Guest User

Untitled

a guest
Oct 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. // inject this
  2. private final MetricFactory metricFactory;
  3.  
  4. public MyBean(final MetricFactory metricFactory) {
  5. this.metricFactory = metricFactory;
  6. }
  7.  
  8. // Use the factory to create metrics objects like Timer or Counter:
  9.  
  10. final Timer timer = metricFactory.createTimer(componentName, methodName);
  11. final TimerContext timerContext = timer.time();
  12.  
  13. try{
  14. // do some stuff
  15. finally {
  16. timerContext.stop();
  17. }
Add Comment
Please, Sign In to add comment