Skip to content
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

Adding NullStatsReporter and TestScope #69

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

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.

Duration interval,
Thread.UncaughtExceptionHandler uncaughtExceptionHandler
) {
if (reporter instanceof NullStatsReporter) {
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