diff --git a/apollo-router/tests/integration/telemetry/datadog.rs b/apollo-router/tests/integration/telemetry/datadog.rs index 95d6117092..2a58132927 100644 --- a/apollo-router/tests/integration/telemetry/datadog.rs +++ b/apollo-router/tests/integration/telemetry/datadog.rs @@ -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> { @@ -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(()) @@ -911,7 +953,8 @@ impl Verifier for DatadogTraceSpec { .as_f64() .expect("psr not string") .to_string(), - psr + psr, + "psr mismatch" ); } } diff --git a/apollo-router/tests/integration/telemetry/fixtures/datadog_agent_sampling_disabled_0.router.yaml b/apollo-router/tests/integration/telemetry/fixtures/datadog_agent_sampling_disabled_0.router.yaml new file mode 100644 index 0000000000..42f56dd642 --- /dev/null +++ b/apollo-router/tests/integration/telemetry/fixtures/datadog_agent_sampling_disabled_0.router.yaml @@ -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 +