Open jhwbarlow opened 7 months ago
Of course, multiple collectors (one per metric) could be used to work around this, but if the call to gather the data is expensive (for example, the gathering of all the UNIX sockets), that gathering would have to happen multiple times redundantly. This also means the metrics will not reflect the exact same snapshot in time, but that is minor.
Because the Collector API has the specification of the metric type and the help text as part of the
newCollector()
call, it is not possible to have multipleoutput()
calls in one collector without breaking the exposition format standard.This is because the help text and type will only be printed once for the entire collector, and not once per-metric. The exposition standard also says that different time-series (label combinations) of the same metric should be grouped together with a single help text and type.
Using multiple
output()
calls will tend to interleave the metrics if for example you are looping over a set of similar resources and reporting different metrics about the same resource in each loop iteration - although one could argue this is a programming error in the collector itself and the collector should be looping through each metric and outputting a time-series for each resource rather than looping through each resource and outputting each metric for that resource.As an example, I have been playing around with an exporter to export Unix Socket metrics:
I want to loop through all the UNIX sockets in the system and report a couple of metrics (current send queue length and the send queue limit) on them (ignoring label cardinality explosions for now 😄 ).
But because the name and help text is defined at the collector level, this leads to the invalid output (according to the exposition standard):
Looking at the builtin metrics, it would look like this also suffer from the same issue - the help text and name is actually defined to be generic instead of specific for each metric, which as far as my reading of the spec is incorrect.
Thanks!