Skip to content

Commit 1fd88bd

Browse files
committed
Call capture_and_reset_value() instead of having reset behavior inside of
value()
1 parent 5603789 commit 1fd88bd

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/datadog/metrics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const std::string Metric::name() { return name_; }
1212
const std::string Metric::type() { return type_; }
1313
const std::vector<std::string> Metric::tags() { return tags_; }
1414
bool Metric::common() { return common_; }
15-
uint64_t Metric::value() { return value_.exchange(0); }
15+
uint64_t Metric::value() { return value_; }
16+
uint64_t Metric::capture_and_reset_value() { return value_.exchange(0); }
1617

1718
CounterMetric::CounterMetric(const std::string name,
1819
const std::vector<std::string> tags, bool common)

src/datadog/metrics.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Metric {
3434
const std::vector<std::string> tags();
3535
bool common();
3636
uint64_t value();
37+
uint64_t capture_and_reset_value();
3738
};
3839

3940
class CounterMetric : public Metric {

src/datadog/tracer_telemetry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void TracerTelemetry::capture_metrics() {
102102
clock_().wall.time_since_epoch())
103103
.count();
104104
for (auto& m : metrics_snapshots_) {
105-
auto value = m.first.get().value();
105+
auto value = m.first.get().capture_and_reset_value();
106106
m.second.emplace_back(timepoint, value);
107107
}
108108
}

0 commit comments

Comments
 (0)