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

A Gauge is using the "last value aggregation", when using the async version, when the callback is called, we can provide a measurement value together with attributes.

Open mikewtf9999-hashPhuct opened this issue 2 months ago • 4 comments

A Gauge is using the "last value aggregation", when using the async version, when the callback is called, we can provide a measurement value together with attributes.

We use the attributes for different purposes:

  • to just add an attribute carrying meta data (say a certain key:pair value we add to a "temperature metric", temperature as in instant temperature)
  • to give the same metric for multiple instances of something, where those multiple instances are dynamic, they may come and go, the attribute is for example "Name":"Instance15".

What we noticed is the moment an attribute changes (or a attribute gets added), the old situation (with the old attribute value and old measurement, or without the new attributed) keeps being reported, so we end up with an ever increasing set of datapoints, where the old ones are to be considered obsolete and should just die.

In the dynamic case, we will always report all of the existing instances, the fact we no longer mention a given instance means it is gone, it has passed on, it died ;-)

How can this be achieved ?

Originally posted by @killerbot242 in https://github.com/open-telemetry/opentelemetry-cpp/discussions/3688

mikewtf9999-hashPhuct avatar Nov 09 '25 03:11 mikewtf9999-hashPhuct

All it done was lag my phone worse that before

mikewtf9999-hashPhuct avatar Nov 09 '25 03:11 mikewtf9999-hashPhuct

A Gauge is using the "last value aggregation", when using the async version, when the callback is called, we can provide a measurement value together with attributes.

We use the attributes for different purposes:

* to just add an attribute carrying meta data (say a certain key:pair value we add to a "temperature metric", temperature as in instant temperature)

* to give the same metric for multiple instances of something, where those multiple instances are dynamic, they may come and go, the attribute is for example "Name":"Instance15".

What we noticed is the moment an attribute changes (or a attribute gets added), the old situation (with the old attribute value and old measurement, or without the new attributed) keeps being reported, so we end up with an ever increasing set of datapoints, where the old ones are to be considered obsolete and should just die.

In the dynamic case, we will always report all of the existing instances, the fact we no longer mention a given instance means it is gone, it has passed on, it died ;-)

How can this be achieved ?

Originally posted by @killerbot242 in #3688 This is not really mine I was helping out for fun

mikewtf9999-hashPhuct avatar Nov 09 '25 03:11 mikewtf9999-hashPhuct

Hi all ,

I'm Prachi, exploring OpenTelemetry C++ metrics internals. I'd love to help address this issue—especially around cleaning up stale attribute sets in async Gauge callbacks. I’m considering a design that tracks active attributes per collection cycle and filters out obsolete ones.

Would it be okay to start prototyping a solution or collaborate on this?

Thanks!

prachi-kCoder avatar Nov 12 '25 18:11 prachi-kCoder

To investigate in more details.

marcalff avatar Dec 01 '25 21:12 marcalff