8000 refactor: metrics instrumentation framework typing and structure by vittoriopolverino · Pull Request #12717 · localstack/localstack · GitHub
[go: up one dir, main page]

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

vittoriopolverino
Copy link
Member
@vittoriopolverino vittoriopolverino commented Jun 5, 2025

Motivation

follow-up to PR #12386

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

  • introduce schema versioning for metrics

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 595 tests  ±0   19 940 ✅ ±0   6m 16s ⏱️ -5s
     1 suites ±0    1 655 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit e3bd187. ± Comparison against base commit 6487dbf.

♻️ This comment has been updated with latest results.



@dataclass(frozen=True)
class LabeledCounterPayload:
Copy link
Member Author
@vittoriopolverino vittoriopolverino Jun 5, 2025

Choose a reason for hiding this comment

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

note: LabeledCounter has its own payload as it's diverging from the base Counter (e.g. it includes labels, which the base does not). Also, once schema versioning is introduced, it will likely apply only to LabeledCounter, as the base Counter payload should remain stable and not require schema changes (still TBD)

@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 41m 5s ⏱️ - 3m 7s
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 e3bd187. ± Comparison against base commit 6487dbf.

♻️ 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 12s ⏱️ +6s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit e3bd187. ± Comparison against base commit 6487dbf.

♻️ 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 10s ⏱️
  4 suites  403 💤
  4 files      0 ❌

Results for commit e3bd187.

♻️ 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 21m 36s ⏱️
5 229 tests 4 300 ✅ 929 💤 0 ❌
5 235 runs  4 300 ✅ 935 💤 0 ❌

Results for commit e3bd187.

♻️ 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
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.

2 participants
0