Skip to content

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

Conversation

vittoriopolverino
Copy link
Member

@vittoriopolverino vittoriopolverino commented Jun 5, 2025

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

@vittoriopolverino vittoriopolverino added this to the 4.6 milestone Jun 5, 2025
@vittoriopolverino vittoriopolverino self-assigned this Jun 5, 2025
@vittoriopolverino vittoriopolverino added the semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases label Jun 5, 2025
@localstack-bot
Copy link
Collaborator

localstack-bot commented Jun 5, 2025

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.

Copy link

github-actions bot commented Jun 5, 2025

Test Results - Preflight, Unit

21 613 tests  ±0   19 958 ✅ ±0   6m 14s ⏱️ -4s
     1 suites ±0    1 655 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit d2d3cff. ± Comparison against base commit f6075f6.

♻️ This comment has been updated with latest results.

@vittoriopolverino vittoriopolverino added semver: major Breaking changes which can be included in a major release only semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases and removed semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases semver: major Breaking changes which can be included in a major release only labels Jun 5, 2025
Copy link

github-actions bot commented Jun 5, 2025

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 43m 50s ⏱️ + 1m 25s
4 872 tests ±0  4 095 ✅ ±0  777 💤 ±0  0 ❌ ±0 
4 874 runs  ±0  4 095 ✅ ±0  779 💤 ±0  0 ❌ ±0 

Results for commit d2d3cff. ± Comparison against base commit f6075f6.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jun 7, 2025

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 8s ⏱️ +2s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit d2d3cff. ± Comparison against base commit f6075f6.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jun 7, 2025

Test Results - Alternative Providers

987 tests   584 ✅  23m 22s ⏱️
  4 suites  403 💤
  4 files      0 ❌

Results for commit d2d3cff.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jun 7, 2025

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 22m 47s ⏱️
5 229 tests 4 300 ✅ 929 💤 0 ❌
5 235 runs  4 300 ✅ 935 💤 0 ❌

Results for commit d2d3cff.

♻️ This comment has been updated with latest results.

@vittoriopolverino vittoriopolverino marked this pull request as ready for review June 8, 2025 17:45
@vittoriopolverino vittoriopolverino changed the title refactor metrics instrumentation framework typing and structure [DAT-159] refactor: metrics instrumentation framework typing and structure Jun 8, 2025
@vittoriopolverino vittoriopolverino marked this pull request as draft June 8, 2025 19:06
@vittoriopolverino vittoriopolverino force-pushed the DAT-159-refactor-metrics-instrumentation-framework-typing-and-structure branch from 9429212 to e3bd187 Compare June 8, 2025 19:21
@vittoriopolverino vittoriopolverino marked this pull request as ready for review June 8, 2025 20:20
@alexrashed alexrashed force-pushed the DAT-159-refactor-metrics-instrumentation-framework-typing-and-structure branch from e3bd187 to cb3585a Compare June 10, 2025 10:11
@vittoriopolverino vittoriopolverino marked this pull request as draft June 10, 2025 10:43
@vittoriopolverino vittoriopolverino marked this pull request as ready for review June 10, 2025 12:33
Copy link
Member

@alexrashed alexrashed left a 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!

@vittoriopolverino vittoriopolverino marked this pull request as draft June 10, 2025 20:07
@vittoriopolverino vittoriopolverino force-pushed the DAT-159-refactor-metrics-instrumentation-framework-typing-and-structure branch from 5d2f749 to d2d3cff Compare June 10, 2025 20:16
@vittoriopolverino vittoriopolverino marked this pull request as ready for review June 10, 2025 21:16
Copy link
Member

@alexrashed alexrashed left a 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! 💯

@vittoriopolverino vittoriopolverino merged commit 5b623bf into master Jun 11, 2025
40 checks passed
@vittoriopolverino vittoriopolverino deleted the DAT-159-refactor-metrics-instrumentation-framework-typing-and-structure branch June 11, 2025 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants