Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changesets/fix_bnjjj_filter_metric_events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Don't include metric events in spans ([PR #5649](https://github.com/apollographql/router/pull/5649))

Previously some internal metric events were included in traces and spans. This PR remove this noise.

By [@bnjjj](https://github.com/bnjjj) in https://github.com/apollographql/router/pull/5649
5 changes: 5 additions & 0 deletions apollo-router/src/plugins/telemetry/otel/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use crate::plugins::telemetry::consts::OTEL_STATUS_CODE;
use crate::plugins::telemetry::consts::OTEL_STATUS_MESSAGE;
use crate::plugins::telemetry::consts::REQUEST_SPAN_NAME;
use crate::plugins::telemetry::consts::ROUTER_SPAN_NAME;
use crate::plugins::telemetry::formatters::filter_metric_events;
use crate::plugins::telemetry::reload::IsSampled;
use crate::plugins::telemetry::reload::SampledSpan;
use crate::plugins::telemetry::reload::SPAN_SAMPLING_RATE;
Expand Down Expand Up @@ -960,6 +961,10 @@ where
/// [`ERROR`]: tracing::Level::ERROR
/// [`Error`]: opentelemetry::trace::StatusCode::Error
fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>) {
// Don't include deprecated metric events
if !filter_metric_events(event) {
return;
}
// Ignore events that are not in the context of a span
if let Some(span) = ctx.lookup_current() {
let mut extensions = span.extensions_mut();
Expand Down
7 changes: 6 additions & 1 deletion apollo-router/tests/integration/telemetry/jaeger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ async fn validate_trace(
.finish();

let id = id.to_string();
println!("trace id: {}", id);
let url = format!("http://localhost:16686/api/traces/{id}?{params}");
for _ in 0..10 {
if find_valid_trace(
Expand Down Expand Up @@ -428,6 +427,12 @@ fn verify_router_span_fields(
.first(),
Some(&&Value::String("1.0".to_string()))
);
assert!(router_span
.select_path("$.logs[*].fields[?(@.key == 'histogram.apollo_router_span')].value")?
.is_empty(),);
assert!(router_span
.select_path("$.logs[*].fields[?(@.key == 'histogram.apollo_router_span')].value")?
.is_empty(),);
if custom_span_instrumentation {
assert_eq!(
router_span
Expand Down