Exemple #1
0
        /// <inheritdoc />
        public override void SetParentAndStart(TraceContextBase parentTraceContext)
        {
            if (CurrentActivity == null)
            {
                CurrentActivity = new Activity(this.OperationName);
            }

            if (parentTraceContext is W3CTraceContext)
            {
                var context = (W3CTraceContext)parentTraceContext;
                CurrentActivity.SetTraceparent(context.TraceParent);
                CurrentActivity.SetTracestate(context.TraceState);
                OrchestrationTraceContexts = context.OrchestrationTraceContexts.Clone();
            }
            else   // In case of null object
            {
                CurrentActivity.GenerateW3CContext();
            }

            CurrentActivity.Start();

            StartTime    = CurrentActivity.StartTimeUtc;
            TraceParent  = CurrentActivity.GetTraceparent();
            TraceState   = CurrentActivity.GetTracestate();
            ParentSpanId = CurrentActivity.GetParentSpanId();

            CorrelationTraceContext.Current = this;
        }