/** * Register a given metric under a given name. * * <p> * This method does not support registering {@link com.codahale.metrics.MetricSet}s. * See{@link #registerAll(com.codahale.metrics.MetricSet)}. * </p> * * <p> * This method will not register a metric with the same name in the parent context (if it exists). * </p> */ @Override public synchronized <T extends Metric> T register(String name, T metric) throws IllegalArgumentException { if(!(metric instanceof ContextAwareMetric)) { throw new UnsupportedOperationException("Can only register ContextAwareMetrics."); } return this.innerMetricContext.register(name, metric); }
/** * Register a {@link org.apache.gobblin.metrics.ContextAwareMetric} under its own name. */ public <T extends ContextAwareMetric> T register(T metric) throws IllegalArgumentException { return register(metric.getName(), metric); }
@SuppressWarnings("unchecked") protected synchronized <T extends ContextAwareMetric> T getOrCreate(String name, ContextAwareMetricFactory<T> factory) { InnerMetric metric = this.contextAwareMetrics.get(name); if (metric != null) { if (factory.isInstance(metric)) { return (T) metric.getContextAwareMetric(); } throw new IllegalArgumentException(name + " is already used for a different type of metric"); } T newMetric = factory.newMetric(this.metricContext.get(), name); this.register(name, newMetric); return newMetric; }
@SuppressWarnings("unchecked") protected synchronized <T extends ContextAwareMetric> T getOrCreate( ContextAwareMetricFactory<T> factory, ContextAwareMetricFactoryArgs args) { String name = args.getName(); InnerMetric metric = this.contextAwareMetrics.get(name); if (metric != null) { if (factory.isInstance(metric)) { return (T) metric.getContextAwareMetric(); } throw new IllegalArgumentException(name + " is already used for a different type of metric"); } T newMetric = factory.newMetric(args); this.register(name, newMetric); return newMetric; }
/** * Register a given metric under a given name. * * <p> * This method does not support registering {@link com.codahale.metrics.MetricSet}s. * See{@link #registerAll(com.codahale.metrics.MetricSet)}. * </p> * * <p> * This method will not register a metric with the same name in the parent context (if it exists). * </p> */ @Override public synchronized <T extends Metric> T register(String name, T metric) throws IllegalArgumentException { if(!(metric instanceof ContextAwareMetric)) { throw new UnsupportedOperationException("Can only register ContextAwareMetrics."); } return this.innerMetricContext.register(name, metric); }
/** * Register a {@link org.apache.gobblin.metrics.ContextAwareMetric} under its own name. */ public <T extends ContextAwareMetric> T register(T metric) throws IllegalArgumentException { return register(metric.getName(), metric); }
@SuppressWarnings("unchecked") protected synchronized <T extends ContextAwareMetric> T getOrCreate(String name, ContextAwareMetricFactory<T> factory) { InnerMetric metric = this.contextAwareMetrics.get(name); if (metric != null) { if (factory.isInstance(metric)) { return (T) metric.getContextAwareMetric(); } throw new IllegalArgumentException(name + " is already used for a different type of metric"); } T newMetric = factory.newMetric(this.metricContext.get(), name); this.register(name, newMetric); return newMetric; }
@SuppressWarnings("unchecked") protected synchronized <T extends ContextAwareMetric> T getOrCreate( ContextAwareMetricFactory<T> factory, ContextAwareMetricFactoryArgs args) { String name = args.getName(); InnerMetric metric = this.contextAwareMetrics.get(name); if (metric != null) { if (factory.isInstance(metric)) { return (T) metric.getContextAwareMetric(); } throw new IllegalArgumentException(name + " is already used for a different type of metric"); } T newMetric = factory.newMetric(args); this.register(name, newMetric); return newMetric; }