@Test(dependsOnMethods = "testChildContext") public void testContextAwareHistogram() { ContextAwareHistogram jobRecordSizeDist = this.context.contextAwareHistogram(RECORD_SIZE_DISTRIBUTION); Assert.assertEquals( this.context.getHistograms().get( jobRecordSizeDist.getName()), jobRecordSizeDist.getInnerMetric()); Assert.assertEquals(jobRecordSizeDist.getContext(), this.context); Assert.assertEquals(jobRecordSizeDist.getName(), RECORD_SIZE_DISTRIBUTION); jobRecordSizeDist.update(2); jobRecordSizeDist.update(4); jobRecordSizeDist.update(7); Assert.assertEquals(jobRecordSizeDist.getCount(), 3l); Assert.assertEquals(jobRecordSizeDist.getSnapshot().getMin(), 2l); Assert.assertEquals(jobRecordSizeDist.getSnapshot().getMax(), 7l); ContextAwareHistogram taskRecordSizeDist = this.childContext.contextAwareHistogram(RECORD_SIZE_DISTRIBUTION); Assert.assertEquals(this.childContext.getHistograms().get(taskRecordSizeDist.getName()), taskRecordSizeDist.getInnerMetric()); Assert.assertEquals(taskRecordSizeDist.getContext(), this.childContext); Assert.assertEquals(taskRecordSizeDist.getName(), RECORD_SIZE_DISTRIBUTION); taskRecordSizeDist.update(3); taskRecordSizeDist.update(14); taskRecordSizeDist.update(11); Assert.assertEquals(taskRecordSizeDist.getCount(), 3l); Assert.assertEquals(taskRecordSizeDist.getSnapshot().getMin(), 3l); Assert.assertEquals(taskRecordSizeDist.getSnapshot().getMax(), 14l); Assert.assertEquals(jobRecordSizeDist.getCount(), 6l); Assert.assertEquals(jobRecordSizeDist.getSnapshot().getMin(), 2l); Assert.assertEquals(jobRecordSizeDist.getSnapshot().getMax(), 14l); }
public ContextAwareHistogram contextAwareHistogram(String name) { return this.innerMetricContext.getOrCreate(name, ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_HISTOGRAM_FACTORY); }
MetricContext extends MetricRegistry implements ReportableContext, Closeable { public ContextAwareHistogram contextAwareHistogram(String name) { return this.innerMetricContext.getOrCreate(name, ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_HISTOGRAM_FACTORY); } }
MetricContext extends MetricRegistry implements ReportableContext, Closeable { public ContextAwareHistogram contextAwareHistogram(String name) { return this.innerMetricContext.getOrCreate(name, ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_HISTOGRAM_FACTORY); } protected  MetricContext(String name, MetricContext parent, List<Tag<?>> tags, boolean isRoot); }
MetricContext extends MetricRegistry implements ReportableContext, Closeable { public ContextAwareHistogram contextAwareHistogram(String name) { return this.innerMetricContext.getOrCreate(name, ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_HISTOGRAM_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 ContextAwareHistogram contextAwareHistogram(String name) { return this.innerMetricContext.getOrCreate(name, ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_HISTOGRAM_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; }