-
Notifications
You must be signed in to change notification settings - Fork 773
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
[Hosting] Throw startup exceptions #4006
[Hosting] Throw startup exceptions #4006
Conversation
src/OpenTelemetry.Extensions.Hosting/Implementation/HostingExtensionsEventSource.cs
Outdated
Show resolved
Hide resolved
[NonEvent] | ||
public void FailedInitialize(Exception ex) | ||
[Event(1, Message = "OpenTelemetry TraverProvider and/or MeterProvider were not found in application services. SDK will remain disabled.", Level = EventLevel.Warning)] | ||
public void SdkNotRegistered() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have dedicated events for TracerProvider and MeterProvider instead of using the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #4006 +/- ##
==========================================
+ Coverage 85.46% 85.48% +0.01%
==========================================
Files 289 289
Lines 11237 11229 -8
==========================================
- Hits 9604 9599 -5
+ Misses 1633 1630 -3
|
} | ||
// The sole purpose of this HostedService is to ensure all | ||
// instrumentations, exporters, etc., are created and started. | ||
Initialize(this.serviceProvider); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add a comment saying intentionally not catching ex, to let it bubble up.
Relates to #3753
Changes
IHostedService
used byOpenTelemetry.Extensions.Hosting
will now throw if it blows up startingTracerProvider
orMeterProvider
.Details
If you do this today using the "Sdk.Create" style you will get a
NotSupportedException
:If you do this today using the hosting style an internal log is written but otherwise nothing happens:
The goal of the change is to make the behavior consistent and notify users when they have made a mistake.
The above example is a dev issue but other kinds of problems will also now blow up the process. Bad configuration, invalid permissions, port issues, etc. Discussing with @alanwest we felt it was better to surface these types of issues immediately and prevent the process from starting.
TODOs
CHANGELOG.md
updated for non-trivial changes