Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Default TelemetryProcessors to be added on DefaultSink instead of on Common pipeline #752

Closed
cijothomas opened this issue Sep 7, 2018 · 0 comments
Assignees
Milestone

Comments

@cijothomas
Copy link
Contributor

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.

  1. First, retrieve TelemetryConfiguration from DI in Configure() method of Startup.cs
var tc = app.ApplicationServices.GetRequiredService<TelemetryConfiguration>(); 
  1. If meant for common pipeline, use its TelemetryProcessorChainBuilder to add TelemetryProcessors.
    eg:
tc.TelemetryProcessorChainBuilder.Use(next => new MyTelemetryProcessor(next))
  1. 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);                        
  1. 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) :

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant