Set the metrics provider to a noop one on shutdown instead of nullptr

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.1.0-rc0, 9.0.0-rc1
    • Affects Version/s: None
    • Component/s: None
    • None
    • Networking & Observability
    • Fully Compatible
    • v9.0
    • N&O 2026-07-20
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This actually matches what is already [documented in the header](https://github.com/10gen/mongo/blob/master/src/mongo/otel/metrics/metrics_initialization.h#L24). The reason this is needed is that a metric may be registered during shutdown, so the provider is nullptr, but the code assumes the provider is always nonnull (e.g. [here](https://github.com/10gen/mongo/blob/32af7511ad7d933b46e21ee3569af3f73f40ee61/src/mongo/otel/metrics/metrics_service.h#L650)). My guess is that the author assumed setting the provider to `nullptr`or to `{}` (which results in `nullptr` becuse it creates a default-constructed `shared_ptr`) would set the provider to noop.

      Additionally, removed some useless comments from the non-otel implementations.

            Assignee:
            Michael Nugent
            Reporter:
            Michael Nugent
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: