-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
refactor: metrics instrumentation framework typing and structure #12717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: metrics instrumentation framework typing and structure #12717
Conversation
Currently, only patch changes are allowed on master. Your PR labels (semver: minor) indicate that it cannot be merged into the master at this time. |
Test Results - Alternative Providers987 tests 584 ✅ 23m 22s ⏱️ Results for commit d2d3cff. ♻️ This comment has been updated with latest results. |
Test Results (amd64) - Integration, Bootstrap 5 files 5 suites 2h 22m 47s ⏱️ Results for commit d2d3cff. ♻️ This comment has been updated with latest results. |
9429212
to
e3bd187
Compare
e3bd187
to
cb3585a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and clean refactoring to move away from the factory pattern. As you explained in your PR description, and as discussed in the previous PRs, I think this totally makes sense.
I added a few comments / questions / suggestions, afterwards this should be good to go! 💯
Thanks for continuously improving the analytics framework!
localstack-core/localstack/services/cloudformation/resource_provider.py
Outdated
Show resolved
Hide resolved
...-core/localstack/services/stepfunctions/asl/static_analyser/usage_metrics_static_analyser.py
Outdated
Show resolved
Hide resolved
localstack-core/localstack/utils/analytics/metrics/interface.py
Outdated
Show resolved
Hide resolved
localstack-core/localstack/utils/analytics/metrics/interface.py
Outdated
Show resolved
Hide resolved
5d2f749
to
d2d3cff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks a lot for churning over all the comments! I think this now looks great! Nice, clean, small, well-defined API separated from its implementations! 💯
Motivation
follow-up to PR #12386 (thanks @alexrashed for the inputs)
The refactoring simplifies the class hierarchy and removes the overloaded factory pattern, which is increasingly becoming a code smell, as Counter and LabeledCounter evolve with diverging behavior and only partially overlapping interfaces.
The previous design made it increasingly difficult to enforce both static and dynamic typing guarantees, leading to ambiguity around the correct usage of the Counter and weakening the overall abstraction. The new structure clearly separates responsibilities, improves type safety at both runtime and development time, and lays a more solid foundation for extensibility.
Additionally, the monolithic
metrics.py
module will be split into smaller, focused modules.Testing
pytest tests/unit/utils/analytics/test_metrics.py
TODO
note: the corresponding updates to the classes using the Counter in the ext package have been addressed in PR #4638