refactor: extract metrics into usecase decorator layer#130
Merged
Conversation
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>
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
BusinessMetricsrecording 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 enabledNoOpBusinessMetricsand the nil-guard inmetrics.Record; a nilBusinessMetricsis now architecturally impossible because decorators are simply not wired whenMetricsEnabled=falseBusinessMetricsparameter, making tests simpler and constructors honest about their actual dependenciesTest plan
make test— all unit tests passmake test-all— integration tests passmake lint— no lint issues🤖 Generated with Claude Code