Hosting: Support metrics registration via IServiceCollection & deferred configuration#2412
Conversation
Co-authored-by: Reiley Yang <reyang@microsoft.com>
| if (services is null) | ||
| { | ||
| throw new ArgumentNullException(nameof(services)); | ||
| } |
There was a problem hiding this comment.
nit: Maybe it would be better to add this null guard to public methods?
There was a problem hiding this comment.
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
AddOpenTelemetryMetricsextensions onIServiceCollectionAddMetricReader->AddReader. This seemed more consistent with the other methods (AddProcessor,SetSampler,AddInstrumentation, etc.)IDeferredMeterProviderBuilderto support DI scenariosDetails
Follows closely the same patterns used for
TracerProviderBuilder+ extensions.TODOs
CHANGELOG.mdupdated for non-trivial changes