Skip to content

refactor: extract metrics into usecase decorator layer#130

Merged
allisson merged 1 commit into
mainfrom
improve-codebase
May 25, 2026
Merged

refactor: extract metrics into usecase decorator layer#130
allisson merged 1 commit into
mainfrom
improve-codebase

Conversation

@allisson
Copy link
Copy Markdown
Owner

Summary

  • Extract BusinessMetrics recording out of 7 usecase implementations (44 scattered method-body calls) into thin decorator structs — one per usecase interface — applied only at DI wiring time when metrics are enabled
  • Delete NoOpBusinessMetrics and the nil-guard in metrics.Record; a nil BusinessMetrics is now architecturally impossible because decorators are simply not wired when MetricsEnabled=false
  • Every usecase constructor drops its BusinessMetrics parameter, making tests simpler and constructors honest about their actual dependencies

Test plan

  • make test — all unit tests pass
  • make test-all — integration tests pass
  • make lint — no lint issues

🤖 Generated with Claude Code

Move BusinessMetrics recording out of the 7 usecase implementations and
into thin decorator structs (one per usecase interface) applied only at
DI wiring time when metrics are enabled. This concentrates observability
at a single seam instead of diffusing it across 44 method bodies, and
lets every usecase constructor and test drop the metrics argument
entirely. NoOpBusinessMetrics and its nil-guard in Record are deleted
because the new DI pattern makes a nil BusinessMetrics architecturally
impossible.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@allisson allisson merged commit 3940458 into main May 25, 2026
3 checks passed
@allisson allisson deleted the improve-codebase branch May 25, 2026 12:44
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.

1 participant