Exemplo n.º 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();
        }
Exemplo n.º 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));
        }
Exemplo n.º 3
0
 public static IDisposable Use(TraceContext context)
 {
     return(TraceContextScope.Begin(context));
 }
Exemplo n.º 4
0
 internal TraceContextScope(TraceContext current, TraceContext parent)
 {
     Current = current;
     Parent  = parent;
 }