TelemetryConfiguration has a common TelemetryProcessor pipeline, which is common for all the sinks configured. i.e this pipeline is invoked first, before broadcasting/passthrough to the sinks.
When enabling Application Insights via UseApplicationInisghts() or AddApplicationInsightsTelemetry() extension methods, all the default TelemetryProcessors (like Sampling, LiveMetrics, MetricAggregator) are currently added to the common pipeline. This means that, for those users configuring additional sinks, their sinks get telemetry after already going through the common pipeline.
Proposal here is to move all the default TelemetryProcessors added automatically by AI into the pipeline of the 'default' sink.
For users who do not configure additional sink, this has no effect.
For users who use additional sink(s), this means that their sinks get the telemetry items without being touched by any of the default TelemetryProcessors.
While adding new TelemetryProcesor to the pipeline, users can do it in two different ways, dependending on whether they want it in common pipeline or on a particular sink.
- First, retrieve
TelemetryConfiguration from DI in Configure() method of Startup.cs
var tc = app.ApplicationServices.GetRequiredService<TelemetryConfiguration>();
- If meant for common pipeline, use its
TelemetryProcessorChainBuilder to add TelemetryProcessors.
eg:
tc.TelemetryProcessorChainBuilder.Use(next => new MyTelemetryProcessor(next))
- If meant for a particular sink only, use the
TelemetryProcessorChainBuilder on that sink.
eg: for adding TP to default sink.
tc.DefaultTelemetrySink.TelemetryProcessorChainBuilder.Use(next => new MyTelemetryProcessor(next))
eg: for adding TP to any custom sink.
TelemetrySink sink1 = new TelemetrySink(tc, new ServerTelemetryChannel()) { Name = "Sink1" };
sink1.TelemetryProcessorChainBuilder.Use(next => new MyTelemetryProcessor(next));
sink1.Initialize(tc);
tc.TelemetrySinks.Add(sink1);
- Re build the main pipeline
tc.TelemetryProcessorChainBuilder.Build();
If TelemetryProcessors were addded to the default sink or any custom sink, then that sink need to be rebuilt as well using sink.TelemetryProcessorChainBuilder.Build().
Also proposing to modify AddApplicationInsightsTelemetryProcessor(), so that it also adds the TelemetryProcessors to the default sink as all other default processors.
Version Info
SDK Version :
.NET Version :
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) :
OS :
Hosting Info (IIS/Azure WebApps/ etc) :
TelemetryConfiguration has a common TelemetryProcessor pipeline, which is common for all the sinks configured. i.e this pipeline is invoked first, before broadcasting/passthrough to the sinks.
When enabling Application Insights via
UseApplicationInisghts()orAddApplicationInsightsTelemetry()extension methods, all the default TelemetryProcessors (like Sampling, LiveMetrics, MetricAggregator) are currently added to the common pipeline. This means that, for those users configuring additional sinks, their sinks get telemetry after already going through the common pipeline.Proposal here is to move all the default TelemetryProcessors added automatically by AI into the pipeline of the 'default' sink.
For users who do not configure additional sink, this has no effect.
For users who use additional sink(s), this means that their sinks get the telemetry items without being touched by any of the default TelemetryProcessors.
While adding new
TelemetryProcesorto the pipeline, users can do it in two different ways, dependending on whether they want it in common pipeline or on a particular sink.TelemetryConfigurationfrom DI inConfigure()method ofStartup.csTelemetryProcessorChainBuilderto add TelemetryProcessors.eg:
TelemetryProcessorChainBuilderon that sink.eg: for adding TP to default sink.
tc.DefaultTelemetrySink.TelemetryProcessorChainBuilder.Use(next => new MyTelemetryProcessor(next))
eg: for adding TP to any custom sink.
If TelemetryProcessors were addded to the default sink or any custom sink, then that sink need to be rebuilt as well using
sink.TelemetryProcessorChainBuilder.Build().Also proposing to modify
AddApplicationInsightsTelemetryProcessor(), so that it also adds the TelemetryProcessors to the default sink as all other default processors.Version Info
SDK Version :
.NET Version :
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) :
OS :
Hosting Info (IIS/Azure WebApps/ etc) :