Skip to content

Instantly share code, notes, and snippets.

@splatch
Created Jul 17, 2015
Embed
What would you like to do?
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