public ITelemetryProcessor Create(ITelemetryProcessor next) { SnapshotCollectorConfiguration configuration = new SnapshotCollectorConfiguration() { //IsEnabled = false, //IsEnabledInDeveloperMode = true, //ProblemCounterResetInterval = TimeSpan.FromMinutes(60), //ThresholdForSnapshotting = 1, // How many times we need to see an exception before we ask for snapshots. Default is 5. The value cannot be less than 1. MaximumSnapshotsRequired = 900, //The maximum number of snapshots we collect for a single problem. Default is 3. The value must be between 1 and 999. //SnapshotsPerTenMinutesLimit = 100, // Momoey throttling is not working since zipping is introduced. //AgentEndpoint = "https://ppe-test.azureserviceprofiler.net", SnapshotsPerDayLimit = 0 // The maximum number of snapshots allowed in one day (24 hours). Default is 50. 0 means not limit. The limit must not be negative. }; //SnapshotCollectorConfiguration configuration = new SnapshotCollectorConfiguration(); return(new SnapshotCollectorTelemetryProcessor(next, configuration)); }
public void DepednencyInjectionConfiguration_ConfiguresSnapshotCollector() { var snapshotConfiguration = new SnapshotCollectorConfiguration(); using (var host = new HostBuilder() .ConfigureLogging(b => { b.AddApplicationInsights(o => { o.InstrumentationKey = "some key"; o.SnapshotConfiguration = snapshotConfiguration; }); }).Build()) { var config = host.Services.GetService <TelemetryConfiguration>(); Assert.Equal(4, config.TelemetryProcessors.Count); Assert.IsType <QuickPulseTelemetryProcessor>(config.TelemetryProcessors[0]); Assert.IsType <FilteringTelemetryProcessor>(config.TelemetryProcessors[1]); Assert.IsType <SnapshotCollectorTelemetryProcessor>(config.TelemetryProcessors[2]); } }
private static void SetupTelemetryConfiguration( TelemetryConfiguration configuration, string instrumentationKey, SamplingPercentageEstimatorSettings samplingSettings, SnapshotCollectorConfiguration snapshotCollectorConfiguration, ITelemetryChannel channel, IEnumerable <ITelemetryInitializer> telemetryInitializers, IEnumerable <ITelemetryModule> telemetryModules, IApplicationIdProvider applicationIdProvider, LoggerFilterOptions filterOptions) { if (instrumentationKey != null) { configuration.InstrumentationKey = instrumentationKey; // Because of https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/943 // we have to touch (and create) Active configuration before initializing telemetry modules TelemetryConfiguration.Active.InstrumentationKey = instrumentationKey; } configuration.TelemetryChannel = channel; foreach (ITelemetryInitializer initializer in telemetryInitializers) { configuration.TelemetryInitializers.Add(initializer); } (channel as ServerTelemetryChannel)?.Initialize(configuration); QuickPulseTelemetryModule quickPulseModule = null; foreach (ITelemetryModule module in telemetryModules) { if (module is QuickPulseTelemetryModule telemetryModule) { quickPulseModule = telemetryModule; } module.Initialize(configuration); } QuickPulseTelemetryProcessor quickPulseProcessor = null; configuration.TelemetryProcessorChainBuilder .Use((next) => { quickPulseProcessor = new QuickPulseTelemetryProcessor(next); return(quickPulseProcessor); }) .Use((next) => new FilteringTelemetryProcessor(filterOptions, next)); if (samplingSettings != null) { configuration.TelemetryProcessorChainBuilder.Use((next) => new AdaptiveSamplingTelemetryProcessor(samplingSettings, null, next)); } if (snapshotCollectorConfiguration != null) { configuration.TelemetryProcessorChainBuilder.UseSnapshotCollector(snapshotCollectorConfiguration); } configuration.TelemetryProcessorChainBuilder.Build(); quickPulseModule?.RegisterTelemetryProcessor(quickPulseProcessor); foreach (ITelemetryProcessor processor in configuration.TelemetryProcessors) { if (processor is ITelemetryModule module) { module.Initialize(configuration); } } configuration.ApplicationIdProvider = applicationIdProvider; }