diff --git a/test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CompositePropagatorTest.cs b/test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CompositePropagatorTest.cs index 8fe1f8f7be1..8e9d26131f0 100644 --- a/test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CompositePropagatorTest.cs +++ b/test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CompositePropagatorTest.cs @@ -54,114 +54,6 @@ public void CompositePropagator_NullTextFormatList() Assert.Throws(() => new CompositePropagator(null)); } - [Fact] - public void CompositePropagator_WithTraceContext() - { - var expectedHeaders = new Dictionary - { - { TraceParent, $"00-{this.traceId}-{this.spanId}-01" }, - }; - - var compositePropagator = new CompositePropagator(new List - { - new TraceContextFormat(), - }); - - var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null); - var carrier = new Dictionary(); - compositePropagator.Inject(activityContext, carrier, Setter); - - Assert.Equal(expectedHeaders, carrier); - - var ctx = compositePropagator.Extract(activityContext, expectedHeaders, Getter); - Assert.Equal(activityContext.TraceId, ctx.TraceId); - Assert.Equal(activityContext.SpanId, ctx.SpanId); - - Assert.Empty(compositePropagator.Fields); - } - - [Fact] - public void CompositePropagator_WithTraceContextAndB3Format() - { - var expectedHeaders = new Dictionary - { - { TraceParent, $"00-{this.traceId}-{this.spanId}-01" }, - { B3Format.XB3TraceId, this.traceId.ToString() }, - { B3Format.XB3SpanId, this.spanId.ToString() }, - { B3Format.XB3Sampled, "1" }, - }; - - var compositePropagator = new CompositePropagator(new List - { - new TraceContextFormat(), - new B3Format(), - }); - - var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null); - var carrier = new Dictionary(); - compositePropagator.Inject(activityContext, carrier, Setter); - - Assert.Equal(expectedHeaders, carrier); - - var ctx = compositePropagator.Extract(activityContext, expectedHeaders, Getter); - Assert.Equal(activityContext.TraceId, ctx.TraceId); - Assert.Equal(activityContext.SpanId, ctx.SpanId); - Assert.True(ctx.IsValid()); - - bool isInjected = compositePropagator.IsInjected(carrier, Getter); - Assert.True(isInjected); - } - - [Fact] - public void CompositePropagator_WithB3FormatAndTraceContext() - { - var expectedHeaders = new Dictionary - { - { TraceParent, $"00-{this.traceId}-{this.spanId}-01" }, - { B3Format.XB3TraceId, this.traceId.ToString() }, - { B3Format.XB3SpanId, this.spanId.ToString() }, - { B3Format.XB3Sampled, "1" }, - }; - - var compositePropagator = new CompositePropagator(new List - { - new B3Format(), - new TraceContextFormat(), - }); - - var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null); - var carrier = new Dictionary(); - compositePropagator.Inject(activityContext, carrier, Setter); - - Assert.Equal(expectedHeaders, carrier); - - var ctx = compositePropagator.Extract(activityContext, expectedHeaders, Getter); - Assert.Equal(activityContext.TraceId, ctx.TraceId); - Assert.Equal(activityContext.SpanId, ctx.SpanId); - Assert.True(ctx.IsValid()); - - bool isInjected = compositePropagator.IsInjected(carrier, Getter); - Assert.True(isInjected); - } - - [Fact] - public void CompositePropagator_B3FormatNotInjected() - { - var carrier = new Dictionary - { - { TraceParent, $"00-{this.traceId}-{this.spanId}-01" }, - }; - - var compositePropagator = new CompositePropagator(new List - { - new TraceContextFormat(), - new B3Format(), - }); - - bool isInjected = compositePropagator.IsInjected(carrier, Getter); - Assert.False(isInjected); - } - [Fact] public void CompositePropagator_TestPropagator() { @@ -214,29 +106,5 @@ public void CompositePropagator_UsingSameTag() // if that's true, we skipped the first one since we have a logic to for the default result Assert.Equal(2, count); } - - [Fact] - public void CompositePropagator_CustomAndTraceFormats() - { - var compositePropagator = new CompositePropagator(new List - { - new TestPropagator("custom-traceparent", "custom-tracestate-1"), - new TraceContextFormat(), - }); - - var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null); - var carrier = new Dictionary(); - - compositePropagator.Inject(activityContext, carrier, Setter); - Assert.Equal(2, carrier.Count); - - bool isInjected = compositePropagator.IsInjected(carrier, Getter); - Assert.True(isInjected); - - ActivityContext newContext = compositePropagator.Extract(default, carrier, Getter); - Assert.Equal(this.traceId, newContext.TraceId); - Assert.Equal(this.spanId, newContext.SpanId); - Assert.True(newContext.IsValid()); - } } }