-
Notifications
You must be signed in to change notification settings - Fork 206
Open
Labels
C-coreComponent: core functionality such as traits, etc.Component: core functionality such as traits, etc.E-complexEffort: complex.Effort: complex.E-intermediateEffort: intermediate.Effort: intermediate.T-ergonomicsType: ergonomics.Type: ergonomics.
Description
Another one for ergonomics.
Scenario:
- Install a Prometheus exporter, but skip the HTTP server, as we have our own.
- Inside our HTTP server, we add an endpoint that renders the metrics in Prometheus format, which requires access to a
PrometheusHandle.
Currently, to make this work, we need to register the Prometheus Recorder and produce a handle to it in the very outer layers of the program (e.g. inside of main()) and then pass that all the way into the internal HTTP server state. Ideally we'd be able to get a handle internally by producing a reference to the contextual Recorder, downcasting it to the correct type and then calling PrometheusRecorder::handle.
This would actually be "safer", because if for some reason one creates multiple Recorders in the same program, there's a possibility of mismatch between the one in scope and the one being used to render the metrics. If we fetch the Recorder contextually that risk goes away.
Metadata
Metadata
Assignees
Labels
C-coreComponent: core functionality such as traits, etc.Component: core functionality such as traits, etc.E-complexEffort: complex.Effort: complex.E-intermediateEffort: intermediate.Effort: intermediate.T-ergonomicsType: ergonomics.Type: ergonomics.