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

Allow UpDown counters to be 'set' #2054

Open
RichardWright opened this issue Oct 24, 2021 · 2 comments
Open

Allow UpDown counters to be 'set' #2054

RichardWright opened this issue Oct 24, 2021 · 2 comments
Assignees
Labels
release:after-ga Not required before GA release, and not going to work on before GA spec:metrics Related to the specification/metrics directory

Comments

@RichardWright
Copy link

Current spec for UpDownCounters

.inc(5)
.inc(-5)

If the state is based on, for example, the length of an array (eg a list of connected clients), this requires the previous state to be stored somewhere so that subtraction can happen. 

Proposal:

.set(25)

Allow the instrument to be set, this can be then used to map to properties of data structures which inform this and remove the need for diffing. This is possible with an observer but using this required substantial changes to our app and exposing state where we don’t want to. With a synchronous set method, this can be done within methods without exposing internal state to observers. 

The Nodejs package ‘prom-client’ has this functionality already and we find it very useful. 

@RichardWright RichardWright added the spec:metrics Related to the specification/metrics directory label Oct 24, 2021
@reyang reyang added the release:after-ga Not required before GA release, and not going to work on before GA label Oct 28, 2021
@imgalli
Copy link

imgalli commented Dec 13, 2021

+1 on this

@jmacd
Copy link
Contributor

jmacd commented Feb 4, 2022

This request is on par with the request for a synchronous Gauge instrument, which I support.

As far as #2226 is concerned, we want the UpDownCounter that is Set() to be different than one that that uses. Add()

As far as how the specification is written today, it's easier to defined this as "Observing an asynchronous instrument synchronously", since it has the same metric identity as the asynchronous UpDownCounter. All we need to do is to allow these instruments (i.e., UpDownCounter, Gauge) to support Observe() outside of the asynchronous callbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:after-ga Not required before GA release, and not going to work on before GA spec:metrics Related to the specification/metrics directory
Projects
None yet
Development

No branches or pull requests

5 participants