Skip to content

Instantly share code, notes, and snippets.

@splatch
Created July 17, 2015 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save splatch/97445758438d92af8da8 to your computer and use it in GitHub Desktop.
Save splatch/97445758438d92af8da8 to your computer and use it in GitHub Desktop.
Gather metrics using codahale stuff
Counter failCounter = new Counter();
Counter successCounter = new Counter();
Timer timer = new Timer();
@Override
public Y transform(X x) {
Timer.Context time = timer.time();
try {
Y transform = delegate.transform(x);
successCounter.inc();
return transform;
} catch (Exception e) {
failCounter.inc();
throw e;
} finally {
time.stop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment