Skip to content

Conversation

@ravirajj
Copy link

@ravirajj ravirajj commented May 3, 2020

  • Created NullStatsReporter to report no metrics when it is used by ScopeBuilder.
  • Created TestScope to snapshot metrics for tests.

Copy link

@inetchitailo inetchitailo May 4, 2020

Choose a reason for hiding this comment

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

I think you just need to add a single if statement:

if (!(reporter instanceof NullStatsReporter) {
 scheduler.scheduleWithFixedDelay(scope.new ReportLoop(uncaughtExceptionHandler), 0, interval.toMillis(), TimeUnit.MILLISECONDS); 
}

* TestScope is a metrics collector that has no reporting, ensuring that
* all emitted values have a given prefix or set of tags.
*/
interface TestScope extends Scope {
Copy link
Contributor

@guscastro guscastro Jan 18, 2023

Choose a reason for hiding this comment

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

This interface needs to be public, so that the Snapshot can be consumed externally.

@guscastro
Copy link
Contributor

How would TestScope be consumed? ScopeBuilder returns a Scope, which happens to be ScopeImpl at the moment. Is the plan for consumers to cast that to TestScope where needed? Should we have a separate ScopeBuilder that returns a TestScope explicitly? (maybe inheriting from RootScopeBuilder)

@zmanji zmanji mentioned this pull request Dec 18, 2023
SokolAndrey pushed a commit that referenced this pull request Dec 18, 2023
This commit plucks select changes from #69 and #43
to bring uber-java/tally on par with uber-go/tally.

It adds a `TestScope` class which allows users of the library to get a
`Snapshot` of all the metrics emitted by the scope. Users can then assert if
certain metrics were created.
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.

3 participants