As you can guess from my comments on the issue, I like the
idea. Formatting is a problem if you put a number into a string. And
while I doubt that `FormatFloat` has any guarantees of always
formatting in the same way across Go versions and platforms, at least
we can help the user a bit here.

On 04.05.21 09:38, Tristan Colgate wrote:
> 
> In the github issue referenced about, it has been suggested that
> count_values arguments could be used to control the value format.
> We've suggested allowing a fmt.Printf style (actually
> strconv.FormatFloat), specification to be appended to the label name,
> perhaps via a comma. e.g.
> 
> count_values("le,g.2")

I think that would work. We just need any separator that is not a
legal charactor of a label name. Which one we pick is matter of
taste. How about `%` to connect it to the printf-style formatting?

So the format could be "<labelname>[%[number]char]".

`number` becomes the `prec` parameter of `FormatFloat` (with default
value -1), and `char` becomes the `fmt` parameter of `FormatFloat`.

If nothing is specified, we fall back to `%f`, which is the current
behavior, so wo don't change current usage.

> In addition, to support the bucket labels produced for OpenMetrics
> histograms, we could use 'o' to facilitate OpenMetrics compatible
> formatting (this is %g with s potential additional .0 appended to
> exact integer values). 'o' is unused by FormatFloat.

+1

-- 
Björn Rabenstein
[PGP-ID] 0x851C3DA17D748D03
[email] [email protected]

-- 
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/20210504142026.GB2645%40jahnn.

Reply via email to