-
Notifications
You must be signed in to change notification settings - Fork 861
Open
Description
One of the cases I want the App Insights health check to cover is if my configuration is missing.
This is not possible, because if I pass an empty string or null to the AddAzureApplicationInsights() method, the health check will later throw an exception.
It would be better if it simply returned the configured failureStatus. This is what I've seen other health checks do (for example Azure App Configuration)
For reference, here's the stacktrace from when I access my API's /healthz endpoint:
System.ArgumentNullException: Value cannot be null. (Parameter 'instrumentationKey')
at Guard.ThrowIfNull[T](T argument, Boolean throwOnEmptyString, String paramName) in /home/runner/work/AspNetCore.Diagnostics.HealthChecks/AspNetCore.Diagnostics.HealthChecks/src/CallerArgumentExpressionAttribute.cs:line 49
at HealthChecks.AzureApplicationInsights.AzureApplicationInsightsHealthCheck..ctor(String instrumentationKey, IHttpClientFactory httpClientFactory) in /home/runner/work/AspNetCore.Diagnostics.HealthChecks/AspNetCore.Diagnostics.HealthChecks/src/HealthChecks.AzureApplicationInsights/AzureApplicationInsightsHealthCheck.cs:line 21
at Microsoft.Extensions.DependencyInjection.AzureApplicationInsightsHealthCheckBuilderExtensions.<>c__DisplayClass1_0.<AddAzureApplicationInsights>b__0(IServiceProvider sp) in /home/runner/work/AspNetCore.Diagnostics.HealthChecks/AspNetCore.Diagnostics.HealthChecks/src/HealthChecks.AzureApplicationInsights/DependencyInjection/AzureApplicationInsightsHealthCheckBuilderExtensions.cs:line 39
at Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService.RunCheckAsync(HealthCheckRegistration registration, CancellationToken cancellationToken)
at Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService.RunCheckAsync(HealthCheckRegistration registration, CancellationToken cancellationToken)
at Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService.CheckHealthAsync(Func`2 predicate, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Diagnostics.HealthChecks.HealthCheckMiddleware.InvokeAsync(HttpContext httpContext)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels