Skip to content

Commit 6776fb8

Browse files
authored
Revert "Ensure datadog propagator is exclusively active (#8514)" (#8654)
1 parent 951d486 commit 6776fb8

File tree

7 files changed

+319
-348
lines changed

7 files changed

+319
-348
lines changed

.changesets/maint_rohan_b99_datadog_propagator_must_be_exclusively_active.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7366,12 +7366,9 @@ expression: "&schema"
73667366
"type": "boolean"
73677367
},
73687368
"datadog": {
7369-
"default": null,
7369+
"default": false,
73707370
"description": "Propagate Datadog",
7371-
"type": [
7372-
"boolean",
7373-
"null"
7374-
]
7371+
"type": "boolean"
73757372
},
73767373
"jaeger": {
73777374
"default": false,

apollo-router/src/plugins/telemetry/config.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -225,32 +225,6 @@ pub(crate) struct Tracing {
225225
pub(crate) datadog: tracing::datadog::Config,
226226
}
227227

228-
impl Tracing {
229-
pub(crate) fn is_baggage_propagation_enabled(&self) -> bool {
230-
self.propagation.baggage
231-
}
232-
233-
pub(crate) fn is_trace_context_propagation_enabled(&self) -> bool {
234-
self.propagation.trace_context || self.otlp.enabled
235-
}
236-
237-
pub(crate) fn is_jaeger_propagation_enabled(&self) -> bool {
238-
self.propagation.jaeger
239-
}
240-
241-
pub(crate) fn is_datadog_propagation_enabled(&self) -> bool {
242-
self.propagation.datadog.unwrap_or(false) || self.datadog.enabled
243-
}
244-
245-
pub(crate) fn is_zipkin_propagation_enabled(&self) -> bool {
246-
self.propagation.zipkin || self.zipkin.enabled
247-
}
248-
249-
pub(crate) fn is_aws_xray_propagation_enabled(&self) -> bool {
250-
self.propagation.aws_xray
251-
}
252-
}
253-
254228
#[derive(Clone, Default, Debug, Deserialize, JsonSchema, PartialEq)]
255229
#[serde(deny_unknown_fields, default)]
256230
pub(crate) struct ExposeTraceId {
@@ -340,7 +314,7 @@ pub(crate) struct Propagation {
340314
/// Propagate Jaeger
341315
pub(crate) jaeger: bool,
342316
/// Propagate Datadog
343-
pub(crate) datadog: Option<bool>,
317+
pub(crate) datadog: bool,
344318
/// Propagate Zipkin
345319
pub(crate) zipkin: bool,
346320
/// Propagate AWS X-Ray

apollo-router/src/plugins/telemetry/reload/builder.rs

Lines changed: 3 additions & 243 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'a> Builder<'a> {
8585
self.setup_public_tracing()?;
8686
self.setup_public_metrics()?;
8787
self.setup_apollo_metrics()?;
88-
self.setup_propagation()?;
88+
self.setup_propagation();
8989
Ok((self.activation, self.endpoints, self.apollo_sender))
9090
})
9191
}
@@ -206,13 +206,12 @@ impl<'a> Builder<'a> {
206206
|| previous_config.exporters.tracing.common != self.config.exporters.tracing.common
207207
}
208208

209-
fn setup_propagation(&mut self) -> Result<(), BoxError> {
209+
fn setup_propagation(&mut self) {
210210
let propagators = create_propagator(
211211
&self.config.exporters.tracing.propagation,
212212
&self.config.exporters.tracing,
213-
)?;
213+
);
214214
self.activation.with_tracer_propagator(propagators);
215-
Ok(())
216215
}
217216

218217
fn setup_logging(&mut self) {
@@ -246,7 +245,6 @@ mod tests {
246245
use crate::plugins::telemetry::config::Exporters;
247246
use crate::plugins::telemetry::config::Instrumentation;
248247
use crate::plugins::telemetry::config::Metrics;
249-
use crate::plugins::telemetry::config::Propagation;
250248
use crate::plugins::telemetry::config::Tracing;
251249

252250
fn create_default_config() -> Conf {
@@ -628,242 +626,4 @@ mod tests {
628626
"Tracer provider should reload when span limits change"
629627
);
630628
}
631-
632-
#[tokio::test(flavor = "multi_thread")]
633-
async fn test_datadog_propagation_only_passes() {
634-
let mut config = create_config_with_apollo_enabled();
635-
config.exporters.tracing.propagation = Propagation {
636-
datadog: Some(true),
637-
..Default::default()
638-
};
639-
640-
let builder = Builder::new(&None, &config);
641-
assert!(builder.build().is_ok());
642-
}
643-
644-
#[tokio::test(flavor = "multi_thread")]
645-
async fn test_datadog_with_baggage_propagation_passes() {
646-
let mut config = create_config_with_apollo_enabled();
647-
config.exporters.tracing.propagation = Propagation {
648-
datadog: Some(true),
649-
baggage: true,
650-
..Default::default()
651-
};
652-
653-
let builder = Builder::new(&None, &config);
654-
assert!(builder.build().is_ok());
655-
}
656-
657-
#[tokio::test(flavor = "multi_thread")]
658-
async fn test_jaeger_propagation_only_passes() {
659-
let mut config = create_config_with_apollo_enabled();
660-
config.exporters.tracing.propagation = Propagation {
661-
jaeger: true,
662-
..Default::default()
663-
};
664-
665-
let builder = Builder::new(&None, &config);
666-
assert!(builder.build().is_ok());
667-
}
668-
669-
#[tokio::test(flavor = "multi_thread")]
670-
async fn test_datadog_with_jaeger_propagation_fails() {
671-
let mut config = create_config_with_apollo_enabled();
672-
config.exporters.tracing.propagation = Propagation {
673-
datadog: Some(true),
674-
jaeger: true,
675-
..Default::default()
676-
};
677-
678-
let builder = Builder::new(&None, &config);
679-
assert_eq!(
680-
"datadog propagation cannot be used with any other propagator except for baggage",
681-
builder.build().err().unwrap().to_string()
682-
);
683-
}
684-
685-
#[tokio::test(flavor = "multi_thread")]
686-
async fn test_datadog_with_trace_context_propagation_fails() {
687-
let mut config = create_config_with_apollo_enabled();
688-
config.exporters.tracing.propagation = Propagation {
689-
datadog: Some(true),
690-
trace_context: true,
691-
..Default::default()
692-
};
693-
694-
let builder = Builder::new(&None, &config);
695-
assert_eq!(
696-
"datadog propagation cannot be used with any other propagator except for baggage",
697-
builder.build().err().unwrap().to_string()
698-
);
699-
}
700-
701-
#[tokio::test(flavor = "multi_thread")]
702-
async fn test_datadog_with_zipkin_propagation_fails() {
703-
let mut config = create_config_with_apollo_enabled();
704-
config.exporters.tracing.propagation = Propagation {
705-
datadog: Some(true),
706-
zipkin: true,
707-
..Default::default()
708-
};
709-
710-
let builder = Builder::new(&None, &config);
711-
assert_eq!(
712-
"datadog propagation cannot be used with any other propagator except for baggage",
713-
builder.build().err().unwrap().to_string()
714-
);
715-
}
716-
717-
#[tokio::test(flavor = "multi_thread")]
718-
async fn test_datadog_with_aws_xray_propagation_fails() {
719-
let mut config = create_config_with_apollo_enabled();
720-
config.exporters.tracing.propagation = Propagation {
721-
datadog: Some(true),
722-
aws_xray: true,
723-
..Default::default()
724-
};
725-
726-
let builder = Builder::new(&None, &config);
727-
assert_eq!(
728-
"datadog propagation cannot be used with any other propagator except for baggage",
729-
builder.build().err().unwrap().to_string()
730-
);
731-
}
732-
733-
#[tokio::test(flavor = "multi_thread")]
734-
async fn test_datadog_exporter_enabled_with_datadog_propagation_only_passes() {
735-
let mut config = create_config_with_apollo_enabled();
736-
config.exporters.tracing.datadog.enabled = true;
737-
config.exporters.tracing.propagation = Propagation {
738-
datadog: Some(true),
739-
..Default::default()
740-
};
741-
742-
let builder = Builder::new(&None, &config);
743-
assert!(builder.build().is_ok());
744-
}
745-
746-
#[tokio::test(flavor = "multi_thread")]
747-
async fn test_datadog_exporter_enabled_with_datadog_baggage_propagation_passes() {
748-
let mut config = create_config_with_apollo_enabled();
749-
config.exporters.tracing.datadog.enabled = true;
750-
config.exporters.tracing.propagation = Propagation {
751-
datadog: Some(true),
752-
baggage: true,
753-
..Default::default()
754-
};
755-
756-
let builder = Builder::new(&None, &config);
757-
assert!(builder.build().is_ok());
758-
}
759-
760-
#[tokio::test(flavor = "multi_thread")]
761-
async fn test_datadog_exporter_enabled_with_jaeger_propagation_only_fails() {
762-
let mut config = create_config_with_apollo_enabled();
763-
config.exporters.tracing.datadog.enabled = true;
764-
config.exporters.tracing.propagation = Propagation {
765-
jaeger: true,
766-
..Default::default()
767-
};
768-
769-
let builder = Builder::new(&None, &config);
770-
assert_eq!(
771-
"datadog propagation must be explicitly disabled if the datadog exporter is enabled and any propagator other than baggage is enabled",
772-
builder.build().err().unwrap().to_string()
773-
);
774-
}
775-
776-
#[tokio::test(flavor = "multi_thread")]
777-
async fn test_datadog_exporter_enabled_with_datadog_jaeger_propagation_fails() {
778-
let mut config = create_config_with_apollo_enabled();
779-
config.exporters.tracing.datadog.enabled = true;
780-
config.exporters.tracing.propagation = Propagation {
781-
datadog: Some(true),
782-
jaeger: true,
783-
..Default::default()
784-
};
785-
786-
let builder = Builder::new(&None, &config);
787-
assert_eq!(
788-
"if the datadog exporter is enabled and any other propagator is enabled, the datadog propagator must be disabled",
789-
builder.build().err().unwrap().to_string()
790-
);
791-
}
792-
793-
#[tokio::test(flavor = "multi_thread")]
794-
async fn test_datadog_exporter_enabled_with_datadog_trace_context_propagation_fails() {
795-
let mut config = create_config_with_apollo_enabled();
796-
config.exporters.tracing.datadog.enabled = true;
797-
config.exporters.tracing.propagation = Propagation {
798-
datadog: Some(true),
799-
trace_context: true,
800-
..Default::default()
801-
};
802-
803-
let builder = Builder::new(&None, &config);
804-
assert_eq!(
805-
"if the datadog exporter is enabled and any other propagator is enabled, the datadog propagator must be disabled",
806-
builder.build().err().unwrap().to_string()
807-
);
808-
}
809-
810-
#[tokio::test(flavor = "multi_thread")]
811-
async fn test_datadog_exporter_enabled_with_datadog_zipkin_propagation_fails() {
812-
let mut config = create_config_with_apollo_enabled();
813-
config.exporters.tracing.datadog.enabled = true;
814-
config.exporters.tracing.propagation = Propagation {
815-
datadog: Some(true),
816-
zipkin: true,
817-
..Default::default()
818-
};
819-
820-
let builder = Builder::new(&None, &config);
821-
assert_eq!(
822-
"if the datadog exporter is enabled and any other propagator is enabled, the datadog propagator must be disabled",
823-
builder.build().err().unwrap().to_string()
824-
);
825-
}
826-
827-
#[tokio::test(flavor = "multi_thread")]
828-
async fn test_datadog_exporter_enabled_with_datadog_aws_xray_propagation_fails() {
829-
let mut config = create_config_with_apollo_enabled();
830-
config.exporters.tracing.datadog.enabled = true;
831-
config.exporters.tracing.propagation = Propagation {
832-
datadog: Some(true),
833-
aws_xray: true,
834-
..Default::default()
835-
};
836-
837-
let builder = Builder::new(&None, &config);
838-
assert_eq!(
839-
"if the datadog exporter is enabled and any other propagator is enabled, the datadog propagator must be disabled",
840-
builder.build().err().unwrap().to_string()
841-
);
842-
}
843-
844-
#[tokio::test(flavor = "multi_thread")]
845-
async fn test_datadog_exporter_enabled_with_otlp_exporter_enabled_fails() {
846-
let mut config = create_config_with_apollo_enabled();
847-
config.exporters.tracing.datadog.enabled = true;
848-
config.exporters.tracing.otlp.enabled = true;
849-
850-
let builder = Builder::new(&None, &config);
851-
assert_eq!(
852-
"datadog propagation must be explicitly disabled if the datadog exporter is enabled and any propagator other than baggage is enabled",
853-
builder.build().err().unwrap().to_string()
854-
);
855-
}
856-
857-
#[tokio::test(flavor = "multi_thread")]
858-
async fn test_datadog_exporter_enabled_with_zipkin_exporter_enabled_fails() {
859-
let mut config = create_config_with_apollo_enabled();
860-
config.exporters.tracing.datadog.enabled = true;
861-
config.exporters.tracing.zipkin.enabled = true;
862-
863-
let builder = Builder::new(&None, &config);
864-
assert_eq!(
865-
"datadog propagation must be explicitly disabled if the datadog exporter is enabled and any propagator other than baggage is enabled",
866-
builder.build().err().unwrap().to_string()
867-
);
868-
}
869629
}

apollo-router/src/plugins/telemetry/reload/tracing.rs

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -78,42 +78,21 @@ impl<'a> TracingBuilder<'a> {
7878
pub(crate) fn create_propagator(
7979
propagation: &Propagation,
8080
tracing: &Tracing,
81-
) -> Result<TextMapCompositePropagator, BoxError> {
81+
) -> TextMapCompositePropagator {
8282
let mut propagators: Vec<Box<dyn TextMapPropagator + Send + Sync + 'static>> = Vec::new();
83-
84-
if tracing.is_jaeger_propagation_enabled() {
83+
if propagation.jaeger {
8584
propagators.push(Box::<opentelemetry_jaeger_propagator::Propagator>::default());
8685
}
87-
if tracing.is_baggage_propagation_enabled() {
86+
if propagation.baggage {
8887
propagators.push(Box::<opentelemetry_sdk::propagation::BaggagePropagator>::default());
8988
}
90-
if tracing.is_trace_context_propagation_enabled() {
89+
if propagation.trace_context || tracing.otlp.enabled {
9190
propagators.push(Box::<opentelemetry_sdk::propagation::TraceContextPropagator>::default());
9291
}
93-
if tracing.is_zipkin_propagation_enabled() {
92+
if propagation.zipkin || tracing.zipkin.enabled {
9493
propagators.push(Box::<opentelemetry_zipkin::Propagator>::default());
9594
}
96-
if tracing.is_datadog_propagation_enabled() {
97-
if tracing.is_jaeger_propagation_enabled()
98-
|| tracing.is_trace_context_propagation_enabled()
99-
|| tracing.is_zipkin_propagation_enabled()
100-
|| tracing.is_aws_xray_propagation_enabled()
101-
{
102-
if tracing.datadog.enabled && propagation.datadog.unwrap_or(false) {
103-
return Err(BoxError::from(
104-
"if the datadog exporter is enabled and any other propagator is enabled, the datadog propagator must be disabled",
105-
));
106-
} else if let Some(true) = propagation.datadog {
107-
return Err(BoxError::from(
108-
"datadog propagation cannot be used with any other propagator except for baggage",
109-
));
110-
} else if propagation.datadog.is_none() {
111-
return Err(BoxError::from(
112-
"datadog propagation must be explicitly disabled if the datadog exporter is enabled and any propagator other than baggage is enabled",
113-
));
114-
}
115-
}
116-
95+
if propagation.datadog || tracing.datadog.enabled {
11796
propagators.push(Box::<
11897
crate::plugins::telemetry::tracing::datadog_exporter::DatadogPropagator,
11998
>::default());
@@ -130,7 +109,7 @@ pub(crate) fn create_propagator(
130109
propagation.request.format.clone(),
131110
)));
132111
}
133-
Ok(TextMapCompositePropagator::new(propagators))
112+
TextMapCompositePropagator::new(propagators)
134113
}
135114

136115
/// Trait for trace exporters to contribute to tracer provider construction

0 commit comments

Comments
 (0)