Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GovukPrometheus - custom labels from rack env
Apps can use request.env['govuk.prometheus_labels'] to specify custom labels for prometheus. For example, and app might do: prometheus_labels = request.env.fetch('govuk.prometheus_labels', {}) request.env['govuk.prometheus_labels'] = prometheus_labels.merge( document_type: @content_item.document_type, schema_name: @content_item.schema_name, ) To set the document type / schema name as custom labels (which is useful for the apps where this isn't obvious based on controller / action, like government-frontend) Testing locally, this results in metrics like: http_request_duration_seconds_count{action="show",controller="content_items",document_type="answer",schema_name="answer"} 1 Care does need to be taken with the cardinality of prometheus labels (i.e. there shouldn't be too many different combinations of labels), but things like document_type are useful and shouldn't increase cardinality too much.
- Loading branch information