/** * * Return an existing meter if * (a) A meter already exist with the same metric name. * Otherwise, creates a new meter and registers * * @param registry MetricsRegistry * @param name metric name * @param eventType Event Type * @param unit TimeUnit for rate determination * @return Meter */ public static Meter newMeter(MetricsRegistry registry, MetricName name, String eventType, TimeUnit unit) { if (registry != null) { return registry.newMeter(name, eventType, unit); } else { return Metrics.newMeter(name, eventType, unit); } }
public InstrumentedAppender(MetricsRegistry registry) { super(); this.all = registry.newMeter(Appender.class, "all", "statements", TimeUnit.SECONDS); this.trace = registry.newMeter(Appender.class, "trace", "statements", TimeUnit.SECONDS); this.debug = registry.newMeter(Appender.class, "debug", "statements", TimeUnit.SECONDS); this.info = registry.newMeter(Appender.class, "info", "statements", TimeUnit.SECONDS); this.warn = registry.newMeter(Appender.class, "warn", "statements", TimeUnit.SECONDS); this.error = registry.newMeter(Appender.class, "error", "statements", TimeUnit.SECONDS); this.fatal = registry.newMeter(Appender.class, "fatal", "statements", TimeUnit.SECONDS); }
public InstrumentedAppender(MetricsRegistry registry) { this.all = registry.newMeter(Appender.class, "all", "statements", TimeUnit.SECONDS); this.trace = registry.newMeter(Appender.class, "trace", "statements", TimeUnit.SECONDS); this.debug = registry.newMeter(Appender.class, "debug", "statements", TimeUnit.SECONDS); this.info = registry.newMeter(Appender.class, "info", "statements", TimeUnit.SECONDS); this.warn = registry.newMeter(Appender.class, "warn", "statements", TimeUnit.SECONDS); this.error = registry.newMeter(Appender.class, "error", "statements", TimeUnit.SECONDS); }
/** * Creates a new {@link Meter} 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 eventType the plural name of the type of events the meter is measuring (e.g., {@code * "requests"}) * @param unit the rate unit of the new meter * @return a new {@link Meter} */ public Meter newMeter(Class<?> klass, String name, String eventType, TimeUnit unit) { return newMeter(klass, name, null, eventType, unit); }
/** * Creates a new {@link com.yammer.metrics.core.Meter} and registers it under the given metric * name. * * @param metricName the name of the metric * @param eventType the plural name of the type of events the meter is measuring (e.g., {@code * "requests"}) * @param unit the rate unit of the new meter * @return a new {@link com.yammer.metrics.core.Meter} */ public static Meter newMeter(MetricName metricName, String eventType, TimeUnit unit) { return DEFAULT_REGISTRY.newMeter(metricName, eventType, unit); }
/** * Creates a new {@link com.yammer.metrics.core.Meter} 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 eventType the plural name of the type of events the meter is measuring (e.g., {@code * "requests"}) * @param unit the rate unit of the new meter * @return a new {@link com.yammer.metrics.core.Meter} */ public static Meter newMeter(Class<?> klass, String name, String eventType, TimeUnit unit) { return DEFAULT_REGISTRY.newMeter(klass, name, eventType, unit); }
/** * Creates a new {@link com.yammer.metrics.core.Meter} 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 eventType the plural name of the type of events the meter is measuring (e.g., {@code * "requests"}) * @param unit the rate unit of the new meter * @return a new {@link com.yammer.metrics.core.Meter} */ public static Meter newMeter(Class<?> klass, String name, String scope, String eventType, TimeUnit unit) { return DEFAULT_REGISTRY.newMeter(klass, name, scope, eventType, unit); }
/** * Creates a new {@link com.yammer.metrics.core.Meter} and registers it under * the given group and name. * * @param name the name of the metric * @param eventType the plural name of the type of events the meter is * measuring (e.g., {@code "requests"}) * @param timeUnit the rate unit of the new meter * @return a new {@link com.yammer.metrics.core.Meter} */ public Meter getMeter(String name, String eventType, TimeUnit timeUnit) { return registry.newMeter(makeMetricName(name), eventType, timeUnit); }
/** * Creates a new {@link Meter} 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 eventType the plural name of the type of events the meter is measuring (e.g., {@code * "requests"}) * @param unit the rate unit of the new meter * @return a new {@link Meter} */ public Meter newMeter(Class<?> klass, String name, String scope, String eventType, TimeUnit unit) { return newMeter(createName(klass, name, scope), eventType, unit); }
public static MethodInterceptor forMethod(MetricsRegistry metricsRegistry, Class<?> klass, Method method) { final Metered annotation = method.getAnnotation(Metered.class); if (annotation != null) { final String name = annotation.name().isEmpty() ? method.getName() : annotation.name(); final MeterMetric meter = metricsRegistry.newMeter(klass, name, annotation.eventType(), annotation.rateUnit()); return new MeteredInterceptor(meter); } return null; }
@Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { final Metered metered = method.getAnnotation(Metered.class); final String group = MetricName.chooseGroup(metered.group(), targetClass); final String type = MetricName.chooseType(metered.type(), targetClass); final String name = MetricName.chooseName(metered.name(), method); final MetricName metricName = new MetricName(group, type, name, scope); final Meter meter = metrics.newMeter(metricName, metered.eventType(), metered.rateUnit()); meters.put(method.getName(), meter); if (log.isDebugEnabled()) { log.debug("Created metric " + metricName + " for method " + method.getName()); } }
/** * Create a new {@link EventRateMonitor} that is backed by a {@code Yammer} * {@link Meter}. * @see MonitorRegistry#newEventRateMonitor(MonitorName, * TimeUnit) */ @Override public EventRateMonitor newEventRateMonitor(final MonitorName monitorName, final TimeUnit rateUnit) { final Meter meter = delegate.newMeter(Utils.toMetricName(monitorName), monitorName.getName(), rateUnit); return new YammerEventRateMonitor(meter); }
public static MethodInterceptor forMethod(MetricsRegistry metricsRegistry, Class<?> klass, Method method) { final ExceptionMetered annotation = method.getAnnotation(ExceptionMetered.class); if (annotation != null) { final String name = determineName(annotation, method); final MeterMetric meter = metricsRegistry.newMeter(klass, name, annotation.eventType(), annotation.rateUnit()); return new ExceptionMeteredInterceptor(meter, annotation.cause()); } return null; }
@Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { final ExceptionMetered metered = method.getAnnotation(ExceptionMetered.class); final String methodName = method.getName(); final String group = MetricName.chooseGroup(metered.group(), targetClass); final String type = MetricName.chooseType(metered.type(), targetClass); final String name = metered.name() == null || metered.name().equals("") ? methodName + ExceptionMetered.DEFAULT_NAME_SUFFIX : metered.name(); final MetricName metricName = new MetricName(group, type, name, scope); final Meter meter = metrics.newMeter(metricName, metered.eventType(), metered.rateUnit()); meters.put(methodName, meter); causes.put(methodName, metered.cause()); if (log.isDebugEnabled()) { log.debug("Created metric " + metricName + " for method " + methodName); } }
public YammerMetrics(final MetricsRegistry registry) { this.gets = registry.newTimer(name("get", "requests"), SECONDS, SECONDS); this.getSuccesses = registry.newMeter(name("get", "successes"), "Successes", SECONDS); this.getHits = registry.newMeter(name("get", "hits"), "Hits", SECONDS); this.getMisses = registry.newMeter(name("get", "misses"), "Misses", SECONDS); this.getFailures = registry.newMeter(name("get", "failures"), "Failures", SECONDS); this.multigetSuccesses = registry.newMeter(name("multiget", "successes"), "Successes", SECONDS); this.multigetFailures = registry.newMeter(name("multiget", "failures"), "Failures", SECONDS); this.setSuccesses = registry.newMeter(name("set", "successes"), "Successes", SECONDS); this.setFailures = registry.newMeter(name("set", "failures"), "Failures", SECONDS); this.deleteSuccesses = registry.newMeter(name("delete", "successes"), "Successes", SECONDS); this.deleteFailures = registry.newMeter(name("delete", "failures"), "Failures", SECONDS); this.incrDecrSuccesses = registry.newMeter(name("incrdecr", "successes"), "Successes", SECONDS); this.incrDecrFailures = registry.newMeter(name("incrdecr", "failures"), "Failures", SECONDS); this.touchSuccesses = registry.newMeter(name("touch", "successes"), "Successes", SECONDS); this.touchFailures = registry.newMeter(name("touch", "failures"), "Failures", SECONDS);
static MethodInterceptor forMethod(MetricsRegistry metricsRegistry, Class<?> klass, Method method) { final ExceptionMetered annotation = method.getAnnotation(ExceptionMetered.class); if (annotation != null) { final String group = MetricName.chooseGroup(annotation.group(), klass); final String type = MetricName.chooseType(annotation.type(), klass); final String name = determineName(annotation, method); final MetricName metricName = new MetricName(group, type, name); final Meter meter = metricsRegistry.newMeter(metricName, annotation.eventType(), annotation.rateUnit()); return new ExceptionMeteredInterceptor(meter, annotation.cause()); } return null; }
static MethodInterceptor forMethod(MetricsRegistry metricsRegistry, Class<?> klass, Method method) { final Metered annotation = method.getAnnotation(Metered.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 Meter meter = metricsRegistry.newMeter(metricName, annotation.eventType(), annotation.rateUnit()); return new MeteredInterceptor(meter); } return null; }