Skip to content

Add support for dynamic labels in metrics

This adds support for dynamic labels to metrics, where the values of the labels is only known for a given request, not when creating the handler.

For this, writing a custom handler and a delegator to scrap info from the written response is required. The delegator is a lot simpler than the one promhttp ships, but seems to do its job just fine. The custom handler combines all the promhttp handlers in a single one, since we know we want all of them anyway and this could improve latency a bit (staying at one level instead of five handlers calling the next handler downwards).

Example of usage for this is gitlab-pages#384 - adding project-level metrics to gitlab-pages. More info in this comment thread: gitlab-pages#384 (comment 640137379)

A matching merge request to use this in gitlab-pages will follow.

Merge request reports