Skip to content

DefaultMeterFactory.Create and MeterOptions.Scope #86684

Closed
@JamesNK

Description

@JamesNK

Description

A meter factory sets the scope of the meter it creates to itself:

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions