public ContextWeakReference(MetricContext referent, InnerMetricContext innerContext) { super(referent, RootMetricContext.get().getReferenceQueue()); this.innerContext = innerContext; }
/** * Get the singleton {@link RootMetricContext}. * @return singleton instance of {@link RootMetricContext}. */ public synchronized static RootMetricContext get() { return get(Lists.<Tag<?>>newArrayList()); }
@Override public Set<MetricContext> getMatchingContexts() { ImmutableSet.Builder<MetricContext> builder = ImmutableSet.builder(); addContextsRecursively(builder, RootMetricContext.get()); return builder.build(); }
/** * Removes {@link ContextAwareReporter} records from the {@link RootMetricContext}. * This method should be considered irreversible and destructive to the {@link ContextAwareReporter}. * @throws IOException */ @Override public void close() throws IOException { RootMetricContext.get().removeNotificationTarget(this.notificationTargetUUID); RootMetricContext.get().removeReporter(this); }
/** * Builder a new {@link MetricContext}. * * <p> * See {@link Taggable#metricNamePrefix(boolean)} for the semantic of {@code includeTagKeys}. * </p> * * @return the newly built {@link MetricContext} * @throws NameConflictException if the parent {@link MetricContext} already has a child with this name. */ public MetricContext buildStrict() throws NameConflictException { if(this.parent == null) { this.parent = RootMetricContext.get(); } return new MetricContext(this.name, this.parent, this.tags, false); }
private void buildJmxMetricReporter(Properties properties) { if (!Boolean.valueOf(properties.getProperty(ConfigurationKeys.METRICS_REPORTING_JMX_ENABLED_KEY, ConfigurationKeys.DEFAULT_METRICS_REPORTING_JMX_ENABLED))) { return; } LOGGER.info("Reporting metrics to JMX"); this.jmxReporter = Optional.of(codahaleReportersCloser.register(JmxReporter.forRegistry(RootMetricContext.get()). convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build())); }
public AzkabanGobblinDaemon(String jobId, Properties props) throws Exception { super(jobId, LOG); List<Tag<?>> tags = Lists.newArrayList(); tags.addAll(Tag.fromMap(AzkabanTags.getAzkabanTags())); RootMetricContext.get(tags); this.daemon = new SchedulerDaemon(props); }
((CustomCodahaleReporterFactory) clazz.getConstructor().newInstance()); com.codahale.metrics.ScheduledReporter scheduledReporter = this.codahaleReportersCloser .register(customCodahaleReporterFactory.newScheduledReporter(RootMetricContext.get(), properties)); String reporterSinkMsg = reporterSink.isPresent()?"to " + reporterSink.get():""; LOGGER.info("Will start reporting metrics " + reporterSinkMsg + " using " + reporterClass);
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); } }
/** * Stop metric reporting. */ public void stopMetricsReporting() { if (!this.metricsReportingStarted) { LOGGER.warn("Metric reporting has not started yet"); return; } // Stop the JMX reporter if (this.jmxReporter.isPresent()) { this.jmxReporter.get().stop(); } // Trigger and stop reporters that implement gobblin.metrics.report.ScheduledReporter RootMetricContext.get().stopReporting(); // Trigger and stop reporters that implement com.codahale.metrics.ScheduledReporter for (com.codahale.metrics.ScheduledReporter scheduledReporter : this.codahaleScheduledReporters) { scheduledReporter.report(); } try { this.codahaleReportersCloser.close(); } catch (IOException ioe) { LOGGER.error("Failed to close metric output stream for job " + this.id, ioe); } this.metricsReportingStarted = false; }
KafkaEventReporter.Builder<?> builder = formatEnum.eventReporterBuilder(RootMetricContext.get(), properties); return builder.build(brokers, eventsTopic.or(defaultTopic).get());
RootMetricContext.get(tags); GobblinMetrics.addCustomTagsToProperties(this.props, tags);
OutputStreamReporter.Factory.newBuilder().outputTo(output).build(properties); this.codahaleScheduledReporters.add(this.codahaleReportersCloser .register(OutputStreamEventReporter.forContext(RootMetricContext.get()).outputTo(output).build()));
public ContextAwareReporter(String name, Config config) { this.name = name; this.config = config; this.started = false; RootMetricContext.get().addNewReporter(this); this.notificationTargetUUID = RootMetricContext.get().addNotificationTarget(new Function<Notification, Void>() { @Nullable @Override public Void apply(Notification input) { notificationCallback(input); return null; } }); this.contextFilter = ContextFilterFactory.createContextFilter(config); this.contextsToReport = Sets.newConcurrentHashSet(); for (MetricContext context : this.contextFilter.getMatchingContexts()) { this.contextsToReport.add(context.getInnerMetricContext()); } }
try { GraphiteEventReporter eventReporter = GraphiteEventReporter.Factory.forContext(RootMetricContext.get()) .withConnectionType(connectionType) .withConnection(hostname, eventsPort)
try { InfluxDBEventReporter eventReporter = InfluxDBEventReporter.Factory.forContext(RootMetricContext.get()) .withConnectionType(connectionType) .withConnection(url, username, password, eventsDatabase)
RootMetricContext.get().startReporting();
MetricContext parentMetricContext = RootMetricContext.get();