public async Task <IActionResult> AllTags()
        {
            // var handler = new TraceHeaderPropagatingHandler();
            var headers       = HttpContext.Request.Headers;
            var spanIdBefore  = _managedTracer.GetCurrentSpanId();
            var traceIdBefore = _managedTracer.GetCurrentTraceId();

            _logger.LogInformation(
                "headers: {@HeadersBefore}, spanIdBefore: {@SpanIdBefore}, traceIdBefore: {@TraceIdBefore}",
                headers, spanIdBefore, traceIdBefore);
            // var span = _managedTracer.StartSpan(nameof(AllTags))
            using (var span = _managedTracer.StartSpan(nameof(AllTags)))
            {
                var headersAfter = HttpContext.Request.Headers;
                var spanIdAfter  = _managedTracer.GetCurrentSpanId();
                var traceIdAfter = _managedTracer.GetCurrentTraceId();

                _logger.LogInformation(
                    "span: {@Span}, headersAfter: {@HeadersAfter}, spanIdAfter: {@SpanIdAfter}, traceIdAfter: {@TraceIdAfter}",
                    span, headersAfter, spanIdAfter, traceIdAfter);
                // var traceHeaderHandler = new TraceHeaderPropagatingHandler(() => _managedTracer);
                var result = await _tagBL.GetAllTags();

                return(Ok(result));
            }
        }
        /// <summary>
        /// Sends the given request.  If tracing is initialized and enabled the outgoing request is
        /// traced and the trace header is added to the request.
        /// </summary>
        protected override async Task <HttpResponseMessage> SendAsync(
            HttpRequestMessage request, CancellationToken cancellationToken)
        {
            if (_tracer.GetCurrentTraceId() == null)
            {
                return(await base.SendAsync(request, cancellationToken).ConfigureAwait(false));
            }

            var traceHeader = TraceHeaderContext.Create(
                _tracer.GetCurrentTraceId(), _tracer.GetCurrentSpanId() ?? 0, true);

            request.Headers.Add(TraceHeaderContext.TraceHeader, traceHeader.ToString());

            _tracer.StartSpan(request.RequestUri.ToString());
            try
            {
                return(await base.SendAsync(request, cancellationToken).ConfigureAwait(false));
            }
            catch (Exception e)
            {
                StackTrace stackTrace = new StackTrace(e, true);
                _tracer.SetStackTrace(stackTrace);
                throw;
            }
            finally
            {
                _tracer.EndSpan();
            }
        }
        public void CreateTracer_SimpleManagedTracer()
        {
            IManagedTracer tracer = s_tracerFactoryNoLimit.CreateTracer(s_headerTrue);

            Assert.IsType(typeof(SimpleManagedTracer), tracer);
            Assert.Equal(tracer.GetCurrentTraceId(), TraceId);
            Assert.Equal(tracer.GetCurrentSpanId(), SpanId);
        }