예제 #1
0
 protected override void Inject(SpanContext spanContext, ITextMap carrier)
 {
     carrier.Set(_contextKey, EncodedValue(spanContext.ContextAsString()));
     foreach (var entry in spanContext.GetBaggageItems())
     {
         carrier.Set(Keys.PrefixedKey(entry.Key, _baggagePrefix), EncodedValue(entry.Value));
     }
 }
예제 #2
0
        public void TestToStringFormatsPositiveFields()
        {
            TraceId traceId  = new TraceId(-10L);
            SpanId  spanId   = new SpanId(-10L);
            SpanId  parentId = new SpanId(-10L);
            byte    flags    = (byte)129;

            // I use MIN_VALUE because the most significant bit, and thats when
            // we want to make sure the hex number is positive.
            SpanContext context = new SpanContext(traceId, spanId, parentId, (SpanContextFlags)flags);

            context.ContextAsString().Split(':');

            Assert.Equal("fffffffffffffff6:fffffffffffffff6:fffffffffffffff6:81", context.ContextAsString());
            SpanContext contextFromStr = SpanContext.ContextFromString(context.ContextAsString());

            Assert.Equal(traceId, contextFromStr.TraceId);
            Assert.Equal(spanId, contextFromStr.SpanId);
            Assert.Equal(parentId, contextFromStr.ParentId);
            Assert.Equal(flags, (byte)contextFromStr.Flags);
        }