From de1c248d37aec1670958d5d2aefd45e428a1f9db Mon Sep 17 00:00:00 2001 From: Brandon Allard Date: Thu, 25 Apr 2024 11:19:29 -0400 Subject: [PATCH] kafka: add option to record latency in fill_fetch_responses --- src/v/kafka/server/handlers/fetch.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/v/kafka/server/handlers/fetch.cc b/src/v/kafka/server/handlers/fetch.cc index 3b8255aafad53..ce4390f52b814 100644 --- a/src/v/kafka/server/handlers/fetch.cc +++ b/src/v/kafka/server/handlers/fetch.cc @@ -424,7 +424,8 @@ static void fill_fetch_responses( op_context& octx, std::vector results, const std::vector& responses, - op_context::latency_point start_time) { + op_context::latency_point start_time, + bool record_latency = true) { auto range = boost::irange(0, results.size()); if (unlikely(results.size() != responses.size())) { // soft assert & recovery attempt @@ -520,10 +521,13 @@ static void fill_fetch_responses( } resp_it->set(std::move(resp)); - std::chrono::microseconds fetch_latency - = std::chrono::duration_cast( - op_context::latency_clock::now() - start_time); - octx.rctx.probe().record_fetch_latency(fetch_latency); + + if (record_latency) { + std::chrono::microseconds fetch_latency + = std::chrono::duration_cast( + op_context::latency_clock::now() - start_time); + octx.rctx.probe().record_fetch_latency(fetch_latency); + } } } @@ -1160,7 +1164,8 @@ class nonpolling_fetch_plan_executor final : public fetch_plan_executor::impl { octx, std::move(results.read_results), fetch.responses, - fetch.start_time); + fetch.start_time, + false); octx.rctx.probe().record_fetch_latency( results.first_run_latency_result);