Improve components that are used to unit test instrumentation logic #129
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.
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 ofTestScope
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 previousTimerImpl
implementation relied onNoReporterSink
to properly createTimerSnapshot
s. However givenTestScope
instances are built withNullStatsReporter
,TimerSnapshots
were not being created at all when usingTestScope
.Leveraged the
ImmutableBuckets
implementation to compute bucket bounds inHistogramImpl
, 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
.