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

ILogger provider does not use TelemetryConfiguration with OperationCorrelationTelemetryInitializer #1455

Closed
cijothomas opened this issue Aug 15, 2019 · 5 comments

Comments

@cijothomas
Copy link
Contributor

ApplicationInsightsLoggerProvider creates a new TelemetryConfiguration which do not contain any initializers. It should use TelemetryConfiguration.CreateDefault() so that OperationCorrelationTelemetryInitializer is added by default.
Without this, the logs from Ilogger will not get correlation with parent operations, if any. (Typically occurs if logs are made within a telemetryClient.StartOperation block)

@cijothomas cijothomas self-assigned this Aug 15, 2019
@cijothomas
Copy link
Contributor Author

cijothomas commented Aug 15, 2019

This will be applicable in non Asp.Net Core apps - like a Console app where this package is used standalone.

@saurabhrajguru
Copy link

We are facing this issue.
Is there any way to workaround this ?
I can file PR if someone can give me some pointers about this.

@cijothomas
Copy link
Contributor Author

@saurabhrajguru The workaround is to simply add the telemetry initializer manually. I have a full example in the below issue.
MicrosoftDocs/azure-docs#37176

At this point, its best if you do the workaround. Actual product fix needs some discussions and will not likely happen very soon.

@TimothyMothra TimothyMothra transferred this issue from microsoft/ApplicationInsights-dotnet-logging Dec 4, 2019
@cijothomas
Copy link
Contributor Author

The recommendation is to use WorkerService SDK or Asp.Net Core SDK based on application type. In both these cases, the reported issue will not occur.

It still occurs if one just uses LoggerProvider standalone - but in those cases, everything is manually collected like Requests etc, so OperationCOrrelationinitializer can be added manually as well.

Closing this issue as no longer relevant/important.

@supereddie
Copy link

The recommendation is to use WorkerService SDK or Asp.Net Core SDK based on application type. In both these cases, the reported issue will not occur.

It still occurs if one just uses LoggerProvider standalone - but in those cases, everything is manually collected like Requests etc, so OperationCOrrelationinitializer can be added manually as well.

Closing this issue as no longer relevant/important.

Hi @cijothomas,
Apologies for resurrecting such an old issue, however I've just ran into this one. We are unfortunately still using the old ASP.NET with .NET Framework 4.7 and converting it to a newer .NET version is going very slow.

Application Insights itself - with request and dependency collectors and stuff - is working properly, with the configuration loaded from applicationinsights.config.

We manually added DI which is working great, but not for ILogger / ApplicationInsightsLoggerProvider. More specifically: none of the ILogger.LogXXX0-methods generate telemetry which is properly correlated to the Operation. The telemetry itself gets send properly to AI, but it is just not correlated (of has any of the other telemetry initializers applied).

Manually adding the TelemetryInitializers (as defined in applicationinsights.config) to the IOptions-instance is working, but is very tedious and error-prone.

It would be very helpful if there was an easier way to load settings from the 'default' places - similar to what TelemetryConfiguration.Active does but on an existing instance. Perhaps an extension-method or something on TelemetryConfiguration - specifically for older .NET Framework applications? So I could do e.g.

services.AddOptions<TelemetryConfiguration>().Configure(c => c.LoadDefaults());
services.AddLogging(b => b.AddApplicationInsights());

We have a small number of ASP.NET sites still using .NET Framework 4.7/8 so it would be very helpful if there was something similar for easier diagnostics.

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

4 participants