Skip to content

telemetry: move geoprobe-agent metrics into geoprobe package#3526

Merged
nikw9944 merged 2 commits intomainfrom
nikw9944/doublezero-3432
Apr 15, 2026
Merged

telemetry: move geoprobe-agent metrics into geoprobe package#3526
nikw9944 merged 2 commits intomainfrom
nikw9944/doublezero-3432

Conversation

@nikw9944
Copy link
Copy Markdown
Contributor

@nikw9944 nikw9944 commented Apr 13, 2026

Fixes #3432

Summary

  • Move geoprobe metrics from the shared internal/metrics package into a Metrics struct in internal/geoprobe, replacing package-level promauto globals with explicit dependency injection via NewMetrics()
  • Add source and device_pubkey constant labels to all geoprobe metrics, enabling per-device filtering in dashboards
  • Shorten metric names from doublezero_device_geoprobe_agent_* to doublezero_geoprobe_*
  • Delete the now-unused geolocation_metrics.go from the shared metrics package
  • Moving geoprobe metrics from package-level globals into a struct with source and device_pubkey constant labels lets multiple binaries emit the same metric names without collision, so dashboards can filter by source and device without needing separate metric prefixes per consumer.

Lines of Code

File Lines Status
geoprobe/metrics.go 190 New
geoprobe/metrics_test.go 144 New (test)
geoprobe-agent/main.go ~30 Modified
metrics/geolocation_metrics.go 139 Deleted
Net new (excl. tests) ~51

Testing Verification

  • Unit tests verify all 12 collectors are registered, constant labels are applied correctly, and duplicate registration panics as expected
  • All existing offsetCache tests in geoprobe-agent continue to pass unchanged
  • go vet clean across the telemetry module

@nikw9944 nikw9944 marked this pull request as ready for review April 13, 2026 17:37
@nikw9944 nikw9944 requested a review from ben-dz April 13, 2026 17:37
@nikw9944 nikw9944 changed the title telemetry: consolidate geoprobe-agent metrics into geoprobe package telemetry: move geoprobe-agent metrics into geoprobe package Apr 13, 2026
Copy link
Copy Markdown
Contributor

@ben-dz ben-dz left a comment

Choose a reason for hiding this comment

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

The new constant label is named device_pubkey, but the geoprobe-agent runs on geoprobe servers, not on DZDs/devices. The value passed is geoProbePubkey.String() — that's a geoprobe pubkey, not a device pubkey. This will cause confusion in PromQL queries and dashboards. Should probably be geoprobe_pubkey or just pubkey.

NewMetrics() is called unconditionally at

// Set up prometheus metrics.
, before the if *metricsEnable check. All 12 collectors get registered to prometheus.DefaultRegisterer even if no HTTP server is started to serve them. Not a regression (promauto did the same), but might want to fix it.

@nikw9944 nikw9944 requested a review from ben-dz April 14, 2026 23:38
@nikw9944 nikw9944 force-pushed the nikw9944/doublezero-3432 branch from 4188b91 to f5df9dd Compare April 15, 2026 14:13
nikw9944 and others added 2 commits April 15, 2026 14:13
Move metrics from the shared metrics package into a Metrics struct in the
geoprobe package. This replaces package-level promauto globals with
explicit dependency injection, adds source/device_pubkey constant labels,
and shortens metric names (doublezero_geoprobe_* instead of
doublezero_device_geoprobe_agent_*).
The constant label identifies the geoprobe device, not a generic device.
Rename for clarity and fix gofmt alignment.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nikw9944 nikw9944 force-pushed the nikw9944/doublezero-3432 branch from f5df9dd to 510a617 Compare April 15, 2026 14:13
@nikw9944 nikw9944 enabled auto-merge (squash) April 15, 2026 14:14
@nikw9944 nikw9944 merged commit 9338c01 into main Apr 15, 2026
33 checks passed
@nikw9944 nikw9944 deleted the nikw9944/doublezero-3432 branch April 15, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

geoprobe: consolidate geoprobe-agent metrics into package-level metrics

2 participants