• Type: New Feature
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • DB Integration & Observability
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Overview

      Build the process-wide MetricsRegistry for the unified metrics framework (epic SPM-4962), plus the registration codegen that feeds it. This ticket absorbs SERVER-138333 (registration codegen): the registration spec, the macro, and the generated initializers are one contract with the registry that consumes them.

      Scope of Work

      • One registry per process, created explicitly via materialize(ServiceContext*) and accessed via MetricsRegistry::get().
      • Members: _sections, _scrapeBuckets, _ownedLeaves, _ownedLeafPaths, and the one-time _materialized flag.
      • Materialization iterates every registration once, sorted by path: resolve stats, run MetricsRegistryTraits<Stats>::bind, validate and claim leaves.
      • Enforce single-path ownership: a duplicate leaf path fails startup via invariant.
      • Contributor forms in this ticket: generated leaves (default), the appender: C++ form (void(BSONObjBuilder*)) reachable via MONGO_REGISTER_METRICS, and isEnabled.
      • Registration codegen: per-file MONGO_INITIALIZER (RegisterMetrics_<file_path>) in the generated _gen.cpp calling addMetricsRegistration directly, with a generated default state binding (stats instance) and leaves factory, bounded by the BeginMetricsRegistration/EndMetricsRegistration initializer groups.
      • replaceMetricsRegistration for C++ overrides of a generated registration, pre-materialization only, with a catalog shape check.
      • unmaterialize() returns the registry to an unmaterialized state for tests that construct repeated ServiceContexts; production code never calls it.

      Out of scope

      • Name governance build-time validator and metrics_name_exceptions.yml: owned by SERVER-139210, which plugs into the validation pass built in SERVER-138594.
      • configAppender (RenderContext) and the IDL appender: override: SERVER-138334.
      • OTel instrument binding and counter backfill: SERVER-138334.
      • Startup wiring into mongod_main/mongos_main (observability::initialize): SERVER-138334.

      Design source

      Technical Design: Unified Metrics Framework, Registration and Process Lifecycle tab: "The MetricsRegistry", "Materialization", "Unmaterialization", "Registration Concurrency", "Grammar", "Registration", "Startup Ordering".

            Assignee:
            Finley Lau
            Reporter:
            Finley Lau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: