Example #1
0
        private Trace()
        {
            var traceId     = RandomUtils.NextLong();
            var traceIdHigh = TraceManager.Trace128Bits ? RandomUtils.NextLong() : 0;
            var spanId      = RandomUtils.NextLong();

            var isSampled = TraceManager.Sampler.Sample(traceId);

            CurrentSpan   = new SpanState(traceIdHigh: traceIdHigh, traceId: traceId, parentSpanId: null, spanId: spanId, isSampled: isSampled, isDebug: false);
            CorrelationId = NumberUtils.LongToGuid(traceId);
        }
Example #2
0
        private Trace()
        {
            var traceId     = RandomUtils.NextLong();
            var traceIdHigh = TraceManager.Trace128Bits ? RandomUtils.NextLong() : 0;
            var spanId      = RandomUtils.NextLong();

            var isSampled = TraceManager.Sampler.Sample(traceId);

            var flags = SpanFlags.SamplingKnown;

            if (isSampled)
            {
                flags = flags | SpanFlags.Sampled;
            }

            CurrentSpan   = new SpanState(traceIdHigh: traceIdHigh, traceId: traceId, parentSpanId: null, spanId: spanId, flags: flags);
            CorrelationId = NumberUtils.LongToGuid(traceId);
        }
Example #3
0
 public Record(SpanState spanState, DateTime timestamp, IAnnotation annotation)
 {
     _spanState  = spanState;
     _timestamp  = timestamp;
     _annotation = annotation;
 }
Example #4
0
        /// <summary>
        /// Creates a derived trace which inherits from
        /// the trace id and flags.
        /// It has a new span id and the parent id set to the current span id.
        /// </summary>
        /// <returns></returns>
        public Trace Child()
        {
            var childState = new SpanState(traceIdHigh: CurrentSpan.TraceIdHigh, traceId: CurrentSpan.TraceId, parentSpanId: CurrentSpan.SpanId, spanId: RandomUtils.NextLong(), isSampled: CurrentSpan.Sampled, isDebug: CurrentSpan.Debug);

            return(new Trace(childState));
        }
Example #5
0
 /// <summary>
 /// Force this trace to be sent.
 /// </summary>
 public void ForceSampled()
 {
     CurrentSpan = new SpanState(traceIdHigh: CurrentSpan.TraceIdHigh, traceId: CurrentSpan.TraceId, parentSpanId: CurrentSpan.SpanId, spanId: RandomUtils.NextLong(), isSampled: true, isDebug: CurrentSpan.Debug);
 }
Example #6
0
        /// <summary>
        /// Creates a derived trace which inherits from
        /// the trace id and flags.
        /// It has a new span id and the parent id set to the current span id.
        /// </summary>
        /// <returns></returns>
        public Trace Child()
        {
            var childState = new SpanState(traceIdHigh: CurrentSpan.TraceIdHigh, traceId: CurrentSpan.TraceId, parentSpanId: CurrentSpan.SpanId, spanId: RandomUtils.NextLong(), flags: CurrentSpan.Flags);

            return(new Trace(childState));
        }
Example #7
0
 private Trace(SpanState spanState)
 {
     CurrentSpan   = spanState;
     CorrelationId = NumberUtils.LongToGuid(CurrentSpan.TraceId);
 }
Example #8
0
 /// <summary>
 /// Creates a trace from an existing span state.
 /// </summary>
 /// <param name="spanState"></param>
 /// <returns></returns>
 public static Trace CreateFromId(SpanState spanState)
 {
     return(new Trace(spanState));
 }