Repository navigation
Description
Parent: #1144
Deliverable: Every Galactic metric is created through the instrumentation library, on the one registry each binary serves.
Today most metric constructors receive a registry as a parameter, and a few components (the CNI's datapath metrics, the fabric-api node sidecar, and the fabric config agent's next-hop check) serve a private registry. The library has one shared registry and refuses reserved label names at startup. Custom collectors that read datapath state at scrape time stay custom but register through the library.
This milestone can be split into one pull request per subsystem: CNI datapath, router, gateway and NAT, ingress sidecar, edge, fabric routing, and fabric-api.
Work items:
- Replace direct metric construction and registration with the library's constructors, and custom collectors with its registration call.
- Serve the library's handler wherever a binary serves metrics outside a controller-runtime manager, and merge private registries into it without changing any series name.
- Rework tests that relied on a private registry per test, so they don't share series state across tests.
- Remove each migrated directory from the adoption test's skip list.
Dependencies: #1148.
Acceptance: Every metrics endpoint serves the same series names and types as before, plus the build-info metric, and its scrape test passes. Alert rule tests pass unchanged. The adoption test passes with no metrics directory skipped.
Pull requests: one stack, merged bottom to top. #1192 fixes main and merges first.
- refactor(cni): Create datapath metrics with the instrumentation library #1184 CNI datapath
- refactor(router): Create router metrics with the instrumentation library #1185 router
- refactor(gateway,nat): Create metrics with the instrumentation library #1186 gateway and NAT
- refactor(vrf): Create ingress sidecar metrics with the library #1187 ingress sidecar
- refactor(edge): Create edge metrics with the instrumentation library #1188 edge
- refactor(fabric): Create fabric routing metrics with the library #1189 fabric routing
- refactor(fabric-api): Create metrics with the instrumentation library #1190 fabric-api
Activity
privateip commentedon Oct 28, 2026
Confirmed on
mainat 1885f0f.With the
pendingskip list ininternal/instrumentation/adoption_test.goemptied,go test ./internal/instrumentation -run 'TestAdopted|TestNoMetricsOutsideLibrary'fails with 171 findings in 35 files. These are the 19 pending directories plusinternal/edge/diag/diagtestandinternal/plumbing/nldump/nldumptest, which sit below pending directories. The unmodified suite passes.What the findings are:
prometheus.Registererand build collectors withprometheus.New*. The commands then register them onctrlmetrics.Registryat startup.prometheus.NewRegistry(): the CNI run daemon (internal/plumbing/ebpf/metrics.New), the fabric config agent's next-hop guard (internal/fabricconfig.NewNextHopMetrics) and the fabric-api node sidecar (internal/fabric/node).ctrlmetrics.Registry.Register.metrics.Handler.Two things beyond the issue text:
componentconstant label (internal/edge/diag/diag.go). The library's constructors refuse that label at startup, so it has to be renamed when those counters move. No alert rule or rule test reads it.providerandnamespacelabels on the edge and fabric routing state collectors, and on the traffic-policy node collector, are custom-collector labels, which the library doesn't check. They stay with Rename metric labels reserved by the collection pipeline #1150.privateip commentedon Oct 28, 2026
Plan, delivered as a stack of 7 pull requests. Each one moves one subsystem and removes its directories from
pending.internal/plumbing/ebpf/metrics,internal/plumbing/nldump,internal/installer,cmd/galactic-cni. The run daemon servesmetrics.Handler(), which also takestests/psc/fixtureoff the list.internal/serviceroute,internal/gateway,cmd/galactic-router.internal/plumbing/ebpf/xdpdispatch,cmd/galactic-gateway,cmd/galactic-nat.internal/ingresssidecar,cmd/galactic-vrf.internal/edge/diag,cmd/galactic-edge,cmd/galactic-controller.internal/fabricconfig,cmd/fabric-config-agent,cmd/fabric-router-controller.internal/fabric/gateway,internal/fabric/node,cmd/fabric-api. This one emptiespending, and its PR closes this issue.How the code changes:
metrics.MustRegister.nldump, because every binary that serves metrics and links it already registers it.mainand its scrape test call. The scrape test then covers every series the binary creates at startup, not only the ones registered at package load.Compatibility:
instrumentation_build_info.go_*andprocess_*series. The fabric-api node sidecar already exported those.componentconstant label is renamed, because the library refuses it at startup. No alert rule reads it. The release notes list the rename.fabric_api_certificate_expiry_timestamp_secondsandfabric_api_credentials_loadedwith different help text. The help text is unified so both roles can share one definition.Validation per layer:
task lint,task build,task test:unitandtask test:alertswith no rule-test changes.task ci, which adds the end-to-end suite, runs on the final layer.test(nat): Register the scrape test's collector once per process
refactor(vrf): Create ingress sidecar metrics with the library
test(vrf): Create the scrape test's metrics once per process
refactor(edge): Create edge metrics with the instrumentation library
test(controller): Register the scrape test's collector once per process
refactor(fabric): Create fabric routing metrics with the library
test(fabric): Register the scrape test's collector once per process
refactor(fabric-api): Create metrics with the instrumentation library
privateip commentedon Oct 28, 2026
The fix is up for review as a stack of 7 pull requests, linked in order: #1184, #1185, #1186, #1187, #1188, #1189, #1190. The last one closes this issue.
Two points differ from the plan above.
The plan said the fabric config agent would gain the Go runtime series. It doesn't. controller-runtime registers those collectors only when a binary links its controller package, and the agent links no controllers. Its endpoint gains only the build-info series.
The acceptance criterion asks for the same series as before plus build-info. Two endpoints that served a private registry now also export the standard Go runtime and process families from the shared registry, which the library's handler always serves. They are the CNI daemon (about 150 families) and the fabric-api node sidecar (about 115, where it had the basic Go collector). No existing series is renamed, removed or retyped. Please say on #1184 or #1190 if those extra families should be dropped rather than accepted.
test(cni): Read only the families each metrics test checks
refactor(router): Create router metrics with the instrumentation library
refactor(gateway,nat): Create metrics with the instrumentation library
test(nat): Register the scrape test's collector once per process
refactor(vrf): Create ingress sidecar metrics with the library
test(vrf): Create the scrape test's metrics once per process
refactor(edge): Create edge metrics with the instrumentation library
test(controller): Register the scrape test's collector once per process
refactor(fabric): Create fabric routing metrics with the library
test(fabric): Register the scrape test's collector once per process
refactor(fabric-api): Create metrics with the instrumentation library
refactor(cni): Create datapath metrics with the instrumentation library