@Override protected void removedMetricContext(InnerMetricContext context) { if (shouldReportInnerMetricContext(context)) { report(context, true); } super.removedMetricContext(context); }
@Override public ScheduledReporter newScheduledReporter(Properties properties) throws IOException { return OutputStreamReporter.Factory.newBuilder().build(properties); } }
/** * Sets metrics prefix independent from the context (useful for grouping metrics in Graphite or other metric-store) * @param metricsPrefix * @return */ public T withMetricsPrefix(String metricsPrefix) { this.metricsPrefix = metricsPrefix; return self(); }
public FileFailureEventReporter(MetricContext context, FileSystem fs, Path failureLogFile) throws IOException { super(OutputStreamEventReporter.forContext(context)); this.fs = fs; this.failureLogFile = failureLogFile; hasSetupOutputStream = false; }
/** * Use the given {@link Clock} instance for the time. * * @param clock a {@link Clock} instance * @return {@code this} */ public T withClock(Clock clock) { this.clock = clock; return self(); }
/** * @see #report(SortedMap, SortedMap, SortedMap, SortedMap, SortedMap, Map) */ protected abstract void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers, Map<String, Object> tags); }
/** * Report all {@link org.apache.gobblin.metrics.GobblinTrackingEvent}s in the queue. */ @Override public void report() { reportEventQueue(this.reportingQueue); }
/** * Returns a new {@link org.apache.gobblin.metrics.kafka.KafkaEventReporter.Builder} for {@link org.apache.gobblin.metrics.kafka.KafkaEventReporter}. * Will automatically add all Context tags to the reporter. * * @param context the {@link org.apache.gobblin.metrics.MetricContext} to report * @return KafkaReporter builder */ public static Builder<? extends Builder> forContext(MetricContext context) { return new BuilderImpl(context); }
@Override public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { reportInContext(this.context, gauges, counters, histograms, meters, timers); }
/** * Write to the given {@link java.io.PrintStream}. * * @param output a {@link java.io.PrintStream} instance. * @return {@code this} */ public T outputTo(PrintStream output) { this.output = output; return self(); }
/** * Only report metrics which match the given filter. * * @param filter a {@link MetricFilter} * @return {@code this} */ public T filter(MetricFilter filter) { this.filter = filter; return self(); } }
@Override public void run() { report(); } });
/** * Add the name of the base metrics context as prefix to the metric keys * * @param metricContextName name of the metrics context * @return {@code this} */ public T withMetricContextName(String metricContextName) { this.metricContextName = metricContextName; return self(); }
/** * Use the given {@link TimeZone} for the time. * * @param timeZone a {@link TimeZone} * @return {@code this} */ public T formattedFor(TimeZone timeZone) { this.timeZone = timeZone; return self(); }
/** * Trigger emission of a report. */ public void report() { report(false); }
/** * Set the name of the reporter * * @param name name of the metric reporter * @return {@code this} */ public T name(String name) { this.name = name; return self(); }
/** * Write to the given {@link PrintStream}. * * @param output a {@link PrintStream} instance. * @return {@code this} */ public T outputTo(PrintStream output) { this.output = output; return self(); }
/** * Convert durations to the given time unit. * * @param durationUnit a unit of time * @return {@code this} */ public T convertDurationsTo(TimeUnit durationUnit) { this.durationUnit = durationUnit; return self(); }
/** * Format numbers for the given {@link Locale}. * * @param locale a {@link Locale} * @return {@code this} */ public T formattedFor(Locale locale) { this.locale = locale; return self(); }
/** * Convert rates to the given time unit. * * @param rateUnit a unit of time * @return {@code this} */ public T convertRatesTo(TimeUnit rateUnit) { this.rateUnit = rateUnit; return self(); }