prometheus / client_golang

Prometheus instrumentation library for Go applications
https://pkg.go.dev/github.com/prometheus/client_golang
Apache License 2.0
5.4k stars 1.18k forks source link

Consider optional disabling of metric sorting #483

Open beorn7 opened 6 years ago

beorn7 commented 6 years ago

With extremely large exposition (example: kube-state-metrics on a large cluster will expose hundreds of MiB of metrics data), sorting of metrics becomes a quite significant computational burden. As metrics sorting is not required for valid expositions, a registry could provide an option to not sort after gathering metrics.

glefloch commented 6 years ago

@beorn7, after looking at the code, you would like to add a option to the Registry to avoid this call : https://github.com/prometheus/client_golang/blob/f30f428035633da15d00d3dfefb0128c5e569ef4/prometheus/registry.go#L533 ?

If this is the case, can I work one this or can you give me some hint?

beorn7 commented 6 years ago

Yeah, the implementation of this will be straight forward, obviously.

The devil is in the detail of how to design the interface. I'm currently considering a separate registry package, inspired by the discussion of how to name WrapRegistererWith properly. We might have a New(Opts) constructor there, which would read in real code like the following:

r := registry.New(registry.Opts{DisableSorting: true, PedanticChecks: true})

That would avoid a combinatorial explosion of constructors (we already have NewPedanticRegistry).

I would like to postpone work on this particular issue until the grand design of this is done (and then it will be trivial to do). I'm currently working on something like a design doc for v0.10 to put it up for discussion.

beorn7 commented 3 years ago

I mostly assigned this to myself as a “default” because I used to be the maintainer of this repo. Therefore, I'm un-assigning this from myself no. New maintainers @bwplotka & @kakkoyun, please deal with this as you see fit.