Exemple #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler();
            }



            var aiconfiguration = app.ApplicationServices
                                  .GetService <Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration>();

            var config = new ApplicationInsightConfig()
            {
                RoleName           = Configuration["ApplicationInsights:ApplicationName"],
                DisableContext     = bool.Parse(Configuration["ApplicationInsights:DisableInstrumentation"]),
                InstrumentationKey = Environment.GetEnvironmentVariable("AiInstrumentationKey")
            };

            aiconfiguration.DisableTelemetry = bool.Parse(Configuration["ApplicationInsights:DisableInstrumentation"]);
            aiconfiguration.TelemetryInitializers.Add(new AiTelemetryInitializer(config));
            app.UseMiddleware <ApplicationInsightsMiddleware>();
            app.UseAuthentication();
            app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()
                        );
            app.UseMvc();

            app.UseSwaggerUi(typeof(Startup).GetTypeInfo().Assembly, settings =>
            {
                settings.GeneratorSettings.DefaultPropertyNameHandling =
                    PropertyNameHandling.CamelCase;
            });
        }
Exemple #2
0
 public AiTelemetryInitializer(ApplicationInsightConfig config)
 {
     _config = config;
 }