Skip to content

API for accessing the contextual Recorder #503

Open
@asmello

Description

@asmello

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

No one assigned

    Labels

    C-coreComponent: core functionality such as traits, etc.E-complexEffort: complex.E-intermediateEffort: intermediate.T-ergonomicsType: ergonomics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions