-
Notifications
You must be signed in to change notification settings - Fork 790
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: Support metrics registration via IServiceCollection & deferred configuration #2412
Conversation
src/OpenTelemetry.Extensions.Hosting/Implementation/MeterProviderBuilderHosting.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Extensions.Hosting/Implementation/TelemetryHostedService.cs
Show resolved
Hide resolved
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.
LGTM.
Co-authored-by: Reiley Yang <[email protected]>
src/OpenTelemetry.Extensions.Hosting/Implementation/MeterProviderBuilderHosting.cs
Show resolved
Hide resolved
if (services is null) | ||
{ | ||
throw new ArgumentNullException(nameof(services)); | ||
} |
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: Maybe it would be better to add this null guard to public methods?
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.
I'm going to vote to leave as-is on this one. Reasoning: services
is the thing being extended. It is unlikely to be null
unless someone is going out of their way to call it directly AND pass null
. So given that should be rare, having it here saves having to duplicate the check in all the publics. 2 checks instead of 4, basically.
Codecov Report
@@ Coverage Diff @@
## main #2412 +/- ##
==========================================
- Coverage 80.27% 80.23% -0.05%
==========================================
Files 232 235 +3
Lines 7505 7564 +59
==========================================
+ Hits 6025 6069 +44
- Misses 1480 1495 +15
|
@CodeBlanch |
Changes
AddOpenTelemetryMetrics
extensions onIServiceCollection
AddMetricReader
->AddReader
. This seemed more consistent with the other methods (AddProcessor
,SetSampler
,AddInstrumentation
, etc.)IDeferredMeterProviderBuilder
to support DI scenariosDetails
Follows closely the same patterns used for
TracerProviderBuilder
+ extensions.TODOs
CHANGELOG.md
updated for non-trivial changes