Add profile events for number of HTTP requests and bytes read

This commit is contained in:
Michael Kolupaev 2024-03-26 09:14:20 +00:00
parent 1fb902c5b7
commit 899b856ad6
2 changed files with 13 additions and 0 deletions

View File

@ -722,6 +722,9 @@ The server successfully detected this situation and will download merged part fr
M(AddressesDiscovered, "Total count of new addresses in dns resolve results for http connections") \
M(AddressesExpired, "Total count of expired addresses which is no longer presented in dns resolve results for http connections") \
M(AddressesMarkedAsFailed, "Total count of addresses which has been marked as faulty due to connection errors for http connections") \
\
M(ReadWriteBufferFromHTTPRequestsSent, "Number of HTTP requests sent by ReadWriteBufferFromHTTP") \
M(ReadWriteBufferFromHTTPBytes, "Total size of payload bytes received and sent by ReadWriteBufferFromHTTP. Doesn't include HTTP headers.") \
#ifdef APPLY_FOR_EXTERNAL_EVENTS

View File

@ -8,6 +8,8 @@
namespace ProfileEvents
{
extern const Event ReadBufferSeekCancelConnection;
extern const Event ReadWriteBufferFromHTTPRequestsSent;
extern const Event ReadWriteBufferFromHTTPBytes;
}
@ -245,6 +247,8 @@ ReadWriteBufferFromHTTP::CallResult ReadWriteBufferFromHTTP::callImpl(
auto session = makeHTTPSession(connection_group, uri_, timeouts, proxy_config);
ProfileEvents::increment(ProfileEvents::ReadWriteBufferFromHTTPRequestsSent);
auto & stream_out = session->sendRequest(request);
if (out_stream_callback)
out_stream_callback(stream_out);
@ -480,6 +484,8 @@ bool ReadWriteBufferFromHTTP::nextImpl()
BufferBase::set(impl->buffer().begin(), impl->buffer().size(), impl->offset());
offset_from_begin_pos += working_buffer.size();
ProfileEvents::increment(ProfileEvents::ReadWriteBufferFromHTTPBytes, working_buffer.size());
},
/*on_retry=*/ [&] ()
{
@ -528,6 +534,8 @@ size_t ReadWriteBufferFromHTTP::readBigAt(char * to, size_t n, size_t offset, co
copyFromIStreamWithProgressCallback(*result.response_stream, to, n, progress_callback, &bytes_copied, &is_canceled);
ProfileEvents::increment(ProfileEvents::ReadWriteBufferFromHTTPBytes, bytes_copied);
offset += bytes_copied;
total_bytes_copied += bytes_copied;
to += bytes_copied;
@ -536,6 +544,8 @@ size_t ReadWriteBufferFromHTTP::readBigAt(char * to, size_t n, size_t offset, co
},
/*on_retry=*/ [&] ()
{
ProfileEvents::increment(ProfileEvents::ReadWriteBufferFromHTTPBytes, bytes_copied);
offset += bytes_copied;
total_bytes_copied += bytes_copied;
to += bytes_copied;