/** * See {@link com.codahale.metrics.MetricRegistry#getCounters()}. * * <p> * This method will return fully-qualified metric names if the {@link MetricContext} is configured * to report fully-qualified metric names. * </p> */ @Override public SortedMap<String, Counter> getCounters() { return this.innerMetricContext.getCounters(MetricFilter.ALL); }
/** * See {@link com.codahale.metrics.MetricRegistry#getHistograms(com.codahale.metrics.MetricFilter)}. * * <p> * This method will return fully-qualified metric names if the {@link MetricContext} is configured * to report fully-qualified metric names. * </p> */ @Override public SortedMap<String, Histogram> getHistograms(MetricFilter filter) { return this.innerMetricContext.getHistograms(filter); }
/** * See {@link com.codahale.metrics.MetricRegistry#getMeters()}. * * <p> * This method will return fully-qualified metric names if the {@link MetricContext} is configured * to report fully-qualified metric names. * </p> */ @Override public SortedMap<String, Meter> getMeters() { return this.innerMetricContext.getMeters(MetricFilter.ALL); }
/** * Get a {@link ContextAwareTimer} with a given name and a customized {@link com.codahale.metrics.SlidingTimeWindowReservoir} * * @param name name of the {@link ContextAwareTimer} * @param windowSize normally the duration of the time window * @param unit the unit of time * @return the {@link ContextAwareTimer} with the given name */ public ContextAwareTimer contextAwareTimer(String name, long windowSize, TimeUnit unit) { ContextAwareMetricFactoryArgs.SlidingTimeWindowArgs args = new ContextAwareMetricFactoryArgs.SlidingTimeWindowArgs( this.innerMetricContext.getMetricContext().get(), name, windowSize, unit); return this.innerMetricContext.getOrCreate(ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_TIMER_FACTORY, args); }
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("InnerMetricContext Name: "); stringBuilder.append(this.name); if (this.getParent().isPresent()) { stringBuilder.append(", Parent Name: "); stringBuilder.append(this.getParent().get().getName()); } else { stringBuilder.append(", No Parent Context"); } stringBuilder.append(", Number of Children: "); stringBuilder.append(this.getChildContextsAsMap().size()); stringBuilder.append(", Tags: "); stringBuilder.append(Joiner.on(", ").withKeyValueSeparator(" : ").useForNull("NULL").join(this.getTagMap())); return stringBuilder.toString(); } }
Assert.assertEquals(innerMetricContextWeakReference.get().getCounters().size(), 2); Assert.assertEquals(innerMetricContextWeakReference.get().getMeters().size(), 1); Assert.assertEquals(innerMetricContextWeakReference.get().getTimers().size(), 2); Assert.assertEquals(innerMetricContextWeakReference.get().getHistograms().size(), 1); Assert.assertEquals(innerMetricContextWeakReference.get().getMeters().get("testMeter").getCount(), 1);
/** * See {@link com.codahale.metrics.MetricRegistry#getTimers(com.codahale.metrics.MetricFilter)}. * * <p> * This method will return fully-qualified metric names if the {@link MetricContext} is configured * to report fully-qualified metric names. * </p> */ @Override public SortedMap<String, Timer> getTimers(MetricFilter filter) { return this.innerMetricContext.getTimers(filter); }
/** * Get the name of this {@link MetricContext}. * * @return the name of this {@link MetricContext} */ public String getName() { return this.innerMetricContext.getName(); }
/** * See {@link com.codahale.metrics.MetricRegistry#getGauges(com.codahale.metrics.MetricFilter)}. * * <p> * This method will return fully-qualified metric names if the {@link MetricContext} is configured * to report fully-qualified metric names. * </p> */ @Override public SortedMap<String, Gauge> getGauges(MetricFilter filter) { return this.innerMetricContext.getGauges(filter); }
/** * Get a view of the child {@link org.apache.gobblin.metrics.MetricContext}s as a {@link com.google.common.collect.ImmutableMap}. * @return {@link com.google.common.collect.ImmutableMap} of * child {@link org.apache.gobblin.metrics.MetricContext}s keyed by their names. */ public Map<String, MetricContext> getChildContextsAsMap() { return this.innerMetricContext.getChildContextsAsMap(); }
void addChildContext(String childContextName, MetricContext childContext) throws NameConflictException, ExecutionException { this.innerMetricContext.addChildContext(childContextName, childContext); }
protected MetricContext(String name, MetricContext parent, List<Tag<?>> tags, boolean isRoot) throws NameConflictException { Preconditions.checkArgument(!Strings.isNullOrEmpty(name)); this.closer = Closer.create(); try { this.innerMetricContext = this.closer.register(new InnerMetricContext(this, name, parent, tags)); } catch(ExecutionException ee) { throw Throwables.propagate(ee); } this.contextAwareMetricsSet = Sets.newConcurrentHashSet(); this.notificationTargets = Maps.newConcurrentMap(); this.executorServiceOptional = Optional.absent(); this.notificationTimer = new ContextAwareTimer(this, GOBBLIN_METRICS_NOTIFICATIONS_TIMER_NAME); register(this.notificationTimer); if (!isRoot) { RootMetricContext.get().addMetricContext(this); } }
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("InnerMetricContext Name: "); stringBuilder.append(this.name); if (this.getParent().isPresent()) { stringBuilder.append(", Parent Name: "); stringBuilder.append(this.getParent().get().getName()); } else { stringBuilder.append(", No Parent Context"); } stringBuilder.append(", Number of Children: "); stringBuilder.append(this.getChildContextsAsMap().size()); stringBuilder.append(", Tags: "); stringBuilder.append(Joiner.on(", ").withKeyValueSeparator(" : ").useForNull("NULL").join(this.getTagMap())); return stringBuilder.toString(); } }
/** * Get a {@link ContextAwareHistogram} with a given name and a customized {@link com.codahale.metrics.SlidingTimeWindowReservoir} * * @param name name of the {@link ContextAwareHistogram} * @param windowSize normally the duration of the time window * @param unit the unit of time * @return the {@link ContextAwareHistogram} with the given name */ public ContextAwareHistogram contextAwareHistogram(String name, long windowSize, TimeUnit unit) { ContextAwareMetricFactoryArgs.SlidingTimeWindowArgs args = new ContextAwareMetricFactoryArgs.SlidingTimeWindowArgs( this.innerMetricContext.getMetricContext().get(), name, windowSize, unit); return this.innerMetricContext.getOrCreate(ContextAwareMetricFactory.DEFAULT_CONTEXT_AWARE_HISTOGRAM_FACTORY, args); }
/** * See {@link com.codahale.metrics.MetricRegistry#getTimers()}. * * <p> * This method will return fully-qualified metric names if the {@link MetricContext} is configured * to report fully-qualified metric names. * </p> */ @Override public SortedMap<String, Timer> getTimers() { return this.innerMetricContext.getTimers(MetricFilter.ALL); }
@Override public boolean apply(Notification input) { if (input instanceof NewMetricContextNotification && ((NewMetricContextNotification) input).getInnerMetricContext().getName().equals(this.name)) { return true; } if (input instanceof MetricContextCleanupNotification && ((MetricContextCleanupNotification) input).getMetricContext().getName().equals(this.name)) { return true; } return false; } }
/** * See {@link com.codahale.metrics.MetricRegistry#getGauges()}. * * <p> * This method will return fully-qualified metric names if the {@link MetricContext} is configured * to report fully-qualified metric names. * </p> */ @Override public SortedMap<String, Gauge> getGauges() { return this.innerMetricContext.getGauges(MetricFilter.ALL); }
private boolean removeChildrenMetrics(String name) { boolean removed = true; for (MetricContext child : getChildContextsAsMap().values()) { if (!child.remove(name)) { removed = false; } } return removed; }
void addChildContext(String childContextName, MetricContext childContext) throws NameConflictException, ExecutionException { this.innerMetricContext.addChildContext(childContextName, childContext); }
protected MetricContext(String name, MetricContext parent, List<Tag<?>> tags, boolean isRoot) throws NameConflictException { Preconditions.checkArgument(!Strings.isNullOrEmpty(name)); this.closer = Closer.create(); try { this.innerMetricContext = this.closer.register(new InnerMetricContext(this, name, parent, tags)); } catch(ExecutionException ee) { throw Throwables.propagate(ee); } this.contextAwareMetricsSet = Sets.newConcurrentHashSet(); this.notificationTargets = Maps.newConcurrentMap(); this.executorServiceOptional = Optional.absent(); this.notificationTimer = new ContextAwareTimer(this, GOBBLIN_METRICS_NOTIFICATIONS_TIMER_NAME); register(this.notificationTimer); if (!isRoot) { RootMetricContext.get().addMetricContext(this); } }