public void CompositePropagator_UsingSameTag() { const string header01 = "custom-tracestate-01"; const string header02 = "custom-tracestate-02"; var compositePropagator = new CompositeTextMapPropagator(new List <TextMapPropagator> { new TestPropagator("custom-traceparent", header01, true), new TestPropagator("custom-traceparent", header02), }); var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null); PropagationContext propagationContext = new PropagationContext(activityContext, default); var carrier = new Dictionary <string, string>(); compositePropagator.Inject(propagationContext, carrier, Setter); Assert.Contains(carrier, kv => kv.Key == "custom-traceparent"); // checking if the latest propagator is the one with the data. So, it will replace the previous one. Assert.Equal($"00-{this.traceId}-{this.spanId}-{header02.Split('-').Last()}", carrier["custom-traceparent"]); // resetting counter count = 0; compositePropagator.Extract(default, carrier, Getter);
public void CompositePropagator_TestPropagator() { var compositePropagator = new CompositeTextMapPropagator(new List <TextMapPropagator> { new TestPropagator("custom-traceparent-1", "custom-tracestate-1"), new TestPropagator("custom-traceparent-2", "custom-tracestate-2"), }); var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null); PropagationContext propagationContext = new PropagationContext(activityContext, default); var carrier = new Dictionary <string, string>(); var activity = new Activity("test"); compositePropagator.Inject(propagationContext, carrier, Setter); Assert.Contains(carrier, kv => kv.Key == "custom-traceparent-1"); Assert.Contains(carrier, kv => kv.Key == "custom-traceparent-2"); }