Skip to content

feat(observability/metrics): add Emitter and Begin/Complete lifecycle helpers#214

Merged
xytan0056 merged 2 commits into
mainfrom
pr1-emitter-core
Jul 21, 2026
Merged

feat(observability/metrics): add Emitter and Begin/Complete lifecycle helpers#214
xytan0056 merged 2 commits into
mainfrom
pr1-emitter-core

Conversation

@xytan0056

@xytan0056 xytan0056 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the observability/metrics package per the merged design doc (docs/observability/metrics.md, #158): a thin, concrete wrapper over tally.Scope pinning the path shape <scope>.<op>.<name>.

  • emitter.goEmitter (New/Nop/Tagged/Counter/DurationHistogram/ValueHistogram) plus the Begin/Complete lifecycle helpers over an Op handle.
  • names.go — shared op / tag-key / result-value constants and Outcome(err) (only context.Canceled → cancelled; DeadlineExceeded → failure, a genuine timeout).

Test plan

CI

@xytan0056
xytan0056 requested review from a team as code owners July 17, 2026 06:35
@xytan0056 xytan0056 changed the title feat(observability/metrics): add Emitter and Begin/Complete lifecycle helpers [WIP] feat(observability/metrics): add Emitter and Begin/Complete lifecycle helpers Jul 17, 2026
@xytan0056 xytan0056 changed the title [WIP] feat(observability/metrics): add Emitter and Begin/Complete lifecycle helpers feat(observability/metrics): add Emitter and Begin/Complete lifecycle helpers Jul 17, 2026
@xytan0056 xytan0056 changed the title feat(observability/metrics): add Emitter and Begin/Complete lifecycle helpers [WIP] feat(observability/metrics): add Emitter and Begin/Complete lifecycle helpers Jul 17, 2026
@xytan0056 xytan0056 changed the title [WIP] feat(observability/metrics): add Emitter and Begin/Complete lifecycle helpers feat(observability/metrics): add Emitter and Begin/Complete lifecycle helpers Jul 17, 2026
… helpers

Introduces the observability/metrics package per docs/observability/metrics.md:
a thin, concrete wrapper over tally.Scope pinning the path shape
<scope>.<op>.<name>.

- emitter.go: Emitter (New/Nop/Tagged/Counter/DurationHistogram/
  ValueHistogram) plus the Begin/Complete lifecycle helpers over an Op handle
- names.go: shared op/tag-key/result-value constants and Outcome(err)
  (context.Canceled -> cancelled; DeadlineExceeded -> failure)
- emitter_test.go: path-shape, tag isolation/composition, Begin/Complete
  result tagging, and Outcome classification
)

// Operation (op) names live in each consuming package's metrics.go, named after
// the interface method they measure (e.g. "GetTargetGraph", "Compute").

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.

@xytan0056 xytan0056 Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I initially did it in a centralized place in names.go than I figure it's kinda weird to have to do metric.Opxxx
op names are package-specific constants, not shared vocabulary

@xytan0056
xytan0056 merged commit 08fa036 into main Jul 21, 2026
10 checks passed
xytan0056 added a commit that referenced this pull request Jul 21, 2026
…tter (#215)

Ports the controller off raw `tally.Scope` counters/timers to
`*metrics.Emitter` with the `Begin`/`Complete` lifecycle helper.

- `Params` keeps `Scope tally.Scope`; `NewController` subscopes it to
`controller` and builds its own emitter (nil → no-op). Same for every
component — no injected emitter.
- Each RPC bakes the `repo` tag once, then `Begin`/`Complete` emit
`start` + result-tagged `finish` (replacing `calls`/`success`/`failure`
+ `total_duration` timers).
- Sub-ops `get_graph` and `compare_target_graphs` get their own
lifecycle; `compare_target_graphs` flattens to its own op.
- Other timers → `DurationHistogram` with package-level buckets
(`controller/metrics.go`); `emitFailureMetric` keeps the
`failure_type`/`failure_reason` axis.

1. #214.
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.

2 participants