Skip to content

Commit

Permalink
kafka: add option to record latency in fill_fetch_responses
Browse files Browse the repository at this point in the history
  • Loading branch information
ballard26 authored and StephanDollberg committed Apr 26, 2024
1 parent afd1c9a commit de1c248
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/v/kafka/server/handlers/fetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ static void fill_fetch_responses(
op_context& octx,
std::vector<read_result> results,
const std::vector<op_context::response_placeholder_ptr>& responses,
op_context::latency_point start_time) {
op_context::latency_point start_time,
bool record_latency = true) {
auto range = boost::irange<size_t>(0, results.size());
if (unlikely(results.size() != responses.size())) {
// soft assert & recovery attempt
Expand Down Expand Up @@ -520,10 +521,13 @@ static void fill_fetch_responses(
}

resp_it->set(std::move(resp));
std::chrono::microseconds fetch_latency
= std::chrono::duration_cast<std::chrono::microseconds>(
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<std::chrono::microseconds>(
op_context::latency_clock::now() - start_time);
octx.rctx.probe().record_fetch_latency(fetch_latency);
}
}
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit de1c248

Please sign in to comment.