File tree Expand file tree Collapse file tree 4 files changed +27
-3
lines changed
presto-native-execution/presto_cpp/main Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,15 @@ void registerPrestoMetrics() {
3030 DEFINE_METRIC (kCounterNumHTTPRequest , facebook::velox::StatType::COUNT);
3131 DEFINE_METRIC (kCounterNumHTTPRequestError , facebook::velox::StatType::COUNT);
3232 DEFINE_METRIC (kCounterHTTPRequestLatencyMs , facebook::velox::StatType::AVG);
33+ DEFINE_HISTOGRAM_METRIC (
34+ kCounterHTTPRequestSizeBytes ,
35+ 1 * 1024 , // 1KB bucket size
36+ 0 ,
37+ 5 * 1024 * 1024 , // 5MB max
38+ 50 ,
39+ 90 ,
40+ 99 ,
41+ 100 );
3342 DEFINE_METRIC (
3443 kCounterHttpClientNumConnectionsCreated , facebook::velox::StatType::SUM);
3544 // Tracks http client transaction create delay in range of [0, 30s] with
Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ constexpr folly::StringPiece kCounterNumHTTPRequestError{
3838 " presto_cpp.num_http_request_error" };
3939constexpr folly::StringPiece kCounterHTTPRequestLatencyMs {
4040 " presto_cpp.http_request_latency_ms" };
41+ constexpr folly::StringPiece kCounterHTTPRequestSizeBytes {
42+ " presto_cpp.http_request_size_bytes" };
4143
4244constexpr folly::StringPiece kCounterHttpClientNumConnectionsCreated {
4345 " presto_cpp.http.client.num_connections_created" };
Original file line number Diff line number Diff line change @@ -28,18 +28,28 @@ void StatsFilter::onRequest(
2828 Filter::onRequest (std::move (msg));
2929}
3030
31+ void StatsFilter::onBody (std::unique_ptr<folly::IOBuf> body) noexcept {
32+ if (body) {
33+ requestBodySize_ += body->computeChainDataLength ();
34+ }
35+ Filter::onBody (std::move (body));
36+ }
37+
3138void StatsFilter::requestComplete () noexcept {
3239 RECORD_METRIC_VALUE (
3340 kCounterHTTPRequestLatencyMs ,
3441 std::chrono::duration_cast<std::chrono::milliseconds>(
3542 std::chrono::steady_clock::now () - startTime_)
3643 .count ());
37- delete this ;
44+ VLOG (2 ) << " StatsFilter::requestComplete: recording request size="
45+ << requestBodySize_ << " bytes" ;
46+ RECORD_HISTOGRAM_METRIC_VALUE (kCounterHTTPRequestSizeBytes , requestBodySize_);
47+ Filter::requestComplete ();
3848}
3949
4050void StatsFilter::onError (proxygen::ProxygenError err) noexcept {
4151 RECORD_METRIC_VALUE (kCounterNumHTTPRequestError , 1 );
42- delete this ;
52+ Filter::onError (err) ;
4353}
4454
4555} // namespace facebook::presto::http::filters
Original file line number Diff line number Diff line change @@ -25,12 +25,15 @@ class StatsFilter : public proxygen::Filter {
2525
2626 void onRequest (std::unique_ptr<proxygen::HTTPMessage> msg) noexcept override ;
2727
28+ void onBody (std::unique_ptr<folly::IOBuf> body) noexcept override ;
29+
2830 void requestComplete () noexcept override ;
2931
3032 void onError (proxygen::ProxygenError err) noexcept override ;
3133
3234 private:
3335 std::chrono::steady_clock::time_point startTime_;
36+ size_t requestBodySize_{0 };
3437};
3538
3639class StatsFilterFactory : public proxygen ::RequestHandlerFactory {
@@ -43,7 +46,7 @@ class StatsFilterFactory : public proxygen::RequestHandlerFactory {
4346
4447 proxygen::RequestHandler* onRequest (
4548 proxygen::RequestHandler* handler,
46- proxygen::HTTPMessage*) noexcept override {
49+ proxygen::HTTPMessage* msg ) noexcept override {
4750 return new StatsFilter (handler);
4851 }
4952};
You can’t perform that action at this time.
0 commit comments