client_golang icon indicating copy to clipboard operation
client_golang copied to clipboard

Consider optional disabling of metric sorting

Open beorn7 opened this issue 7 years ago • 3 comments

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.

beorn7 avatar Oct 23 '18 11:10 beorn7

@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?

glefloch avatar Oct 31 '18 12:10 glefloch

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 avatar Oct 31 '18 13:10 beorn7

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.

beorn7 avatar Jun 02 '21 18:06 beorn7