public void TestPropagationJaegerAndB3FromConfig() { TraceId traceId = new TraceId(1234); SpanId spanId = new SpanId(5678); TestTextMap textMap = new TestTextMap(); SpanContext spanContext = new SpanContext(traceId, spanId, new SpanId(0), (byte)0); Configuration.CodecConfiguration codecConfiguration = new Configuration.CodecConfiguration(_loggerFactory) .WithPropagation(Configuration.Propagation.Jaeger) .WithPropagation(Configuration.Propagation.B3); ITracer tracer = new Configuration("Test", _loggerFactory) .WithCodec(codecConfiguration) .GetTracer(); tracer.Inject(spanContext, BuiltinFormats.TextMap, textMap); Assert.NotNull(textMap.Get("uber-trace-id")); Assert.NotNull(textMap.Get("X-B3-TraceId")); Assert.NotNull(textMap.Get("X-B3-SpanId")); SpanContext extractedContext = (SpanContext)tracer.Extract(BuiltinFormats.TextMap, textMap); Assert.Equal(traceId, extractedContext.TraceId); Assert.Equal(spanId, extractedContext.SpanId); }
public void TestPropagationValidFormat() { SetProperty(Configuration.JaegerPropagation, "jaeger,invalid"); SetProperty(Configuration.JaegerServiceName, "Test"); TestTextMap textMap = new TestTextMap(); SpanContext spanContext = new SpanContext(new TraceId(1234), new SpanId(5678), new SpanId(0), (byte)0); Configuration.FromEnv(_loggerFactory).GetTracer().Inject(spanContext, BuiltinFormats.TextMap, textMap); // Check that jaeger context still available even though invalid format specified Assert.NotNull(textMap.Get("uber-trace-id")); }
public void TestPropagationDefault() { SetProperty(Configuration.JaegerServiceName, "Test"); TestTextMap textMap = new TestTextMap(); SpanContext spanContext = new SpanContext(new TraceId(1234), new SpanId(5678), new SpanId(0), (byte)0); Configuration.FromEnv(_loggerFactory).GetTracer().Inject(spanContext, BuiltinFormats.TextMap, textMap); Assert.NotNull(textMap.Get("uber-trace-id")); Assert.Null(textMap.Get("X-B3-TraceId")); Assert.Null(textMap.Get("X-B3-SpanId")); }
public void TestPropagationJaegerAndB3FromEnv() { SetProperty(Configuration.JaegerPropagation, "jaeger,b3"); SetProperty(Configuration.JaegerServiceName, "Test"); TraceId traceId = new TraceId(1234); SpanId spanId = new SpanId(5678); TestTextMap textMap = new TestTextMap(); SpanContext spanContext = new SpanContext(traceId, spanId, new SpanId(0), (byte)0); ITracer tracer = Configuration.FromEnv(_loggerFactory).GetTracer(); tracer.Inject(spanContext, BuiltinFormats.TextMap, textMap); Assert.NotNull(textMap.Get("uber-trace-id")); Assert.NotNull(textMap.Get("X-B3-TraceId")); Assert.NotNull(textMap.Get("X-B3-SpanId")); SpanContext extractedContext = (SpanContext)tracer.Extract(BuiltinFormats.TextMap, textMap); Assert.Equal(traceId, extractedContext.TraceId); Assert.Equal(spanId, extractedContext.SpanId); }