-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Description
Description
A meter factory sets the scope of the meter it creates to itself:
runtime/src/libraries/Microsoft.Extensions.Diagnostics/src/Metrics/DefaultMeterFactory.cs
Lines 50 to 51 in ce689d9
| Meter m = new Meter(options.Name, options.Version, options.Tags, scope: this); | |
| meterList.Add(m); |
However, a scope can be provided on MeterOptions.Scope, which passed to Create.
Create should probably throw an error if a scope is specified. Otherwise there could be confusion about why the specified scope value wasn't used.
Reproduction Steps
object myCoolScope = new object();
IMeterFactory f = CreateFactory();
Meter meter = f.Create(new MeterOptions("Name") { Scope = myCoolScope });
Debug.Assert(meter.Scope == myCoolScope); // Fails?!?!Expected behavior
Throw an error.
Actual behavior
The scope provided by the user is ignored, and the meter scope is set to the factory.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
amiru3f