/** * * Return an existing timer if * (a) A timer already exist with the same metric name. * Otherwise, creates a new timer and registers * * @param registry MetricsRegistry * @param name metric name * @param durationUnit TimeUnit for duration * @param rateUnit TimeUnit for rate determination * @return Timer */ public static Timer newTimer(MetricsRegistry registry, MetricName name, TimeUnit durationUnit, TimeUnit rateUnit) { if (registry != null) { return registry.newTimer(name, durationUnit, rateUnit); } else { return Metrics.newTimer(name, durationUnit, rateUnit); } }
@Override public Object start(final String tagName) { final Timer timer = metricsRegistry.newTimer(new MetricName(clusterName, TIMER_TYPE, tagName), durationUnit, rateUnit); return timer.time(); }
/** * Creates a new {@link Timer} and registers it under the given class and name, measuring * elapsed time in milliseconds and invocations per second. * * @param klass the class which owns the metric * @param name the name of the metric * @return a new {@link Timer} */ public Timer newTimer(Class<?> klass, String name) { return newTimer(klass, name, null, TimeUnit.MILLISECONDS, TimeUnit.SECONDS); }
/** * Creates a new {@link com.yammer.metrics.core.Timer} and registers it under the given class * and name, measuring elapsed time in milliseconds and invocations per second. * * @param klass the class which owns the metric * @param name the name of the metric * @return a new {@link com.yammer.metrics.core.Timer} */ public static Timer newTimer(Class<?> klass, String name) { return DEFAULT_REGISTRY.newTimer(klass, name); }
@Override public Timer newMetric(Class<?> clazz, String name, String scope) { return registry.newTimer(clazz, name, scope); } };
/** * Creates a new {@link Timer} and registers it under the given class and name. * * @param klass the class which owns the metric * @param name the name of the metric * @param durationUnit the duration scale unit of the new timer * @param rateUnit the rate scale unit of the new timer * @return a new {@link Timer} */ public Timer newTimer(Class<?> klass, String name, TimeUnit durationUnit, TimeUnit rateUnit) { return newTimer(klass, name, null, durationUnit, rateUnit); }
/** * Creates a new {@link Timer} and registers it under the given class, name, and scope, * measuring elapsed time in milliseconds and invocations per second. * * @param klass the class which owns the metric * @param name the name of the metric * @param scope the scope of the metric * @return a new {@link Timer} */ public Timer newTimer(Class<?> klass, String name, String scope) { return newTimer(klass, name, scope, TimeUnit.MILLISECONDS, TimeUnit.SECONDS); }
/** * Creates a new {@link com.yammer.metrics.core.Timer} and registers it under the given class, * name, and scope, measuring elapsed time in milliseconds and invocations per second. * * @param klass the class which owns the metric * @param name the name of the metric * @param scope the scope of the metric * @return a new {@link com.yammer.metrics.core.Timer} */ public static Timer newTimer(Class<?> klass, String name, String scope) { return DEFAULT_REGISTRY.newTimer(klass, name, scope); }
/** * Creates a new {@link com.yammer.metrics.core.Timer} and registers it under the given metric * name. * * @param metricName the name of the metric * @param durationUnit the duration scale unit of the new timer * @param rateUnit the rate scale unit of the new timer * @return a new {@link com.yammer.metrics.core.Timer} */ public static Timer newTimer(MetricName metricName, TimeUnit durationUnit, TimeUnit rateUnit) { return DEFAULT_REGISTRY.newTimer(metricName, durationUnit, rateUnit); }
/** * Creates a new {@link com.yammer.metrics.core.Timer} and registers it under the given class * and name. * * @param klass the class which owns the metric * @param name the name of the metric * @param durationUnit the duration scale unit of the new timer * @param rateUnit the rate scale unit of the new timer * @return a new {@link com.yammer.metrics.core.Timer} */ public static Timer newTimer(Class<?> klass, String name, TimeUnit durationUnit, TimeUnit rateUnit) { return DEFAULT_REGISTRY.newTimer(klass, name, durationUnit, rateUnit); }
/** * Creates a new {@link com.yammer.metrics.core.Timer} and registers it under the given class, * name, and scope. * * @param klass the class which owns the metric * @param name the name of the metric * @param scope the scope of the metric * @param durationUnit the duration scale unit of the new timer * @param rateUnit the rate scale unit of the new timer * @return a new {@link com.yammer.metrics.core.Timer} */ public static Timer newTimer(Class<?> klass, String name, String scope, TimeUnit durationUnit, TimeUnit rateUnit) { return DEFAULT_REGISTRY.newTimer(klass, name, scope, durationUnit, rateUnit); }
/** * Creates a new {@link Timer} and registers it under the given * group and name. * * @param name the name of the metric * @param durationUnit the duration scale unit of the new timer * @param rateUnit the rate scale unit of the new timer * @return a new {@link Timer} */ public Timer getTimer(String name, TimeUnit durationUnit, TimeUnit rateUnit) { return registry.newTimer(makeMetricName(name), durationUnit, rateUnit); }
private Timer getTimer(StatementContext ctx) { return registry.newTimer(statementNameStrategy.getStatementName(ctx), durationUnit, rateUnit); } }
private CallTracker(MetricsRegistry registry, String name, String subName, String scope) { StringBuilder sb = new StringBuilder(CLIENT_SVC).append("_").append(name); if (subName != null) { sb.append("(").append(subName).append(")"); } this.name = sb.toString(); this.callTimer = registry.newTimer(MetricsConnection.class, DRTN_BASE + this.name, scope); this.reqHist = registry.newHistogram(MetricsConnection.class, REQ_BASE + this.name, scope); this.respHist = registry.newHistogram(MetricsConnection.class, RESP_BASE + this.name, scope); }
protected View(String templateName, Charset charset) { this.templateName = resolveName(templateName); this.charset = charset; this.renderingTimer = Metrics.defaultRegistry().newTimer(getClass(), "rendering"); }
@Override public Object start(final String tagName) { final Timer timer = metricsRegistry.newTimer(new MetricName(clusterName, TIMER_TYPE, tagName), durationUnit, rateUnit); return timer.time(); }
public static MethodInterceptor forMethod(MetricsRegistry metricsRegistry, Class<?> klass, Method method) { final Timed annotation = method.getAnnotation(Timed.class); if (annotation != null) { final String name = annotation.name().isEmpty() ? method.getName() : annotation.name(); final TimerMetric timer = metricsRegistry.newTimer(klass, name, annotation.durationUnit(), annotation.rateUnit()); return new TimedInterceptor(timer); } return null; }
@Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { final Timed timed = method.getAnnotation(Timed.class); final String group = MetricName.chooseGroup(timed.group(), targetClass); final String type = MetricName.chooseType(timed.type(), targetClass); final String name = MetricName.chooseName(timed.name(), method); final MetricName metricName = new MetricName(group, type, name, scope); final Timer timer = metrics.newTimer(metricName, timed.durationUnit(), timed.rateUnit()); timers.put(method.getName(), timer); if (log.isDebugEnabled()) { log.debug("Created metric " + metricName + " for method " + method.getName()); } }
@Override public void collect(long elapsedTime, StatementContext ctx) { StatementName statementName = jdbiGroupStrategy.getStatementName(ctx); TimerMetric timer = metricsRegistry.newTimer(new MetricName(statementName.getGroupName(), statementName.getTypeName(), statementName.getStatementName()), durationUnit, rateUnit); timer.update(elapsedTime, TimeUnit.NANOSECONDS); } }
static MethodInterceptor forMethod(MetricsRegistry metricsRegistry, Class<?> klass, Method method) { final Timed annotation = method.getAnnotation(Timed.class); if (annotation != null) { final String group = MetricName.chooseGroup(annotation.group(), klass); final String type = MetricName.chooseType(annotation.type(), klass); final String name = MetricName.chooseName(annotation.name(), method); final MetricName metricName = new MetricName(group, type, name); final Timer timer = metricsRegistry.newTimer(metricName, annotation.durationUnit(), annotation.rateUnit()); return new TimedInterceptor(timer); } return null; }