You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(metrics): route all controllers through core/metrics helpers (#162)
## Summary
Route every controller and the consumer framework through the
`core/metrics` helpers so metric emission is consistent across the
codebase.
## What changed
**Migrated to `metrics.Begin` / `op.Complete` +
`metrics.NamedCounter`:**
- RPC controllers: `gateway/controller/land.go`,
`orchestrator/controller/ping.go`, `stovepipe/controller/ping.go`
- Queue controllers:
`orchestrator/controller/{batch,build,start,score,speculate,buildsignal,log}/*.go`
- Extension: `extension/mergechecker/github/checker.go`
Each 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_histogram` with automatic `error_origin`, `retryable`,
and `dependency` classification tags via `core/errs`. Sub-event counters
(`deserialize_errors`, `storage_errors`, `publish_errors`, …) go through
`metrics.NamedCounter` so they share the same sub-scope prefix.
**Consumer framework — `core/consumer/consumer.go`:**
Migrated to `metrics.NamedCounter` / `metrics.NamedTimer` rather than
`Begin`/`Complete` because the framework needs custom
`success=true|false|cancel` and `operation=ack|nack` tags that the
standard `Op` lifecycle can't express.
**Op-name de-duplication:**
Each migrated method declares `const opName = "..."` once and references
it from every emit (file-level in `speculate.go` where emits span six
helper methods).
## Wire-format change
Metric names move from flat keys to
`{controller_subscope}.{op}.{event}`:
| Before | After |
| --- | --- |
| `land_request_count` | `land_controller.land.called` |
| `land_request_latency` | `land_controller.land.latency` |
| `received` (per controller) | `{controller}_controller.process.called`
|
| `processed` | `{controller}_controller.process.succeeded` |
| `deserialize_errors` |
`{controller}_controller.process.deserialize_errors` |
| `messages_received` (consumer) | `consumer.process.messages_received`
|
| `controller_latency` (consumer) |
`consumer.process.controller_latency` |
| `ack_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 migrated
`processDelivery` still emits `controller_latency` (with
`success=true|false`) and `ack_count` (substring matches survive the
`process.` prefix).
- `//extension/mergechecker/github:github_test`
- `//gateway/controller:controller_test`,
`//orchestrator/controller:controller_test`,
`//stovepipe/controller:controller_test`
- Per-stage controllers: `batch`, `build`, `buildsignal`, `log`,
`score`, `speculate`, `start`
- `make gazelle`, `make fmt`, `make mocks`, `make tidy` — re-running on
top of the diff produces zero further changes.
- `make lint-license` — clean.
- No test assertions on the renamed metrics needed updating
(`consumer_test.go` uses `strings.Contains`, which still matches the new
fully-qualified names).
## Issues
None.
returnfmt.Errorf("failed to create batch dependent index for new batchID=%s: %w", batch.ID, err)
181
185
}
182
186
183
187
// Persist batch to storage.
184
188
// This is the final operation that concludes the batch creation process. If it fails, BatchDependents will be pointing to a batch id that does not exist.
185
189
// We do not reuse batch ids, a retry of this operation will create a new batch with a new ID. The downstream logic that operates on BatchDependent should be able to handle stale entries.
0 commit comments