Ejemplo n.º 1
0
        public ISpan StartManual()
        {
            LambdaTracer tracer     = LambdaTracer.Instance as LambdaTracer;
            ISpan        activeSpan = tracer.ActiveSpan;

            ISpanContext parentSpanContext = null;

            if (!_ignoreActiveSpan && _parent == null && activeSpan != null)
            {
                AddReference(References.ChildOf, activeSpan.Context);
                parentSpanContext = activeSpan.Context;
            }
            else if (_parent != null)
            {
                parentSpanContext = _parent;
            }

            LambdaSpan parentSpan = null;

            if (parentSpanContext is LambdaSpanContext)
            {
                parentSpan = ((LambdaSpanContext)parentSpanContext).GetSpan();
            }

            var        guid = GuidGenerator.GenerateNewRelicGuid();
            LambdaSpan newSpan;

            if (parentSpan != null)
            {
                newSpan = new LambdaSpan(_operationName, DateTimeOffset.UtcNow, _tags, parentSpan, guid);
            }
            else
            {
                var rootSpan = new LambdaRootSpan(_operationName, DateTimeOffset.UtcNow, _tags, guid, new DataCollector(_logger, tracer.DebugMode), new TransactionState(), new PrioritySamplingState(), new DistributedTracingState());

                if (parentSpanContext is LambdaPayloadContext payloadContext)
                {
                    rootSpan.ApplyLambdaPayloadContext(payloadContext);
                }
                else
                {
                    rootSpan.ApplyAdaptiveSampling(tracer.AdaptiveSampler);
                }

                newSpan = rootSpan;
            }

            LambdaSpanContext spanContext = new LambdaSpanContext(newSpan);

            newSpan.SetContext(spanContext);

            return(newSpan);
        }
Ejemplo n.º 2
0
 public void SetContext(LambdaSpanContext context)
 {
     _context = context;
 }