/** * Instantiates {@link com.codahale.metrics.Metric}s. Called once in {@link #startUp()}. Subclasses should override * this method to instantiate their own metrics. */ protected void createMetrics() { this.messagesRead = this.metricContext.counter(RuntimeMetrics.GOBBLIN_KAFKA_HIGH_LEVEL_CONSUMER_MESSAGES_READ); }
/** * Get a {@link Counter} with the given name prefix and suffixes. * * @param prefix the given name prefix * @param suffixes the given name suffixes * @return a {@link Counter} with the given name prefix and suffixes */ public Counter getCounter(String prefix, String... suffixes) { return this.metricContext.counter(MetricRegistry.name(prefix, suffixes)); }
/** * Creates a {@link Counter} for every value of the enumClass. * Use {@link #inc(Enum, long)} to increment the counter associated with a enum value * * @param metricContext that {@link Counter}s will be registered * @param enumClass that define the names of {@link Counter}s. One counter is created per value * @param instrumentedClass name that will be prefixed in the metric name */ public void initialize(final MetricContext metricContext, final Class<E> enumClass, final Class<?> instrumentedClass) { Builder<E, Counter> builder = ImmutableMap.builder(); for (E e : Arrays.asList(enumClass.getEnumConstants())) { builder.put(e, metricContext.counter(MetricRegistry.name(instrumentedClass, e.name()))); } counters = builder.build(); }
@Override protected void createMetrics() { super.createMetrics(); this.rejectedEvents = getMetricContext().counter(RuntimeMetrics.GOBBLIN_JOB_MONITOR_SLAEVENT_REJECTEDEVENTS); }