Ejemplo n.º 1
0
        /// <summary>
        /// Create a local span
        /// </summary>
        public ISpan CreateLocalSpan(string operationName)
        {
            if (!EnsureLimitMechanismWorking(out var noopSpan))
            {
                return(noopSpan);
            }

            _activeSpanStacks.TryPeek(out var parentSpan);

            var parentSpanId = parentSpan?.SpanId ?? -1;

            var span = new LocalSpan(_spanIdGenerator++, parentSpanId, operationName);

            span.Start();
            _activeSpanStacks.Push(span);
            return(span);
        }
        /// <summary>
        /// Create a local span
        /// </summary>
        public ISpan CreateLocalSpan(string operationName, string activityId, string parentId)
        {
            if (!EnsureLimitMechanismWorking(activityId, out var noopSpan))
            {
                return(noopSpan);
            }

            var parentSpanId = -1;

            if (!string.IsNullOrWhiteSpace(parentId))
            {
                _activeSpanDic.TryGetValue(parentId, out var parentSpan);
                parentSpanId = parentSpan?.SpanId ?? -1;
            }

            var span = new LocalSpan(_spanIdGenerator++, parentSpanId, operationName);

            span.Start();
            TryAddSpan(activityId, span);

            return(span);
        }