-
Notifications
You must be signed in to change notification settings - Fork 283
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
Comments
This will be applicable in non Asp.Net Core apps - like a Console app where this package is used standalone. |
We are facing this issue. |
@saurabhrajguru The workaround is to simply add the telemetry initializer manually. I have a full example in the below issue. At this point, its best if you do the workaround. Actual product fix needs some discussions and will not likely happen very soon. |
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, 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 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. |
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)
The text was updated successfully, but these errors were encountered: