Skip to content

Commit

Permalink
Add test for non datadog agent propagation zero percent sampling.
Browse files Browse the repository at this point in the history
  • Loading branch information
bryn committed Dec 13, 2024
1 parent 55ec86e commit 3b5d256
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
49 changes: 46 additions & 3 deletions apollo-router/tests/integration/telemetry/datadog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ async fn test_sampling_datadog_agent_disabled() -> Result<(), BoxError> {
Ok(())
}



// We want to check we're able to override the behavior of preview_datadog_agent_sampling configuration even if we set a datadog exporter
#[tokio::test(flavor = "multi_thread")]
async fn test_sampling_datadog_agent_disabled_always_sample() -> Result<(), BoxError> {
Expand All @@ -92,9 +90,53 @@ async fn test_sampling_datadog_agent_disabled_always_sample() -> Result<(), BoxE
TraceSpec::builder()
.services(["router", "subgraph"].into())
.subgraph_sampled(true)
.priority_sampled("1")
.build()
.validate_datadog_trace(&mut router, Query::builder().traced(false).build())
.await?;

TraceSpec::builder()
.services(["client", "router", "subgraph"].into())
.subgraph_sampled(true)
.priority_sampled("1")
.build()
.validate_datadog_trace(&mut router, Query::builder().traced(true).build())
.await?;
router.graceful_shutdown().await;

Ok(())
}

#[tokio::test(flavor = "multi_thread")]
async fn test_sampling_datadog_agent_disabled_never_sample() -> Result<(), BoxError> {
if !graph_os_enabled() {
return Ok(());
}
let mut router = IntegrationTest::builder()
.telemetry(Telemetry::Datadog)
.config(include_str!(
"fixtures/datadog_agent_sampling_disabled_0.router.yaml"
))
.build()
.await;

router.start().await;
router.assert_started().await;

TraceSpec::builder()
.services([].into())
.subgraph_sampled(false)
.build()
.validate_datadog_trace(&mut router, Query::builder().traced(false).build())
.await?;

TraceSpec::builder()
.services(["client", "router", "subgraph"].into())
.subgraph_sampled(true)
.priority_sampled("1")
.build()
.validate_datadog_trace(&mut router, Query::builder().traced(true).build())
.await?;
router.graceful_shutdown().await;

Ok(())
Expand Down Expand Up @@ -911,7 +953,8 @@ impl Verifier for DatadogTraceSpec {
.as_f64()
.expect("psr not string")
.to_string(),
psr
psr,
"psr mismatch"
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
telemetry:
apollo:
field_level_instrumentation_sampler: always_off
exporters:
tracing:
experimental_response_trace_id:
enabled: true
header_name: apollo-custom-trace-id
common:
service_name: router
sampler: 0.0
preview_datadog_agent_sampling: false
datadog:
enabled: true
batch_processor:
scheduled_delay: 100ms
fixed_span_names: false
enable_span_mapping: false
instrumentation:
spans:
mode: spec_compliant

0 comments on commit 3b5d256

Please sign in to comment.