Skip to content

refactor(router): Create router metrics with the instrumentation library - #1185

Merged
privateip merged 1 commit into
fix/issue-1149-cnifrom
fix/issue-1149-router
Oct 28, 2026
Merged

privateip merged 1 commit into
fix/issue-1149-cnifrom
fix/issue-1149-router

Conversation

@privateip

@privateip privateip commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

galactic-router registered its service route metrics, BMP station gauge and traffic policy collector on controller-runtime's registry directly, so the instrumentation library's checks skipped them.

They now go through the library. The BMP gauge moves out of the command's main package, which the library's lint can't reach.

The router's scrape test now creates the service route metrics before scraping and lints them.

Stack

Merge in order:

  1. refactor(cni): Create datapath metrics with the instrumentation library #1184 CNI datapath, onto main
  2. refactor(router): Create router metrics with the instrumentation library #1185 router, onto refactor(cni): Create datapath metrics with the instrumentation library #1184 (this PR)
  3. refactor(gateway,nat): Create metrics with the instrumentation library #1186 gateway and NAT, onto refactor(router): Create router metrics with the instrumentation library #1185
  4. refactor(vrf): Create ingress sidecar metrics with the library #1187 ingress sidecar, onto refactor(gateway,nat): Create metrics with the instrumentation library #1186
  5. refactor(edge): Create edge metrics with the instrumentation library #1188 edge, onto refactor(vrf): Create ingress sidecar metrics with the library #1187
  6. refactor(fabric): Create fabric routing metrics with the library #1189 fabric routing, onto refactor(edge): Create edge metrics with the instrumentation library #1188
  7. refactor(fabric-api): Create metrics with the instrumentation library #1190 fabric-api, onto refactor(fabric): Create fabric routing metrics with the library #1189

Compatibility

The router endpoint exports the same families as before. Rolling back restores the previous code with no other effect.

Test plan

  • Lint, build, unit and alert rule tests pass on this layer. The end-to-end and root-only suites run in CI.
  • A series inventory of the router endpoint before and after this change is identical.

Related to #1149

🤖 Generated with Claude Code

galactic-router registered its service route metrics, its BMP station
gauge and the traffic policy collector on controller-runtime's
registry directly, so the instrumentation library's reserved-label
check and lint skipped them.

- The service route metrics are created by the library's
  constructors when run calls serviceroute.NewMetrics, as before.
- galactic_router_bmp_station_up moves from package main to
  internal/runtime/gobgp, beside the route install gauge, because the
  lint can only link metrics defined outside a main package. The
  observer the BMP keeper calls moves with it.
- The traffic policy collector registers through
  metrics.MustRegister.

The lint linking check no longer counts metrics.MustRegister as
creating a metric. Lint checks only what the library's constructors
create, so a custom collector registered in a main package is never
something it could see.

The scrape test creates the service route metrics before scraping and
lints them. The endpoint's series are unchanged.

Refs: #1149

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@privateip
privateip force-pushed the fix/issue-1149-router branch from b38bbed to 48ca043 Compare October 28, 2026 14:22
@privateip
privateip marked this pull request as ready for review October 28, 2026 14:58
@privateip
privateip requested a review from a team as a code owner October 28, 2026 14:58

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve.

galactic_router_bmp_station_up{router,station} and the five galactic_service_route_* series are unchanged in name, type, labels and buckets (DefBuckets kept), and still land on the registry the manager serves.

  • The BMP gauge moved from cmd/galactic-router into internal/runtime/gobgp and now loads in every binary linking gobgp. It is a vector with no children outside the router, so no series appear elsewhere.
  • Infra only references the BMP gauge by name in alerts; nothing renamed.
  • The traffic-policy collector is now MustRegistered rather than returning an error; it was registered on the same registry before, so the failure mode is only louder.

@privateip
privateip merged commit 23de5d9 into main Oct 28, 2026
23 checks passed
@privateip
privateip deleted the fix/issue-1149-router branch October 28, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants