refactor(metrics): route all controllers through core/metrics helpers#162
Merged
Conversation
Migrate every controller and the consumer framework off raw tally.Scope
calls onto the core/metrics helpers (Begin/Complete, NamedCounter,
NamedTimer). RPC controllers (land, ping) and queue controllers (batch,
build, start, score, speculate, buildsignal, log) now follow the same
Begin/Complete pattern as merge, so each Process call emits a
consistent {scope}.process.{called,succeeded,failed,latency,latency_histogram}
set with automatic error classification tags. The mergechecker's Check
gets the same treatment.
core/consumer/consumer.go is migrated to NamedCounter/NamedTimer rather
than Begin/Complete to preserve its custom success=true|false|cancel
and operation=ack|nack tagging.
Wire-format note: metric names move from flat keys (e.g. "received",
"land_request_count") to the {sub-scope}.{op}.{event} pattern (e.g.
"batch_controller.process.deserialize_errors"). Existing dashboards
keyed on the old names will need updating.
Each controller's metric emissions repeated the operation literal
("process", "land", "ping", "check") on every call. Hoist it to a
method-level `const opName = "..."` (file-level in speculate.go where
emissions span six helper methods), so the name is defined once per
file and every emit reads as opName.
albertywu
approved these changes
May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Route every controller and the consumer framework through the
core/metricshelpers so metric emission is consistent across the codebase.What changed
Migrated to
metrics.Begin/op.Complete+metrics.NamedCounter:gateway/controller/land.go,orchestrator/controller/ping.go,stovepipe/controller/ping.goorchestrator/controller/{batch,build,start,score,speculate,buildsignal,log}/*.goextension/mergechecker/github/checker.goEach migrated method now wraps its work with
op := metrics.Begin(scope, opName); defer func() { op.Complete(retErr) }(), which emits{scope}.{op}.called,{op}.succeeded/{op}.failed,{op}.latency, and{op}.latency_histogramwith automaticerror_origin,retryable, anddependencyclassification tags viacore/errs. Sub-event counters (deserialize_errors,storage_errors,publish_errors, …) go throughmetrics.NamedCounterso they share the same sub-scope prefix.Consumer framework —
core/consumer/consumer.go:Migrated to
metrics.NamedCounter/metrics.NamedTimerrather thanBegin/Completebecause the framework needs customsuccess=true|false|cancelandoperation=ack|nacktags that the standardOplifecycle can't express.Op-name de-duplication:
Each migrated method declares
const opName = "..."once and references it from every emit (file-level inspeculate.gowhere emits span six helper methods).Wire-format change
Metric names move from flat keys to
{controller_subscope}.{op}.{event}:land_request_countland_controller.land.calledland_request_latencyland_controller.land.latencyreceived(per controller){controller}_controller.process.calledprocessed{controller}_controller.process.succeededdeserialize_errors{controller}_controller.process.deserialize_errorsmessages_received(consumer)consumer.process.messages_receivedcontroller_latency(consumer)consumer.process.controller_latencyack_count,nack_count, …consumer.process.ack_count,consumer.process.nack_count, …Dashboards keyed on the old flat names will need updating; the
success=true|false|cancel,operation=ack|nack, and per-controller tags on consumer metrics are preserved.Test Plan
make build— all 135 targets build clean.make test— all 34 test targets pass, including://core/consumer:consumer_test— verifies the migratedprocessDeliverystill emitscontroller_latency(withsuccess=true|false) andack_count(substring matches survive theprocess.prefix).//extension/mergechecker/github:github_test//gateway/controller:controller_test,//orchestrator/controller:controller_test,//stovepipe/controller:controller_testbatch,build,buildsignal,log,score,speculate,startmake gazelle,make fmt,make mocks,make tidy— re-running on top of the diff produces zero further changes.make lint-license— clean.consumer_test.gousesstrings.Contains, which still matches the new fully-qualified names).Issues
None.