@Test(dependsOnMethods = "testChildContext") public void testContextAwareCounter() { ContextAwareCounter jobRecordsProcessed = this.context.contextAwareCounter(RECORDS_PROCESSED); Assert.assertEquals(this.context.getCounters().get(jobRecordsProcessed.getName()), jobRecordsProcessed.getInnerMetric()); Assert.assertEquals(jobRecordsProcessed.getContext(), this.context); Assert.assertEquals(jobRecordsProcessed.getName(), RECORDS_PROCESSED); jobRecordsProcessed.inc(); Assert.assertEquals(jobRecordsProcessed.getCount(), 1l); jobRecordsProcessed.inc(5); Assert.assertEquals(jobRecordsProcessed.getCount(), 6l); jobRecordsProcessed.dec(); Assert.assertEquals(jobRecordsProcessed.getCount(), 5l); jobRecordsProcessed.dec(3); Assert.assertEquals(jobRecordsProcessed.getCount(), 2l); ContextAwareCounter taskRecordsProcessed = this.childContext.contextAwareCounter(RECORDS_PROCESSED); Assert.assertEquals(this.childContext.getCounters() .get(taskRecordsProcessed.getName()), taskRecordsProcessed.getInnerMetric()); Assert.assertEquals(taskRecordsProcessed.getContext(), this.childContext); Assert.assertEquals(taskRecordsProcessed.getName(), RECORDS_PROCESSED); taskRecordsProcessed.inc(); Assert.assertEquals(taskRecordsProcessed.getCount(), 1l); Assert.assertEquals(jobRecordsProcessed.getCount(), 3l); taskRecordsProcessed.inc(3); Assert.assertEquals(taskRecordsProcessed.getCount(), 4l); Assert.assertEquals(jobRecordsProcessed.getCount(), 6l); taskRecordsProcessed.dec(4); Assert.assertEquals(taskRecordsProcessed.getCount(), 0l); Assert.assertEquals(jobRecordsProcessed.getCount(), 2l); }
public ContextAwareCounter contextAwareCounter(String name) { return contextAwareCounter(name, ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_COUNTER_FACTORY); }
MetricContext extends MetricRegistry implements ReportableContext, Closeable { public ContextAwareCounter contextAwareCounter(String name) { return contextAwareCounter(name, ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_COUNTER_FACTORY); } }
MetricContext extends MetricRegistry implements ReportableContext, Closeable { public ContextAwareCounter contextAwareCounter(String name) { return contextAwareCounter(name, ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_COUNTER_FACTORY); } protected  MetricContext(String name, MetricContext parent, List<Tag<?>> tags, boolean isRoot); }
MetricContext extends MetricRegistry implements ReportableContext, Closeable { public ContextAwareCounter contextAwareCounter(String name) { return contextAwareCounter(name, ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_COUNTER_FACTORY); } protected  MetricContext(String name, MetricContext parent, List<Tag<?>> tags, boolean isRoot); String getName(); Optional<MetricContext> getParent(); Map<String, MetricContext> getChildContextsAsMap(); @Override SortedSet<String> getNames(); void submitEvent(GobblinTrackingEvent nonReusableEvent); @Override Map<String, Metric> getMetrics(); @Override SortedMap<String, Gauge> getGauges(); @Override SortedMap<String, Gauge> getGauges(MetricFilter filter); @Override SortedMap<String, Counter> getCounters(); @Override SortedMap<String, Counter> getCounters(MetricFilter filter); @Override SortedMap<String, Histogram> getHistograms(); @Override SortedMap<String, Histogram> getHistograms(MetricFilter filter); @Override SortedMap<String, Meter> getMeters(); @Override SortedMap<String, Meter> getMeters(MetricFilter filter); @Override SortedMap<String, Timer> getTimers(); @Override SortedMap<String, Timer> getTimers(MetricFilter filter); @Override Counter counter(String name); @Override Meter meter(String name); @Override Histogram histogram(String name); @Override ContextAwareTimer timer(String name); @Override synchronized T register(String name, T metric); T register(T metric); ContextAwareCounter contextAwareCounter(String name); ContextAwareCounter contextAwareCounter(String name, ContextAwareMetricFactory<ContextAwareCounter> factory); ContextAwareMeter contextAwareMeter(String name); ContextAwareMeter contextAwareMeter(String name, ContextAwareMetricFactory<ContextAwareMeter> factory); ContextAwareHistogram contextAwareHistogram(String name); ContextAwareHistogram contextAwareHistogram(String name, long windowSize, TimeUnit unit); ContextAwareTimer contextAwareTimer(String name); ContextAwareTimer contextAwareTimer(String name, long windowSize, TimeUnit unit); ContextAwareGauge<T> newContextAwareGauge(String name, Gauge<T> gauge); @Override synchronized boolean remove(String name); @Override void removeMatching(MetricFilter filter); List<Tag<?>> getTags(); Map<String, Object> getTagMap(); @Override void close(); Builder childBuilder(String name); static Builder builder(String name); UUID addNotificationTarget(Function<Notification, Void> target); void removeNotificationTarget(UUID key); void sendNotification(final Notification notification); }
MetricContext extends MetricRegistry implements ReportableContext, Closeable { public ContextAwareCounter contextAwareCounter(String name) { return contextAwareCounter(name, ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_COUNTER_FACTORY); } protected  MetricContext(String name, MetricContext parent, List<Tag<?>> tags, boolean isRoot); String getName(); Optional<MetricContext> getParent(); Map<String, MetricContext> getChildContextsAsMap(); @Override SortedSet<String> getNames(); void submitEvent(GobblinTrackingEvent nonReusableEvent); @Override Map<String, Metric> getMetrics(); @Override SortedMap<String, Gauge> getGauges(); @Override SortedMap<String, Gauge> getGauges(MetricFilter filter); @Override SortedMap<String, Counter> getCounters(); @Override SortedMap<String, Counter> getCounters(MetricFilter filter); @Override SortedMap<String, Histogram> getHistograms(); @Override SortedMap<String, Histogram> getHistograms(MetricFilter filter); @Override SortedMap<String, Meter> getMeters(); @Override SortedMap<String, Meter> getMeters(MetricFilter filter); @Override SortedMap<String, Timer> getTimers(); @Override SortedMap<String, Timer> getTimers(MetricFilter filter); @Override Counter counter(String name); @Override Meter meter(String name); @Override Histogram histogram(String name); @Override ContextAwareTimer timer(String name); @Override synchronized T register(String name, T metric); T register(T metric); ContextAwareCounter contextAwareCounter(String name); ContextAwareCounter contextAwareCounter(String name, ContextAwareMetricFactory<ContextAwareCounter> factory); ContextAwareMeter contextAwareMeter(String name); ContextAwareMeter contextAwareMeter(String name, ContextAwareMetricFactory<ContextAwareMeter> factory); ContextAwareHistogram contextAwareHistogram(String name); ContextAwareHistogram contextAwareHistogram(String name, long windowSize, TimeUnit unit); ContextAwareTimer contextAwareTimer(String name); ContextAwareTimer contextAwareTimer(String name, long windowSize, TimeUnit unit); ContextAwareGauge<T> newContextAwareGauge(String name, Gauge<T> gauge); @Override synchronized boolean remove(String name); @Override void removeMatching(MetricFilter filter); List<Tag<?>> getTags(); Map<String, Object> getTagMap(); @Override void close(); Builder childBuilder(String name); static Builder builder(String name); UUID addNotificationTarget(Function<Notification, Void> target); void removeNotificationTarget(UUID key); void sendNotification(final Notification notification); static final String METRIC_CONTEXT_ID_TAG_NAME; static final String METRIC_CONTEXT_NAME_TAG_NAME; static final String GOBBLIN_METRICS_NOTIFICATIONS_TIMER_NAME; }