Skip to content

Commit f41f4d4

Browse files
committed
Add tags to metrics payloads. Ignore unused counters.
1 parent 890490d commit f41f4d4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/datadog/tracer_telemetry.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ void TracerTelemetry::capture_metrics() {
9393
clock_().wall.time_since_epoch())
9494
.count();
9595
for (auto& m : metrics_snapshots_) {
96-
m.second.emplace_back(timepoint, m.first.get().value());
96+
auto value = m.first.get().value();
97+
if (value == 0) {
98+
continue;
99+
}
100+
m.second.emplace_back(timepoint, value);
97101
}
98102

99103
for (auto& m : metrics_snapshots_) {
@@ -118,14 +122,18 @@ std::string TracerTelemetry::heartbeat_and_telemetry() {
118122
for (auto& m : metrics_snapshots_) {
119123
auto& metric = m.first.get();
120124
auto& points = m.second;
125+
if (points.empty()) {
126+
continue;
127+
}
128+
121129
metrics.emplace_back(nlohmann::json::object({
122130
{"metric", metric.name()},
131+
{"tags", metric.tags()},
123132
{"type", metric.type()},
124133
{"interval", 60},
125134
{"points", points},
126135
{"common", metric.common()},
127136
}));
128-
m.second.clear();
129137
}
130138

131139
auto generate_metrics = nlohmann::json::object({

0 commit comments

Comments
 (0)