8000 Improve components that are used to unit test instrumentation logic by trein · Pull Request #129 · uber-java/tally · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@trein
Copy link
Contributor
@trein trein commented Nov 22, 2024

Several improvements are suggested in this PR:

  • Introduced a new abstraction so that developers can manipulate time in tests. The MonotonicClock interface offers an abstraction for us to manipulate time in test. It aims to improve the implementation of TestScope so that developers can verify metric recording of timers and histograms.

  • Refactored how snapshots are created to leverage the same reporting mechanism used in regular metrics recording.

  • Fixed snapshots for Timers, which seem to be broken at HEAD. The previous TimerImpl implementation relied on NoReporterSink to properly create TimerSnapshots. However given TestScope instances are built with NullStatsReporter, TimerSnapshots were not being created at all when using TestScope.

  • Leveraged the ImmutableBuckets implementation to compute bucket bounds in HistogramImpl, allowing removal of a substantial amount of duplicated code.

  • Added unit tests to cover the fixes for TimerSnapshots as well as the changes to the snapshot logic.

The changes were structured in dependent but self-contained commits hoping to allow for easier code review. The lack of support for stacked PRs in Github made very difficult to create separate PRs for them.

The changes were tested according to instructions in DEVELOPMENT.md.

@CLAassistant
Copy link
CLAassistant commented Nov 22, 2024

CLA assistant check
All committers have signed the CLA.

 The `MonotonicClock` interface offers an abstraction for us to
 manipulate time in test. It aims to improve the implementation of
 `TestScope` so that develpers can verify metric recording of timers
 and histograms.
@trein trein force-pushed the testscope-timer-fix branch 4 times, most recently from 6821ff7 to 1cb7175 Compare November 23, 2024 13:58
The following changes have been made as part of this commit:

1. Refactored how snapshots are created to leverage the same reporting
   mechanism used in regular metrics recording.

2. Fixed snapshots for Timers. The previous `TimerImpl` implementation
   relied on `NoReporterSink` to properly create `TimerSnapshots`.
   However given `TestScope` instances are built with `NullStatsReporter`,
   `TimerSnapshots` were not being created at all when using `TestScope`.

3. Leveraged the `ImmutableBuckets` implementation to compute bucket bounds
   in `HistogramImpl`, allowing removal of a substantial amount of
   duplicated code.

4. Added unit tests to cover the fixes for `TimerSnapshots` as well as
   the changes to the snapshot creation logic.
No functionality change. Just removal of warnings in the code.
@trein trein force-pushed the testscope-timer-fix branch 2 times, most recently from c5b5e77 to f9fb566 Compare November 25, 2024 18:15
@justinjc justinjc merged commit 6bf67f9 into uber-java:master Dec 6, 2024
3 of 4 checks passed
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.

5 participants

0