예제 #1
0
        public SpanBuilder(
            [NotNull] TracerSettings settings,
            [NotNull] IDisposable contextScope,
            [NotNull] TraceContext currentContext,
            [CanBeNull] TraceContext parentContext)
        {
            this.settings     = settings ?? throw new ArgumentNullException(nameof(settings));
            this.contextScope = contextScope ?? throw new ArgumentNullException(nameof(contextScope));

            metadata    = ConstructInitialMetadata(currentContext, parentContext);
            annotations = ConstructInitialAnnotations(settings);
            watch       = Stopwatch.StartNew();
        }
예제 #2
0
        private static SpanMetadata ConstructInitialMetadata([NotNull] TraceContext currentContext, [CanBeNull] TraceContext parentContext)
        {
            var beginTimestamp = PreciseDateTime.Now;
            var endTimestamp   = DateTimeOffset.MinValue;

            var parentSpanId = parentContext?.SpanId;

            if (parentSpanId == Guid.Empty)
            {
                parentSpanId = null;
            }

            return(new SpanMetadata(
                       currentContext.TraceId,
                       currentContext.SpanId,
                       parentSpanId,
                       beginTimestamp,
                       endTimestamp));
        }
예제 #3
0
 public static IDisposable Use(TraceContext context)
 {
     return(TraceContextScope.Begin(context));
 }
예제 #4
0
 internal TraceContextScope(TraceContext current, TraceContext parent)
 {
     Current = current;
     Parent  = parent;
 }