-
Notifications
You must be signed in to change notification settings - Fork 794
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
AspNetCore.HealthChecks.Publisher.ApplicationInsights - 3.0.2 doesn't handle missing telemetry key #380
Comments
@ianjirka, Microsoft now recommends relaying on Dependency injection to retrieve TelemetryConfiguration after TelemetryConfiguration.Active has been deprecated: microsoft/ApplicationInsights-dotnet#1152 By using: services.AddApplicationInsightsTelemetry(); This will automatically read your configuration from IConfiguration providers like appsettings or you can use the overload with a setup method to configure the Telemetry configuration. Docs: https://docs.microsoft.com/es-es/azure/azure-monitor/app/asp-net-core |
@CarlosLanderas - I agree, and this is what I currently do. I just do not set the telemetry key in the Development environment to avoid the number of things that need to be set up during development. In this issue I'm noting that the behavior changed in 3.0.2 such that this setup no longer works. From reading the linked issues I infer that was not intended but I didn't receive confirmation from the engineering team yet. |
#373 will fix it if it's accepted |
@joshlang, I am going to submit a new PR that will not have the throw exception, but we are going to relay on DI and not going to use TelemetryClient.CreateDefault static, as Microsoft good practice is using If you want to edit yours is ok for me. |
Nope, it's okay. I'm not particularly attached to my solution, and I'm happy to see yours get preference - the important thing is that it's fixed. You're also more familiar with the preferences & styles of this repo! Thanks!! |
In my startup code, I don't provide a telemetry key to AI if the environment is Development. So far this has worked fine.
With AspNetCore.HealthChecks.Publisher.ApplicationInsights v 3.0.2, I get the below exception. 3.0.1 does not have this behavior.
Can you confirm if this is a bug or if I need to change how I do startup to not configure AI health checks in this case?
Thanks much.
Error Message:
System.AggregateException : One or more errors occurred. (Value cannot be null. (Parameter 'No instrumentation key was provided in options or constructor'))
---- System.ArgumentNullException : Value cannot be null. (Parameter 'No instrumentation key was provided in options or constructor')
Stack Trace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait(TimeSpan timeout)
at test.WebServerUnitTests.ConfigureWebSite() in C:\rep\uhe.infra.patterns\test\UnitTests\WebsiteUnitTests.cs:line 73
----- Inner Stack Trace -----
at HealthChecks.Publisher.ApplicationInsights.ApplicationInsightsPublisher..ctor(IOptions`1 telemetryConfiguration, String instrumentationKey, Boolean saveDetailedReport, Boolean excludeHealthyReports)
The text was updated successfully, but these errors were encountered: