Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new (hidden) method on TelemetryClient to initialize instrumentation key. #966

Closed
cijothomas opened this issue Oct 30, 2018 · 0 comments
Assignees
Milestone

Comments

@cijothomas
Copy link
Contributor

TelemetryClient has Initialize() (https://github.com/Microsoft/ApplicationInsights-dotnet/blob/develop/src/Microsoft.ApplicationInsights/TelemetryClient.cs#L456) method, which is used by AutoCollection TelemetryModules (https://github.com/Microsoft/ApplicationInsights-dotnet/blob/develop/src/Microsoft.ApplicationInsights/TelemetryClient.cs#L456) to populate the instrumentation key from TelemetryClient.
This method causes all TelemetryInitializers to run. Apart from this, when Track() is eventually called, all TelemetryInitializers are run again.

While most TelemetryInitializers are written in such a way that it detects 'no action needed, exit quickly' - but there are exceptions.
An example is SyntheticUserAgentTelemetryInitializer, which, if called multiple times, will do all the compute-intensive task of checking useragent to the list of potential 'bot' strings.
https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/develop/Src/Web/Web.Shared.Net/SyntheticUserAgentTelemetryInitializer.cs#L50

(there are others similar to this in AI default list itself, but potentially many more written by others)

Proposal is to add a new method (but hidden) in TelemetryClient called InitializeInstrumentationKey(ITelemetry telemetry), which can used by auto collection modules to populate instrumentation key. Once all auto collectors move to this method, the customer confusions about TelemetryInitializers being called multiple times is going to be mitigated. (along with the perf improvement!)

@cijothomas cijothomas added this to the 2.9-beta1 milestone Oct 30, 2018
@cijothomas cijothomas self-assigned this Oct 30, 2018
TimothyMothra pushed a commit that referenced this issue Oct 25, 2019
Asp.Net Core 3.0 Functional Tests Added. This leverages the built-in integration test capability of ASP.NET Core via Microsoft.AspNetCore.MVC.Testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant