예제 #1
0
        public void Init(HttpApplication context)
        {
            context.BeginRequest += (sender, args) =>
            {
                string url = HttpContext.Current.Request.Path;

                var zipkinConfig = new ZipkinConfig();

                var traceProvider = new TraceProvider(new System.Web.HttpContextWrapper(HttpContext.Current), zipkinConfig.DontSampleListCsv, zipkinConfig.ZipkinSampleRate);
                var logger        = new MDLogger(LogManager.GetLogger(this.GetType()), traceProvider, new AssemblyInformation());

                ITracerClient zipkinClient = new ZipkinClient(traceProvider, url, logger);

                zipkinClient.StartServerTrace();

                HttpContext.Current.Items["zipkinClient"] = zipkinClient;

                var stopwatch = new Stopwatch();
                HttpContext.Current.Items["zipkinStopwatch"] = stopwatch;
                stopwatch.Start();
            };

            context.EndRequest += (sender, args) =>
            {
                var stopwatch = (Stopwatch)HttpContext.Current.Items["zipkinStopwatch"];
                stopwatch.Stop();

                var zipkinClient = (ITracerClient)HttpContext.Current.Items["zipkinClient"];

                zipkinClient.EndServerTrace(stopwatch.Elapsed.Milliseconds * 1000);
            };
        }
        public void Init(HttpApplication context)
        {
            context.BeginRequest += (sender, args) =>
                {
                    string url = HttpContext.Current.Request.Path;

                    var zipkinConfig = new ZipkinConfig();

                    var traceProvider = new TraceProvider(new System.Web.HttpContextWrapper(HttpContext.Current), zipkinConfig.DontSampleListCsv, zipkinConfig.ZipkinSampleRate);
                    var logger = new MDLogger(LogManager.GetLogger(this.GetType()), traceProvider, new AssemblyInformation());

                    ITracerClient zipkinClient = new ZipkinClient(traceProvider, url, logger);

                    zipkinClient.StartServerTrace();

                    HttpContext.Current.Items["zipkinClient"] = zipkinClient;

                    var stopwatch = new Stopwatch();
                    HttpContext.Current.Items["zipkinStopwatch"] = stopwatch;
                    stopwatch.Start();
                };

            context.EndRequest += (sender, args) =>
                {
                    var stopwatch = (Stopwatch)HttpContext.Current.Items["zipkinStopwatch"];
                    stopwatch.Stop();

                    var zipkinClient = (ITracerClient)HttpContext.Current.Items["zipkinClient"];

                    zipkinClient.EndServerTrace(stopwatch.Elapsed.Milliseconds * 1000);
                };
        }