DefaultMeterFactory does not pass MeterOptions future properties to Meter constructor #97941
Labels
area-System.Diagnostics.Metric
in-pr
There is an active PR which will close this issue when it is merged
Milestone
Description
If more properties are added to System.Diagnostics.Metrics.MeterOptions in the future, then Microsoft.Extensions.Diagnostics.Metrics.DefaultMeterFactory should pass them too to the System.Diagnostics.Metrics.Meter constructor. However, the DefaultMeterFactory implementation in .NET 8.0.1 passes only those properties that it knows about: Name, Version, Tags, and a fixed Scope.
This was noted in #86740 (comment), and the implementation was then changed, but the change did not fix it. The code in .NET 8.0.1 is:
runtime/src/libraries/Microsoft.Extensions.Diagnostics/src/Metrics/DefaultMeterFactory.cs
Lines 55 to 58 in bf5e279
It changes and restores MeterOptions.Scope but does not pass the MeterOptions reference to the FactoryMeter constructor. Thus:
Reproduction Steps
Cannot be reproduced before more properties are added to MeterOptions.
Expected behavior
DefaultMeterFactory should pass through the MeterOptions reference all the way to Meter.
Actual behavior
DefaultMeterFactory passes through only the known properties of MeterOptions to Meter.
Regression?
Not a regression.
Known Workarounds
Register a custom IMeterFactory implementation in the dependency injection container.
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: