refactor(npm): consolidate metric collectors into metrics.go

Follow-up from the review of !794 (merged) (raised by @jdrpereira), tracked in #248 (closed). Behavior-preserving cleanup — not a plan step, no spec change.

♻️ What this MR does

npm's Prometheus metric collectors and RegisterMetrics were spread across five files: RegisterMetrics lived in buffered.go, and each collector sat next to its handler. The sibling formats keep every vector plus RegisterMetrics in one dedicated file (internal/format/oci/metrics.go, internal/storage/metrics.go). This consolidates npm to match, so the full metric surface and its registration wiring stay in one place — the drift that let the wantSeries gap into !794 (merged).

  • Consolidated into internal/format/npm/metrics.go — the eight operational collectors, RegisterMetrics, and the shared metricSubsystemNPM const, joining the request-level metrics the file already held.
Collector Moved from
bufferedCounterUpdates buffered.go
distTagsCacheBlobMissing, distTagsInlineBuildCollapsed disttags.go
packumentRebuildTotal, packumentRebuildDurationSeconds packument_cache.go
packumentInlineBuildCollapsed packument_get.go
gateRejectionsTotal, coherenceFailuresTotal publish_stream.go
  • Emitting logic stays putbufferedUpdate, writeGateRejection / gateRejectionReason / writeCoherenceError, the inline-build and rebuild helpers, and the rebuild result label-value consts remain in their handler files; only the collector declarations move. The five source files drop their now-unused prometheus / fmt imports (packument_cache.go keeps prometheus for NewTimer).
  • Doc refresh — the TODO(buffered) no longer says "this file" (it now names buffered.go / bufferedUpdate explicitly), and metrics.md, metrics_test.go, and the surviving handler comments point at the new location.

Behavior-preserving: no metric names, labels, help text, or registration order change.

Verification

  • Full npm unit suite green, including metrics_test.go's gatherer and label-enumeration coverage.
  • go build ./... and go vet (incl. -tags integration) clean; golangci-lint (default tags) reports 0 issues.
  • Diff is exactly the eight npm files; all eleven metric names (3 request + 8 operational) are present with identical labels and help.

📚 References

Related to #248 (closed)

Merge request reports

Loading
Loading