private static string GetInstrumentationKey(AppInsightsSettings settings) { var instrumentationKey = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY") ?? settings.InstrumentationKey; if (string.IsNullOrEmpty(instrumentationKey)) { throw new InvalidOperationException("App insights instrumentation key is not configured"); } return(instrumentationKey); }
private static void AddGenevaSink(IServiceCollection services, AppInsightsSettings settings) { var config = new TelemetryConfiguration { InstrumentationKey = GetInstrumentationKey(settings) }; TelemetryConfiguration genevaMdsdConfig = new TelemetryConfiguration(settings.Geneva.OneDSSinkChannel); TelemetrySink mdsdSink = new TelemetrySink(config, new GenevaAgentChannel()) { Name = settings.Geneva.OneDSSinkChannel }; mdsdSink.Initialize(genevaMdsdConfig); config.TelemetrySinks.Add(mdsdSink); config.TelemetryProcessorChainBuilder.Use(next => new GenevaMetricsProcessor(next) { MetricAccountName = settings.Geneva.GenevaMetricsAccountName, MetricNamespace = settings.Geneva.GenevaMetricsNamespace }); config.TelemetryProcessorChainBuilder.Build(); Console.WriteLine($"Added geneva metrics sink, account={settings.Geneva.GenevaMetricsAccountName}, namespace={settings.Geneva.GenevaMetricsNamespace}"); services.AddSingleton(config); }
public ContextTelemetryInitializer(IOptions <AppInsightsSettings> serviceContext) { settings = serviceContext.Value; }
public ContextTelemetryInitializer(AppInsightsSettings serviceContext) { _settings = serviceContext; }