From 876cbc0fc8cac2a65327152650982ac481c6bae0 Mon Sep 17 00:00:00 2001 From: Ke Date: Sun, 9 Mar 2025 20:41:49 -0700 Subject: [PATCH] xxx --- .../presto_cpp/main/common/Counters.cpp | 33 +++++++++++++++++++ .../presto_cpp/main/common/Counters.h | 6 ++++ .../presto_cpp/main/http/HttpClient.cpp | 9 +++++ 3 files changed, 48 insertions(+) diff --git a/presto-native-execution/presto_cpp/main/common/Counters.cpp b/presto-native-execution/presto_cpp/main/common/Counters.cpp index b709d61f8bd38..425905f9dede6 100644 --- a/presto-native-execution/presto_cpp/main/common/Counters.cpp +++ b/presto-native-execution/presto_cpp/main/common/Counters.cpp @@ -43,6 +43,39 @@ void registerPrestoMetrics() { 90, 99, 100); + // Tracks http client transaction create delay in range of [0, 250] with + // 50 buckets and reports P50, P90, P99, and P100. + DEFINE_HISTOGRAM_METRIC( + kCounterHTTPClientNumIdleSessions, + 5, + 0, + 250, + 50, + 90, + 99, + 100); + // Tracks http client transaction create delay in range of [0, 250] with + // 50 buckets and reports P50, P90, P99, and P100. + DEFINE_HISTOGRAM_METRIC( + kCounterHTTPClientNumActiveNonFullSessions, + 5, + 0, + 250, + 50, + 90, + 99, + 100); + // Tracks http client transaction create delay in range of [0, 250] with + // 50 buckets and reports P50, P90, P99, and P100. + DEFINE_HISTOGRAM_METRIC( + kCounterHTTPClientNumFullSessions, + 5, + 0, + 250, + 50, + 90, + 99, + 100); DEFINE_METRIC(kCounterNumQueryContexts, facebook::velox::StatType::AVG); DEFINE_METRIC(kCounterNumTasks, facebook::velox::StatType::AVG); DEFINE_METRIC(kCounterNumTasksBytesProcessed, facebook::velox::StatType::AVG); diff --git a/presto-native-execution/presto_cpp/main/common/Counters.h b/presto-native-execution/presto_cpp/main/common/Counters.h index 2b610da8579ec..1522e16e69798 100644 --- a/presto-native-execution/presto_cpp/main/common/Counters.h +++ b/presto-native-execution/presto_cpp/main/common/Counters.h @@ -43,6 +43,12 @@ constexpr folly::StringPiece kCounterHttpClientNumConnectionsCreated{ "presto_cpp.http.client.num_connections_created"}; constexpr folly::StringPiece kCounterHTTPClientTransactionCreateDelay{ "presto_cpp.http.client.transaction_create_delay_ms"}; +constexpr folly::StringPiece kCounterHTTPClientNumIdleSessions{ + "presto_cpp.http.client.num_idle_sessions"}; +constexpr folly::StringPiece kCounterHTTPClientNumActiveNonFullSessions{ + "presto_cpp.http.num_active_non_full_sessions"}; +constexpr folly::StringPiece kCounterHTTPClientNumFullSessions{ + "presto_cpp.http.client.num_full_sessions"}; /// Peak number of bytes queued in PrestoExchangeSource waiting for consume. constexpr folly::StringPiece kCounterExchangeSourcePeakQueuedBytes{ "presto_cpp.exchange_source_peak_queued_bytes"}; diff --git a/presto-native-execution/presto_cpp/main/http/HttpClient.cpp b/presto-native-execution/presto_cpp/main/http/HttpClient.cpp index 4041755ef3ed1..4eb4466f1e1ac 100644 --- a/presto-native-execution/presto_cpp/main/http/HttpClient.cpp +++ b/presto-native-execution/presto_cpp/main/http/HttpClient.cpp @@ -442,6 +442,15 @@ void HttpClient::initSessionPool() { folly::SemiFuture HttpClient::createTransaction( proxygen::HTTPTransactionHandler* handler) { eventBase_->dcheckIsInEventBaseThread(); + RECORD_HISTOGRAM_METRIC_VALUE( + kCounterHTTPClientNumIdleSessions, + sessionPool_->getNumIdleSessions()); + RECORD_HISTOGRAM_METRIC_VALUE( + kCounterHTTPClientNumActiveNonFullSessions, + sessionPool_->getNumActiveNonFullSessions()); + RECORD_HISTOGRAM_METRIC_VALUE( + kCounterHTTPClientNumFullSessions, + sessionPool_->getNumFullSessions()); if (auto* txn = sessionPool_->getTransaction(handler)) { VLOG(3) << "Reuse same thread connection to " << address_.describe(); return folly::makeSemiFuture(txn);