コード例 #1
0
        public void TestInject()
        {
            DelegatingTextMap textMap = new DelegatingTextMap();

            b3Codec.Inject(new SpanContext(new TraceId(1), new SpanId(1), new SpanId(1), SpanContextFlags.Sampled), textMap);

            Assert.True(textMap.ContainsKey(B3TextMapCodec.TraceIdName));
            Assert.True(textMap.ContainsKey(B3TextMapCodec.SpanIdName));
        }
コード例 #2
0
        public void Downgrades128BitTraceIdToLower64Bits()
        {
            string hex128Bits  = "463ac35c9f6413ad48485a3953bb6124";
            string lower64Bits = "48485a3953bb6124";

            DelegatingTextMap textMap = new DelegatingTextMap();

            textMap.Set(B3TextMapCodec.TraceIdName, hex128Bits);
            textMap.Set(B3TextMapCodec.SpanIdName, lower64Bits);
            textMap.Set(B3TextMapCodec.ParentSpanIdName, "0");
            textMap.Set(B3TextMapCodec.SampledName, "1");
            textMap.Set(B3TextMapCodec.FlagsName, "1");

            SpanContext context = b3Codec.Extract(textMap);

            //Assert.NotNull(HexCodec.LowerHexToUnsignedLong(lower64Bits));
            Assert.Equal(HexCodec.LowerHexToUnsignedLong(lower64Bits), context.TraceId.Low);
            Assert.Equal(HexCodec.LowerHexToUnsignedLong(lower64Bits), context.SpanId);
            Assert.Equal(new SpanId(0), context.ParentId);
            Assert.True(context.Flags.HasFlag(SpanContextFlags.Sampled));
            Assert.True(context.Flags.HasFlag(SpanContextFlags.Debug));
        }
コード例 #3
0
        public void Supports128BitTraceId()
        {
            string hex128Bits  = "463ac35c9f6413ad48485a3953bb6124";
            string upper64Bits = "463ac35c9f6413ad";
            string lower64Bits = "48485a3953bb6124";

            DelegatingTextMap textMap = new DelegatingTextMap();

            textMap.Set(B3TextMapCodec.TraceIdName, hex128Bits);
            textMap.Set(B3TextMapCodec.SpanIdName, lower64Bits);
            textMap.Set(B3TextMapCodec.SampledName, "1");
            textMap.Set(B3TextMapCodec.FlagsName, "1");

            SpanContext context = b3Codec.Extract(textMap);

            Assert.Equal(long.Parse(upper64Bits, NumberStyles.HexNumber), context.TraceId.High);
            Assert.Equal(long.Parse(lower64Bits, NumberStyles.HexNumber), context.TraceId.Low);
            Assert.Equal(long.Parse(lower64Bits, NumberStyles.HexNumber), context.SpanId);
            Assert.Equal(new SpanId(0), context.ParentId);
            Assert.True(context.Flags.HasFlag(SpanContextFlags.Sampled));
            Assert.True(context.Flags.HasFlag(SpanContextFlags.Debug));
        }