[BUG]: Crashes when the connection string is missing #47638
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
Monitor - Distro
Monitor OpenTelemetry Distro
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Service Attention
Workflow: This issue is responsible by Azure service team.
Library name and version
Azure.Monitor.OpenTelemetry.AspNetCore v1.2.0
Describe the bug
I just migrated from the old AppInsights library to Azure.Monitor.OpenTelemetry.AspNetCore and I this gotcha caught me off guard and I had to spend 30 minutes trying to find why.
So, apparently, if the App Insight connection string is not present, then it will just DIE at startup with.
System.InvalidOperationException: A connection string was not found. Please set your connection string.
In my opinion, logging libraries should not prevent my application from crashing.
I also find it useful to have the library in the code, but when the connection string is not present, the library is just disabled.
https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/AzureMonitorTransmitter.cs#L77
I just think this is bad, and will trip soo many developers and many developer hours will be spent trying to figure out why.
I think a kinder approach is to not terminate the application and instead , log a friendly message that the connection string is missing and the Azure.Monitor.OpenTelemetry.AspNetCore is disabled.
just ventilating my frustration.
Expected behavior
Logging libraries should no terminate my applications.
Actual behavior
2024-12-22T17:00:19.498890235Z System.InvalidOperationException: A connection string was not found. Please set your connection string.
Reproduction Steps
don't provide any connection string.
Environment
Azure, ASP.NET Core 9
The text was updated successfully, but these errors were encountered: