Exemplo n.º 1
0
        private static ApplicationInsightsConfiguration InitializeApplicationInsights(RefreshableConfiguration configuration)
        {
            var instrumentationKey       = configuration.Root.GetValue <string>("ApplicationInsights_InstrumentationKey");
            var heartbeatIntervalSeconds = configuration.Root.GetValue("ApplicationInsights_HeartbeatIntervalSeconds", 60);

            var applicationInsightsConfiguration = ApplicationInsights.Initialize(
                instrumentationKey,
                TimeSpan.FromSeconds(heartbeatIntervalSeconds));

            applicationInsightsConfiguration.TelemetryConfiguration.TelemetryInitializers.Add(new AzureWebAppTelemetryInitializer());
            applicationInsightsConfiguration.TelemetryConfiguration.TelemetryInitializers.Add(new KnownOperationNameEnricher(new[]
            {
                GetOperationName <SearchController>(HttpMethod.Get, nameof(SearchController.AutocompleteAsync)),
                GetOperationName <SearchController>(HttpMethod.Get, nameof(SearchController.IndexAsync)),
                GetOperationName <SearchController>(HttpMethod.Get, nameof(SearchController.GetStatusAsync)),
                GetOperationName <SearchController>(HttpMethod.Get, nameof(SearchController.V2SearchAsync)),
                GetOperationName <SearchController>(HttpMethod.Get, nameof(SearchController.V3SearchAsync)),
            }));

            applicationInsightsConfiguration.TelemetryConfiguration.TelemetryProcessorChainBuilder.Use(next =>
            {
                var processor = new RequestTelemetryProcessor(next);

                processor.SuccessfulResponseCodes.Add(400);
                processor.SuccessfulResponseCodes.Add(403);
                processor.SuccessfulResponseCodes.Add(404);
                processor.SuccessfulResponseCodes.Add(405);

                return(processor);
            });

            RegisterApplicationInsightsTelemetryModules(applicationInsightsConfiguration.TelemetryConfiguration);

            return(applicationInsightsConfiguration);
        }
Exemplo n.º 2
0
        private static ApplicationInsightsConfiguration InitializeApplicationInsights(RefreshableConfiguration configuration)
        {
            var instrumentationKey       = configuration.Root.GetValue <string>("ApplicationInsights_InstrumentationKey");
            var heartbeatIntervalSeconds = configuration.Root.GetValue("ApplicationInsights_HeartbeatIntervalSeconds", 60);

            var applicationInsightsConfiguration = ApplicationInsights.Initialize(
                instrumentationKey,
                TimeSpan.FromSeconds(heartbeatIntervalSeconds));

            applicationInsightsConfiguration.TelemetryConfiguration.TelemetryInitializers.Add(new AzureWebAppTelemetryInitializer());

            RegisterApplicationInsightsTelemetryModules(applicationInsightsConfiguration.TelemetryConfiguration);

            return(applicationInsightsConfiguration);
        }