Skip to content

Commit 64c0e38

Browse files
committed
Record presto exchange source request duration and num of retries
1 parent 74c0411 commit 64c0e38

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

presto-native-execution/presto_cpp/main/PrestoExchangeSource.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ void PrestoExchangeSource::handleDataResponse(
255255

256256
void PrestoExchangeSource::processDataResponse(
257257
std::unique_ptr<http::HttpResponse> response) {
258+
RECORD_HISTOGRAM_METRIC_VALUE(
259+
kCounterExchangeRequestDuration, dataRequestRetryState_.durationMs());
260+
RECORD_HISTOGRAM_METRIC_VALUE(
261+
kCounterExchangeRequestNumRetries, dataRequestRetryState_.numTries());
258262
if (closed_.load()) {
259263
// If PrestoExchangeSource is already closed, just free all buffers
260264
// allocated without doing any processing. This can happen when a super slow

presto-native-execution/presto_cpp/main/PrestoExchangeSource.h

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ class PrestoExchangeSource : public velox::exec::ExchangeSource {
5656
return velox::getCurrentTimeMs() - startMs_;
5757
}
5858

59+
size_t numTries() const {
60+
return numTries_;
61+
}
62+
5963
// Returns whether we have exhausted all retries. We only retry if we spent
6064
// less than maxWaitMs_ time after we first started.
6165
bool isExhausted() const {

presto-native-execution/presto_cpp/main/common/Counters.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,29 @@ void registerPrestoMetrics() {
108108
95,
109109
99,
110110
100);
111+
112+
// Tracks exchange request duration in range of [0, 300s] with
113+
// 300 buckets and reports P50, P90, P99, and P100.
114+
DEFINE_HISTOGRAM_METRIC(
115+
kCounterExchangeRequestDuration,
116+
1'000,
117+
0,
118+
300'000,
119+
50,
120+
90,
121+
99,
122+
100);
123+
// Tracks exchange request num of retris in range of [0, 20] with
124+
// 20 buckets and reports P50, P90, P99, and P100.
125+
DEFINE_HISTOGRAM_METRIC(
126+
kCounterExchangeRequestNumRetries,
127+
1,
128+
0,
129+
20,
130+
50,
131+
90,
132+
99,
133+
100);
111134
DEFINE_METRIC(kCounterMemoryPushbackCount, facebook::velox::StatType::COUNT);
112135
DEFINE_HISTOGRAM_METRIC(
113136
kCounterMemoryPushbackLatencyMs, 10'000, 0, 100'000, 50, 90, 99, 100);

presto-native-execution/presto_cpp/main/common/Counters.h

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ constexpr folly::StringPiece kCounterHTTPClientTransactionCreateDelay{
4747
constexpr folly::StringPiece kCounterExchangeSourcePeakQueuedBytes{
4848
"presto_cpp.exchange_source_peak_queued_bytes"};
4949

50+
constexpr folly::StringPiece kCounterExchangeRequestDuration{
51+
"presto_cpp.exchange.request.duration"};
52+
constexpr folly::StringPiece kCounterExchangeRequestNumRetries{
53+
"presto_cpp.exchange.request.num_retries"};
54+
5055
constexpr folly::StringPiece kCounterNumQueryContexts{
5156
"presto_cpp.num_query_contexts"};
5257

0 commit comments

Comments
 (0)