Example #1
0
        private void BeginRequest(object sender, EventArgs e)
        {
            var    request       = HttpContext.Current.Request;
            string header        = request.Headers.Get(TraceHeaderContext.TraceHeader);
            var    headerContext = TraceHeaderContext.FromHeader(
                header, () => _traceFallbackPredicate?.Invoke(request));

            var tracer = _tracerFactory.CreateTracer(headerContext);

            if (tracer.GetCurrentTraceId() == null)
            {
                return;
            }

            TracerManager.SetCurrentTracer(tracer);

            // Start the span and annotate it with information from the current request.
            tracer.StartSpan(HttpContext.Current.Request.Path);
            tracer.AnnotateSpan(Labels.FromHttpRequest(HttpContext.Current.Request));
            tracer.AnnotateSpan(Labels.AgentLabel);
        }