Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // inject this
- private final MetricFactory metricFactory;
- public MyBean(final MetricFactory metricFactory) {
- this.metricFactory = metricFactory;
- }
- // Use the factory to create metrics objects like Timer or Counter:
- final Timer timer = metricFactory.createTimer(componentName, methodName);
- final TimerContext timerContext = timer.time();
- try{
- // do some stuff
- finally {
- timerContext.stop();
- }
Add Comment
Please, Sign In to add comment