Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tracked by #97522
noahfalk opened this issue Oct 20, 2023 · 1 comment

Comments

@noahfalk
Copy link
Member

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.

@CodeBlanch
Copy link
Contributor

I dropped a comment over here: #102678 (comment)

Just wondering if we could have events on the sources (metrics and tracing) for Meter\ActivitySource published. What I would like to do is be able to listen to those, capture all the static data into a dictionary, and then when individual measurements happen or activities start/stop I could look up the data. That way we don't need to mirror everything for all the individual events. Key could be a hash or just some id/count that is auto-assigned to Meter/ActivitySource and present on the events 🤷

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants