Hi Jonathan,

As it stands I would say that is an implementation detail that could
change, for example we might treat integers differently from floats in the
future. That is just the status quo, and if the community would like to see
this as the official behavior we could add a test case for setting values
to booleans. OpenMetrics even specifies that booleans must be represented
as 0/1 so I think there is a reasonable case to make it official.

Chris

On Wed, Apr 28, 2021 at 4:16 AM Jonathan Martin <[email protected]>
wrote:

> Hi there,
>
> I have a question relative to Gauge and booleans, if you don't mind.
>
> I'm considering to use a gauge to reflect the evolution of a boolean value.
>
> Knowing that the set method of a Gauge cast the given value as a float, I
> could call directly my_gauge.set(my_bool_value), and have it set to 0.0 or
> 1.0.
>
> So the question here is: Is the casting as float part of the API design,
> or simply an implementation detail which may change?
>
> If we have no guarantee that this cast will remain, then the call to set
> needs to be protected by my_gauge.set(float(my_bool_value)), but it is a
> pity to call it twice...
>
> It's a nice built in capability, so if it is going to last, I may argue
> that it would be worth mentioning it explicitly somewhere, either in the
> doc of the *set* function or the documentation of the Gauge (
> https://github.com/prometheus/client_python#gauge).
>
> Thanks in advance!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prometheus Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-developers/ffcee28e-d367-4897-8b30-ff5a1e28daean%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-developers/ffcee28e-d367-4897-8b30-ff5a1e28daean%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-developers/CANVFovVD7FhvAHdu74%2BG00CBZJO-NpRU%3DmkTDYSwb%2B2VPQ-e8w%40mail.gmail.com.

Reply via email to