Skip to content

MetricEventSource value published events don't unambiguously resolve which Meter and Instrument tags they are refering to #93767

Closed
@noahfalk

Description

@noahfalk

Similar to #93097, ambiguity also occurs for meter scoped tags and instrument scoped tags. .NET allows creating new Meter and Instrument objects that differ from existing Meters/Instruments only by their tags. This isn't recommended usage and within the domain of OTel SDK specification it is an error for Meters to differ by tags only. However given that .NET API doesn't block it then we should be consistent and have MetricsEventSource should report it unambiguously. The simplest way to eliminate the ambiguity would be for value published events to include meter tags, instrument tags, and scope hash (#93097) in addition to the information that is currently reported.

Repro

var meterTags1 = new KeyValuePair<string,object?>[] { new KeyValuePair<string,object?>("m1","value1") };
var meterTags2 = new KeyValuePair<string,object?>[] { new KeyValuePair<string,object?>("m1","value2") };
var instrumentTags1 = new KeyValuePair<string,object?>[] { new KeyValuePair<string,object?>("i1","value1") };
var instrumentTags2 = new KeyValuePair<string,object?>[] { new KeyValuePair<string,object?>("i1","value2") };
Meter meter1 = new Meter("MyMeter", 1.0, meterTags1);
Meter meter2 = new Meter("MyMeter", 1.0, meterTags2);
Counter<int> m1c1 = meter1.CreateCounter<int>("MyCounter", null, null, instrumentTags1);
Counter<int> m1c2 = meter1.CreateCounter<int>("MyCounter", null, null, instrumentTags2);
Counter<int> m2c1 = meter2.CreateCounter<int>("MyCounter", null, null, instrumentTags1);
Counter<int> m2c2 = meter2.CreateCounter<int>("MyCounter", null, null, instrumentTags2);
m1c1.Add(1);
m1c2.Add(2);
m2c1.Add(3);
m2c2.Add(4);

Expected behavior

MetricsEventSource value publishing events can associate each reported value 1,2,3,4 with the correct Meter and Instrument tags

Actual behavior

MetricsEventSource value publishing events will report each value publishing event only including the names which will be the same each time, leaving it ambiguous which tags go with which measurement.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions