Skip to content

Please expose wrappingCollector publicly #1060

@joewreschnig

Description

@joewreschnig

We have a number of custom collectors that wrap other collectors - e.g. some cached value is periodically refreshed, where we want to collect metrics about the last refresh time, and also metrics about the value itself.

Currently for the outer collector to add a label or metric to the inner collector, we either need to reimplement wrappingCollector ourselves, or we need to also apply the labels to the outer collector when it's registered using e.g. WrapRegistererWith, in turn leading to some ugly patterns like

	{
		r := prometheus.WrapRegistererWith(labels, prometheus.DefaultRegisterer)
		r.MustRegister(c)
		defer r.Unregister(c)
	}

repeated for every collector with different labels.

With a public wrappingCollector we could avoid this by either wrapping it at the layer between the outer and inner collector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions