/** * * Return an existing gauge if * (a) A gauge already exist with the same metric name. * Otherwise, creates a new meter and registers * * @param registry MetricsRegistry * @param name metric name * @param gauge Underlying gauge to be tracked * @return gauge */ public static <T> Gauge<T> newGauge(MetricsRegistry registry, MetricName name, Gauge<T> gauge) { if (registry != null) { return registry.newGauge(name, gauge); } else { return Metrics.newGauge(name, gauge); } }
metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int32", "FlowFiles Received Last 5 mins"), new Gauge<Integer>() { @Override public Integer value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int64", "Bytes Received Last 5 mins"), new Gauge<Long>() { @Override public Long value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int32", "FlowFiles Sent Last 5 mins"), new Gauge<Integer>() { @Override public Integer value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int64", "Bytes Sent Last 5 mins"), new Gauge<Long>() { @Override public Long value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int32", "FlowFiles Queued"), new Gauge<Integer>() { @Override public Integer value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int64", "Bytes Queued"), new Gauge<Long>() { @Override public Long value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int64", "Bytes Read (5 mins)"), new Gauge<Long>() { @Override public Long value() { metricsRegistry.newGauge(new MetricName(METRICS_GROUP, "int64", "Bytes Written (5 mins)"), new Gauge<Long>() {
/** * Given a new {@link com.yammer.metrics.core.Gauge}, registers it under the given metric name. * * @param metricName the name of the metric * @param metric the metric * @param <T> the type of the value returned by the metric * @return {@code metric} */ public static <T> Gauge<T> newGauge(MetricName metricName, Gauge<T> metric) { return DEFAULT_REGISTRY.newGauge(metricName, metric); }
/** * Given a new {@link Gauge}, registers it under the given class and name. * * @param klass the class which owns the metric * @param name the name of the metric * @param metric the metric * @param <T> the type of the value returned by the metric * @return {@code metric} */ public <T> Gauge<T> newGauge(Class<?> klass, String name, Gauge<T> metric) { return newGauge(klass, name, null, metric); }
protected void createCumulativeCountForEvent(final String name, final HystrixRollingNumberEvent event) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Long>() { @Override public Long value() { return metrics.getCumulativeCount(event); } }); }
@Deprecated protected void createCumulativeCountForEvent(String name, final HystrixRollingNumberEvent event) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Long>() { @Override public Long value() { return metrics.getCumulativeCount(event); } }); }
@Deprecated protected void createRollingGauge(String name, final HystrixRollingNumberEvent event) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Long>() { @Override public Long value() { return metrics.getRollingCount(event); } }); }
protected void createExecutionLatencyPercentileGauge(final String name, final double percentile) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Integer>() { @Override public Integer value() { return metrics.getExecutionTimePercentile(percentile); } }); }
/** * Given a new {@link com.yammer.metrics.core.Gauge}, registers it under the * given group and name. * * @param name the name of the metric * @param metric the metric * @param <T> the type of the value returned by the metric * @return {@code metric} */ public <T> Gauge<T> getGauge(String name, Gauge<T> metric) { return registry.newGauge(makeMetricName(name), metric); }
protected void createRollingCountForEvent(final String name, final HystrixRollingNumberEvent event) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Long>() { @Override public Long value() { return metrics.getRollingCount(event); } }); }
protected void createRollingGauge(final String name, final HystrixEventType eventType) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Long>() { @Override public Long value() { return metrics.getRollingCount(HystrixRollingNumberEvent.from(eventType)); } }); }
protected void createTotalLatencyPercentileGauge(final String name, final double percentile) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Integer>() { @Override public Integer value() { return metrics.getTotalTimePercentile(percentile); } }); }
protected void createExecutionLatencyMeanGauge(final String name) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Integer>() { @Override public Integer value() { return metrics.getExecutionTimeMean(); } }); }
protected void createCurrentValueGauge(final String name, final Func0<Integer> metricToEvaluate) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Integer>() { @Override public Integer value() { return metricToEvaluate.call(); } }); } }
protected void createTotalLatencyMeanGauge(final String name) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Integer>() { @Override public Integer value() { return metrics.getTotalTimeMean(); } }); }
protected void createCumulativeGauge(final String name, final HystrixEventType eventType) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Long>() { @Override public Long value() { return metrics.getCumulativeCount(HystrixRollingNumberEvent.from(eventType)); } }); }
protected void safelyCreateCumulativeCountForEvent(final String name, final Func0<HystrixRollingNumberEvent> eventThunk) { metricsRegistry.newGauge(createMetricName(name), new Gauge<Long>() { @Override public Long value() { try { return metrics.getCumulativeCount(eventThunk.call()); } catch (NoSuchFieldError error) { logger.error("While publishing Yammer metrics, error looking up eventType for : {}. Please check that all Hystrix versions are the same!", name); return 0L; } } }); }
public Gauge getGauge(MetricName metricName, MetricMatcher metricMatcher) { metricNamesForMetricMatchers.get(metricMatcher).add(metricName); return (Gauge) metricCache.get( metricName, (key) -> metricsRegistry.newGauge(key, new ChangeableGauge<Double>())); }
public Gauge getGauge(MetricName metricName, MetricMatcher metricMatcher) { metricNamesForMetricMatchers.get(metricMatcher).add(metricName); return (Gauge) metricCache.get( metricName, (key) -> metricsRegistry.newGauge(key, new ChangeableGauge<Double>())); }
@Override public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { final Gauge gauge = field.getAnnotation(Gauge.class); final String group = MetricName.chooseGroup(gauge.group(), targetClass); final String type = MetricName.chooseType(gauge.type(), targetClass); final String name = gauge.name().isEmpty() ? field.getName() : gauge.name(); final MetricName metricName = new MetricName(group, type, name, scope); metrics.newGauge(metricName, new GaugeField(bean, field)); if (log.isDebugEnabled()) { log.debug("Created gauge " + metricName + " for field " + targetClass.getCanonicalName() + "." + field.getName()); } } }, filter);