opentelemetry-rust icon indicating copy to clipboard operation
opentelemetry-rust copied to clipboard

UniqueInstrumentMeterCore silently drops observers with the same name and type

Open tustvold opened this issue 4 years ago • 2 comments

The implementation of UniqueInstrumentMeterCore::new_async_instrument and UniqueInstrumentMeterCore::new_sync_instrument returns the existing instrument if one exists.

This causes issues for value observers where the instruments are not interchangeable as they have different callbacks. I'm not sure what the correct behaviour here is, the go implementation looks to do something similar, but I can't help feeling silently dropping metrics is perhaps not ideal?

tustvold avatar May 07 '21 14:05 tustvold

Yeah this is a rougher area still, was discussed in https://github.com/open-telemetry/opentelemetry-specification/issues/1046 with less clear resolution as I recall. Could be worth considering alternatives here.

jtescher avatar May 07 '21 18:05 jtescher

Thank you for that context, very helpful :+1:

From my perspective, the issue at the moment is that there is no way to detect a collision, and even if you could the returned ValueObserver provides no ability to do anything about it. Perhaps if the API only took a descriptor and then returned a ValueObserver that you could then register one or more callbacks with? I don't know, I'm not sure I completely understand the motivation for making async instrument unique in the first place...

Basically, if there was some way I could get rid of this hack, it would make me very happy :smile: - https://github.com/influxdata/influxdb_iox/pull/1457

tustvold avatar May 08 '21 10:05 tustvold

This now logs in the new metrics, released in #1156

jtescher avatar Jul 30 '23 17:07 jtescher