Exemple #1
0
 public static void NotifyFinish(ITracerContext tracerContext)
 {
     foreach (var listener in _listeners)
     {
         listener.AfterFinish(tracerContext);
     }
 }
        public void ApplicationOnEndRequest(object sender, EventArgs e)
        {
            var            httpApplication = sender as HttpApplication;
            var            httpContext     = httpApplication.Context;
            ITracerContext context         = null;

            if (httpContext.Request.HttpMethod == "OPTIONS")
            {
                //asp.net Exclude OPTIONS request
                return;
            }

            var httpRequestSpan = ContextManager.ActiveSpan;

            if (httpRequestSpan == null)
            {
                // ContextManager.ActiveSpan is null, from httpContext.Items
                if (!httpContext.Items.Contains("span_Context"))
                {
                    return;
                }

                context = httpContext.Items["span_Context"] as ITracerContext;
                if (context == null)
                {
                    return;
                }

                httpRequestSpan = context.ActiveSpan;
                if (httpRequestSpan == null)
                {
                    return;
                }
            }

            var statusCode = httpContext.Response.StatusCode;

            if (statusCode >= 400)
            {
                httpRequestSpan.ErrorOccurred();
            }

            Tags.StatusCode.Set(httpRequestSpan, statusCode.ToString());

            var exception = httpContext.Error;

            if (exception != null)
            {
                httpRequestSpan.ErrorOccurred().Log(exception);
            }

            httpRequestSpan.Log(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
                                new Dictionary <string, object>
            {
                { "event", "AspNet EndRequest" },
                { "message", $"Request finished {httpContext.Response.StatusCode} {httpContext.Response.ContentType}" }
            });

            ContextManager.StopSpan(httpRequestSpan, context);
        }
Exemple #3
0
 public static void StopSpan(ISpan span, ITracerContext context = null)
 {
     if (Context != null)
     {
         Context.StopSpan(span);
     }
     else if (context != null)
     {
         context.StopSpan(span);
     }
 }
Exemple #4
0
 public void AfterFinish(ITracerContext tracerContext)
 {
     _context.Value = null;
 }
 public void AfterFinish(ITracerContext tracerContext)
 {
     Counter = Counter + 1;
 }