From a05649c620cf15740f7f84ade69d7646c63711b4 Mon Sep 17 00:00:00 2001 From: Kevin Hoxha Date: Mon, 12 Dec 2022 11:02:10 -0800 Subject: [PATCH] metrics: Add knob to control emission of DDSketch buckets --- fdbrpc/Stats.actor.cpp | 25 ++++++++++++++++--------- flow/Knobs.cpp | 1 + flow/include/flow/Knobs.h | 1 + 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/fdbrpc/Stats.actor.cpp b/fdbrpc/Stats.actor.cpp index ae6489c547..dd065d0ba8 100644 --- a/fdbrpc/Stats.actor.cpp +++ b/fdbrpc/Stats.actor.cpp @@ -259,16 +259,23 @@ void LatencySample::logSample() { std::string port_str = std::to_string(addr.port); switch (model) { case MetricsDataModel::OTLP: { - if (metrics->histMap.find(IMetric::id) != metrics->histMap.end()) { - metrics->histMap[IMetric::id].points.emplace_back( - sketch.getErrorGuarantee(), sketch.getSamples(), sketch.min(), sketch.max(), sketch.getSum()); - } else { - metrics->histMap[IMetric::id] = OTEL::OTELHistogram( - name, sketch.getErrorGuarantee(), sketch.getSamples(), sketch.min(), sketch.max(), sketch.getSum()); + // We only want to emit the entire DDSketch if the knob is set + if (FLOW_KNOBS->METRICS_EMIT_DDSKETCH) { + if (metrics->histMap.find(IMetric::id) != metrics->histMap.end()) { + metrics->histMap[IMetric::id].points.emplace_back( + sketch.getErrorGuarantee(), sketch.getSamples(), sketch.min(), sketch.max(), sketch.getSum()); + } else { + metrics->histMap[IMetric::id] = OTEL::OTELHistogram(name, + sketch.getErrorGuarantee(), + sketch.getSamples(), + sketch.min(), + sketch.max(), + sketch.getSum()); + } + metrics->histMap[IMetric::id].points.back().addAttribute("ip", ip_str); + metrics->histMap[IMetric::id].points.back().addAttribute("port", port_str); + metrics->histMap[IMetric::id].points.back().startTime = sampleEmit; } - metrics->histMap[IMetric::id].points.back().addAttribute("ip", ip_str); - metrics->histMap[IMetric::id].points.back().addAttribute("port", port_str); - metrics->histMap[IMetric::id].points.back().startTime = sampleEmit; createOtelGauge(p50id, name + "p50", p50); createOtelGauge(p90id, name + "p90", p90); createOtelGauge(p95id, name + "p95", p95); diff --git a/flow/Knobs.cpp b/flow/Knobs.cpp index eedeb689ba..ee8c9e4ed6 100644 --- a/flow/Knobs.cpp +++ b/flow/Knobs.cpp @@ -95,6 +95,7 @@ void FlowKnobs::initialize(Randomize randomize, IsSimulated isSimulated) { init( STATSD_UDP_EMISSION_PORT, 8125 ); init( OTEL_UDP_EMISSION_ADDR, "127.0.0.1"); init( OTEL_UDP_EMISSION_PORT, 8903 ); + init( METRICS_EMIT_DDSKETCH, false ); // Determines if DDSketch buckets will get emitted //connectionMonitor init( CONNECTION_MONITOR_LOOP_TIME, isSimulated ? 0.75 : 1.0 ); if( randomize && BUGGIFY ) CONNECTION_MONITOR_LOOP_TIME = 6.0; diff --git a/flow/include/flow/Knobs.h b/flow/include/flow/Knobs.h index 1ff40625ba..4fc0ee5e8a 100644 --- a/flow/include/flow/Knobs.h +++ b/flow/include/flow/Knobs.h @@ -152,6 +152,7 @@ public: std::string OTEL_UDP_EMISSION_ADDR; int STATSD_UDP_EMISSION_PORT; int OTEL_UDP_EMISSION_PORT; + bool METRICS_EMIT_DDSKETCH; // run loop profiling double RUN_LOOP_PROFILING_INTERVAL;