From eb04fe8b3b7b08c3933d8d6f617f534c903a8d0a Mon Sep 17 00:00:00 2001 From: Caleb Gilmour Date: Tue, 17 Oct 2023 00:03:05 +0000 Subject: [PATCH] Fix the app-closing metrics payload --- src/datadog/tracer_telemetry.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/datadog/tracer_telemetry.cpp b/src/datadog/tracer_telemetry.cpp index 8d1dba45..1d302fbb 100644 --- a/src/datadog/tracer_telemetry.cpp +++ b/src/datadog/tracer_telemetry.cpp @@ -178,14 +178,26 @@ std::string TracerTelemetry::app_closing() { auto& metric = m.first.get(); auto& points = m.second; if (!points.empty()) { - metrics.emplace_back(nlohmann::json::object({ - {"metric", metric.name()}, - {"tags", metric.tags()}, - {"type", metric.type()}, - {"interval", 60}, - {"points", points}, - {"common", metric.common()}, - })); + auto type = metric.type(); + if (type == "count") { + metrics.emplace_back(nlohmann::json::object({ + {"metric", metric.name()}, + {"tags", metric.tags()}, + {"type", metric.type()}, + {"points", points}, + {"common", metric.common()}, + })); + } else if (type == "gauge") { + // gauge metrics have a interval + metrics.emplace_back(nlohmann::json::object({ + {"metric", metric.name()}, + {"tags", metric.tags()}, + {"type", metric.type()}, + {"interval", 10}, + {"points", points}, + {"common", metric.common()}, + })); + } } points.clear(); }