/** * * Return an existing counter if * (a) A counter already exist with the same metric name. * Otherwise, creates a new meter and registers * * @param registry MetricsRegistry * @param name metric name * @return Counter */ public static Counter newCounter(MetricsRegistry registry, MetricName name) { if (registry != null) { return registry.newCounter(name); } else { return Metrics.newCounter(name); } }
/** * Creates a new {@link com.yammer.metrics.core.Counter} and registers it under the given class * and name. * * @param klass the class which owns the metric * @param name the name of the metric * @return a new {@link com.yammer.metrics.core.Counter} */ public static Counter newCounter(Class<?> klass, String name) { return DEFAULT_REGISTRY.newCounter(klass, name); }
/** * Creates a new {@link com.yammer.metrics.core.Counter} and registers it under the given metric * name. * * @param metricName the name of the metric * @return a new {@link com.yammer.metrics.core.Counter} */ public static Counter newCounter(MetricName metricName) { return DEFAULT_REGISTRY.newCounter(metricName); }
/** * Creates a new {@link Counter} and registers it under the given class and name. * * @param klass the class which owns the metric * @param name the name of the metric * @return a new {@link Counter} */ public Counter newCounter(Class<?> klass, String name) { return newCounter(klass, name, null); }
/** * Creates a new {@link com.yammer.metrics.core.Counter} 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 scope the scope of the metric * @return a new {@link com.yammer.metrics.core.Counter} */ public static Counter newCounter(Class<?> klass, String name, String scope) { return DEFAULT_REGISTRY.newCounter(klass, name, scope); }
public RunnerStats(MetricsRegistry registry) { this.normalRunners = registry.newCounter(MetricsConnection.class, "normalRunnersCount"); this.delayRunners = registry.newCounter(MetricsConnection.class, "delayRunnersCount"); this.delayIntevalHist = registry.newHistogram(MetricsConnection.class, "delayIntervalHist"); }
/** * Creates a new {@link Counter} 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 scope the scope of the metric * @return a new {@link Counter} */ public Counter newCounter(Class<?> klass, String name, String scope) { return newCounter(createName(klass, name, scope)); }
/** * Creates a new {@link com.yammer.metrics.core.Counter} and registers it * under the given group and name. * * @param name the name of the metric * @return a new {@link com.yammer.metrics.core.Counter} */ public Counter getCounter(String name) { return registry.newCounter(makeMetricName(name)); }
/** * Create a new {@link CounterMonitor} that is backed by a {@code Yammer} * {@link Counter}. * @see MonitorRegistry#newCounterMonitor(MonitorName) */ @Override public CounterMonitor newCounterMonitor(MonitorName monitorName) { final Counter counter = delegate.newCounter(Utils.toMetricName(monitorName)); return new YammerCounterMonitor(counter); }
final Counter counter = _metricsRegistry.newCounter(YammerMetricsSink.class, entry.getKey()); for (final Quantity sample : entry.getValue()) { counter.inc(sample.getValue().longValue());
public static void main(String[] args) throws IOException, InterruptedException { // Parse inputs. System.out.println("Args: " + Joiner.on(", ").join(args)); if (args.length != 2) { System.out.println("Usage: java -jar this.jar <metricsPort> <histogramsPort>"); return; } int port = Integer.parseInt(args[0]); int histoPort = Integer.parseInt(args[1]); // Set up periodic reporting. MetricsRegistry metricsRegistry = new MetricsRegistry(); WavefrontYammerMetricsReporter wavefrontYammerMetricsReporter = new WavefrontYammerMetricsReporter(metricsRegistry, "wavefrontYammerMetrics", "localhost", port, histoPort, System::currentTimeMillis); wavefrontYammerMetricsReporter.start(5, TimeUnit.SECONDS); // Populate test metrics. Counter counter = metricsRegistry.newCounter(new TaggedMetricName("group", "mycounter", "tag1", "value1")); Histogram histogram = metricsRegistry.newHistogram(new TaggedMetricName("group2", "myhisto"), false); WavefrontHistogram wavefrontHistogram = WavefrontHistogram.get(metricsRegistry, new TaggedMetricName("group", "mywavefronthisto", "tag2", "value2")); while (true) { counter.inc(); histogram.update(counter.count()); wavefrontHistogram.update(counter.count()); Thread.sleep(1000); } }
this.metaCacheHits = registry.newCounter(this.getClass(), "metaCacheHits", scope); this.metaCacheMisses = registry.newCounter(this.getClass(), "metaCacheMisses", scope); this.getTracker = new CallTracker(this.registry, "Get", scope); this.scanTracker = new CallTracker(this.registry, "Scan", scope);