Exemple #1
0
        public void InjectExtract_TextMap_Ok()
        {
            var carrier = new TextMapCarrier();

            var spanContextShim = new SpanContextShim(new SpanContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.None));

            var format = new TextMapPropagator();

            var tracer = TracerProvider.Default.GetTracer(TracerName);
            var shim   = new TracerShim(tracer, format);

            // first inject
            shim.Inject(spanContextShim, BuiltinFormats.TextMap, carrier);

            // then extract
            var extractedSpanContext = shim.Extract(BuiltinFormats.TextMap, carrier);

            AssertOpenTracerSpanContextEqual(spanContextShim, extractedSpanContext);
        }
Exemple #2
0
        public void InjectExtract_TextMap_Ok()
        {
            var tracerMock = new Mock <Trace.Tracer>();

            var carrier = new TextMapCarrier();

            var spanContextShim = new SpanContextShim(Defaults.GetOpenTelemetrySpanContext());

            var format = new TraceContextFormat();

            var shim = new TracerShim(tracerMock.Object, format, new BinaryFormat());

            // first inject
            shim.Inject(spanContextShim, BuiltinFormats.TextMap, carrier);

            // then extract
            var extractedSpanContext = shim.Extract(BuiltinFormats.TextMap, carrier);

            AssertOpenTracerSpanContextEqual(spanContextShim, extractedSpanContext);
        }