Skip to content

refactor(fabric-api): Create metrics with the instrumentation library - #1190

Merged
privateip merged 1 commit into
fix/issue-1149-fabric-routingfrom
fix/issue-1149
Oct 28, 2026
Merged

privateip merged 1 commit into
fix/issue-1149-fabric-routingfrom
fix/issue-1149

Conversation

@privateip

@privateip privateip commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The fabric-api gateway registered its metrics on a registry passed in from the command, and the node sidecar served a private registry, so the adoption test still skipped both.

Both roles now create their metrics through the library, and the node sidecar serves the library's handler. A gauge that reads state when scraped is created on the first call that needs it, so a series that only exists in one mode still only exists there.

With this layer the adoption test runs with no directory skipped.

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
  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 (this PR)

Compatibility

The gateway endpoint is unchanged. The node sidecar keeps all of its series and gains the build-info series, the full Go runtime set in place of the basic one, and a few controller-runtime and certificate watcher families.

Both roles export a certificate expiry gauge, and its help text now names both certificates so the two definitions agree. Rolling back restores the previous code with no other effect.

Test plan

  • Lint, build, unit and alert rule tests pass on the combined change. The end-to-end and root-only suites run in CI.
  • Series inventories of both roles show no family removed or retyped.
  • The adoption, lint and scrape tests pass with no directory skipped.

Fixes #1149

🤖 Generated with Claude Code

The fabric-api gateway registered its metrics on a registry passed in
from the command, and the node sidecar served a private registry. The
instrumentation library's checks saw neither, and the adoption test
still skipped them.

- Both roles create their metrics with the library's constructors,
  and each NewMetrics starts its vectors over, because the library's
  registry keeps a series across calls.
- The library creates a function metric only once per process, so
  the queue depth, service switch, admission, clock and search index
  gauges are created on the first call that needs them and read the
  source the latest call gave them. A series that only exists in one
  mode still only exists there.
- The node sidecar serves metrics.Handler. Its endpoint keeps every
  series it had and adds instrumentation_build_info, the full Go
  runtime set where the private registry had the basic Go collector,
  and the controller-runtime and certificate watcher series the shared
  registry holds.
- Both roles define fabric_api_certificate_expiry_timestamp_seconds,
  with help text naming one certificate each. The help now names both,
  so the two definitions agree on one registry.

With every directory migrated, the adoption test's skip list and the
code that applied it are gone.

The scrape test creates both roles' startup series and lints them.

Fixes #1149

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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
scotwells
scotwells previously approved these changes Oct 28, 2026
ecv
ecv previously approved these changes Oct 28, 2026

@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.

Every fabric_api_gateway_* and fabric_api_node_* series keeps its name, type, labels, buckets and constant afi label; function metrics are now created once and read a swappable source, with the same values. The node sidecar now serves the shared registry with the library's handler, and its Go and process series are still present. CI is green.

  • HELP text of fabric_api_certificate_expiry_timestamp_seconds changes to one shared string, since gateway and node define the same name and the library requires one definition. Series, labels and values are unchanged.
  • The node's /metrics now includes whatever controller-runtime registers on its registry (extra Go runtime series, instrumentation_build_info). Additive.
  • fabric_api_node_bmp_route_messages_total is now created in RegisterIndex, so BMPMessage() is a no-op before it runs. A node always calls RegisterIndex, so the exported series is unchanged; idleUnconfigured exports no index series either way, as before.
  • Nothing in infra queries a series whose name or labels changed.

@privateip
privateip dismissed stale reviews from ecv and scotwells October 28, 2026 15:06

The merge-base changed after approval.

@privateip
privateip merged commit 23de5d9 into main Oct 28, 2026
23 checks passed
@privateip
privateip deleted the fix/issue-1149 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.

Create every metric through the instrumentation library

3 participants