Exemplo n.º 1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, DiagnosticListener diagnosticListener)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler(ExceptionHandler.Default);  // handle exception
            }

            diagnosticListener.AddToolkitDiagnositcs();  // 添加诊断

            env.ConfigureNLog("nlog.config");
            loggerFactory.AddDefaultNLog(options =>
            {
                options.HasRequestHeaders  = true;
                options.HasResponseHeaders = true;
            });
            //添加调用链监控(APM)
            app.AddZipKin(loggerFactory, Configuration["ZipKin:ApplicationId"], Configuration["ZipKin:ZipKinServer"]);
            // 保证在 Mvc 之前调用
            app.UseHttpContextGlobal()
            .UseToolTrace();

            app.UseMvc();

            // add service discovery
            //app.UseDiscoveryClient();
        }