-
Notifications
You must be signed in to change notification settings - Fork 21
chore(stats)!: submit p0 telemetry in stats #2130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -299,14 +299,19 @@ fn add_spans_to_stats<T: libdd_trace_utils::span::TraceData>( | |
| } | ||
|
|
||
| /// Process traces for stats computation and update header tags accordingly. | ||
| /// Returns the number of P0 traces and spans that were dropped. | ||
| /// | ||
| /// If a telemetry client is provided and stats are enabled, dropped P0 counts | ||
| /// will be sent to telemetry. | ||
| pub(crate) fn process_traces_for_stats<T: libdd_trace_utils::span::TraceData>( | ||
| traces: &mut Vec<Vec<libdd_trace_utils::span::v04::Span<T>>>, | ||
| header_tags: &mut libdd_trace_utils::trace_utils::TracerHeaderTags, | ||
| client_side_stats: &ArcSwap<StatsComputationStatus>, | ||
| client_computed_top_level: bool, | ||
| trace_filterer: &TraceFilterer, | ||
| ) -> libdd_trace_utils::span::trace_utils::DroppedStats { | ||
| #[cfg(all(not(target_arch = "wasm32"), feature = "telemetry"))] telemetry: Option< | ||
| &crate::telemetry::TelemetryClient, | ||
| >, | ||
| ) { | ||
| let status = client_side_stats.load(); | ||
| if let StatsComputationStatus::Enabled { | ||
| stats_concentrator, .. | ||
|
|
@@ -322,22 +327,24 @@ pub(crate) fn process_traces_for_stats<T: libdd_trace_utils::span::TraceData>( | |
| add_spans_to_stats(stats_concentrator, traces); | ||
| // Once stats have been computed we can drop all chunks that are not going to be | ||
| // sampled by the agent | ||
| let mut dropped_stats = libdd_trace_utils::span::trace_utils::drop_chunks(traces); | ||
| dropped_stats.dropped_by_trace_filter = dropped_by_trace_filter; | ||
| let dropped_p0_stats = libdd_trace_utils::span::trace_utils::drop_chunks(traces); | ||
|
|
||
| // Update the headers to indicate that stats have been computed and forward dropped | ||
| // traces counts | ||
| header_tags.client_computed_top_level = true; | ||
| header_tags.client_computed_stats = true; | ||
| header_tags.dropped_p0_traces = dropped_stats.dropped_p0_traces; | ||
| header_tags.dropped_p0_spans = dropped_stats.dropped_p0_spans; | ||
|
|
||
| dropped_stats | ||
| } else { | ||
| libdd_trace_utils::span::trace_utils::DroppedStats { | ||
| dropped_p0_traces: 0, | ||
| dropped_p0_spans: 0, | ||
| dropped_by_trace_filter: 0, | ||
| header_tags.dropped_p0_traces = dropped_p0_stats.dropped_p0_traces; | ||
| header_tags.dropped_p0_spans = dropped_p0_stats.dropped_p0_spans; | ||
|
|
||
| // Send dropped P0 stats directly to telemetry if available | ||
| #[cfg(all(not(target_arch = "wasm32"), feature = "telemetry"))] | ||
| if let Some(telemetry_client) = telemetry { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be a good idea to add a test asserting that stats are sent?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be a bit heavy. There's a test with http mock in the telemetry component, I don't think it should be up to the caller to check that telemetry correctly sends the telemetry. |
||
| if let Err(e) = telemetry_client.send_client_side_stats_drops( | ||
| dropped_p0_stats.dropped_p0_traces, | ||
| dropped_by_trace_filter, | ||
| ) { | ||
| tracing::error!(?e, "Error sending dropped P0 stats to telemetry"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.