File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,9 @@ DatadogAgent::DatadogAgent(
148148 assert (logger_);
149149 assert (tracer_telemetry_);
150150 if (tracer_telemetry_->enabled ()) {
151+ // Only schedule this if telemetry is enabled.
152+ // Every 10 seconds, have the tracer telemetry capture the metrics values.
153+ // Every 60 seconds, also report those values to the datadog agent.
151154 cancel_telemetry_timer_ = event_scheduler_->schedule_recurring_event (
152155 std::chrono::seconds (10 ), [this , n = 0 ]() mutable {
153156 n++;
@@ -164,8 +167,11 @@ DatadogAgent::~DatadogAgent() {
164167 cancel_scheduled_flush_ ();
165168 flush ();
166169 if (tracer_telemetry_->enabled ()) {
170+ // This action only needs to occur if tracer telemetry is enabled.
167171 cancel_telemetry_timer_ ();
168172 tracer_telemetry_->capture_metrics ();
173+ // The app-closing message is bundled with a message containing the final
174+ // metric values.
169175 send_app_closing ();
170176 }
171177 http_client_->drain (deadline);
Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ TracerTelemetry::TracerTelemetry(
1818 span_defaults_(span_defaults),
1919 hostname_(get_hostname().value_or(" hostname-unavailable" )) {
2020 if (enabled_) {
21+ // Register all the metrics that we're tracking by adding them to the
22+ // metrics_snapshots_ container. This allows for simpler iteration logic
23+ // when using the values in `generate-metrics` messages.
2124 metrics_snapshots_.emplace_back (metrics_.tracer .spans_created ,
2225 MetricSnapshot{});
2326 metrics_snapshots_.emplace_back (metrics_.tracer .spans_finished ,
You can’t perform that action at this time.
0 commit comments