/** * Creates a new {@link ExponentiallyDecayingSample}. * * @param reservoirSize the number of samples to keep in the sampling reservoir * @param alpha the exponential decay factor; the higher this is, the more biased the * sample will be towards newer values */ public ExponentiallyDecayingSample(int reservoirSize, double alpha) { this(reservoirSize, alpha, Clock.defaultClock()); }
/** * Creates a new {@link MetricsRegistry}. */ public MetricsRegistry() { this(Clock.defaultClock()); }
/** * Creates a new {@link Timer}. * * @param tickThread background thread for updating the rates * @param durationUnit the scale unit for this timer's duration metrics * @param rateUnit the scale unit for this timer's rate metrics */ Timer(ScheduledExecutorService tickThread, TimeUnit durationUnit, TimeUnit rateUnit) { this(tickThread, durationUnit, rateUnit, Clock.defaultClock()); }
/** * Creates a new {@link CsvReporter} which will write metrics from the given * {@link MetricsRegistry} which match the given {@link MetricPredicate} to CSV files in the * given output directory. * * @param metricsRegistry the {@link MetricsRegistry} containing the metrics this reporter * will report * @param predicate the {@link MetricPredicate} which metrics are required to match * before being written to files * @param outputDir the directory to which files will be written */ public CsvReporter(MetricsRegistry metricsRegistry, MetricPredicate predicate, File outputDir) { this(metricsRegistry, predicate, outputDir, Clock.defaultClock()); }
/** * Creates a new {@link ConsoleReporter} for a given metrics registry. * * @param metricsRegistry the metrics registry * @param out the {@link PrintStream} to which output will be written * @param predicate the {@link MetricPredicate} used to determine whether a metric will be * output */ public ConsoleReporter(MetricsRegistry metricsRegistry, PrintStream out, MetricPredicate predicate) { this(metricsRegistry, out, predicate, Clock.defaultClock(), TimeZone.getDefault()); }
protected X(MetricsRegistry registry) { super(registry, "consumer-groups-reporter"); this.clock = Clock.defaultClock(); this.admin = AdminClient.create(props); }
/** do not instantiate */ private NoOpMeter() { super(new NoOpExecutorService(), "", TimeUnit.SECONDS, Clock.defaultClock()); }
public StatsDReporter(MetricsRegistry metricsRegistry, String host, int port, String prefix) { this(metricsRegistry, prefix, MetricPredicate.ALL, Clock.defaultClock(), new StatsD(host, port)); }
public KafkaMetricsProcessor( MetricsRegistry metricsRegistry, Map<org.apache.kafka.common.MetricName, KafkaMetric> kafkaMetrics, MeasurementPublisher publisher, Map<String, String> fixedTags, Integer pollingIntervalSeconds ) { super(metricsRegistry, "streaming-reporter"); this.kafkaMetrics = kafkaMetrics; this.clock = Clock.defaultClock(); this.fixedTags = fixedTags; this.publisher = publisher; this.formatter = new MeasurementFormatter(); this.pollingIntervalSeconds = pollingIntervalSeconds; }
/** * Creates a new {@link GraphiteReporter}. * * @param metricsRegistry the metrics registry * @param host is graphite server * @param port is port on which graphite server is running * @param prefix is prepended to all names reported to graphite * @throws IOException if there is an error connecting to the Graphite server */ public GraphiteReporter(MetricsRegistry metricsRegistry, String host, int port, String prefix) throws IOException { this(metricsRegistry, prefix, MetricPredicate.ALL, new DefaultSocketProvider(host, port), Clock.defaultClock()); }
/** * Creates a new {@link MetricsServlet}. */ public MetricsServletShim() { this(Clock.defaultClock(), VirtualMachineMetrics.getInstance(), Metrics.defaultRegistry(), DEFAULT_JSON_FACTORY, true); }
/** * Creates a new {@link MetricsServlet}. */ public MetricsServlet() { this(Clock.defaultClock(), VirtualMachineMetrics.getInstance(), Metrics.defaultRegistry(), DEFAULT_JSON_FACTORY, true); }
/** * Creates a new {@link MetricsServlet}. * * @param showJvmMetrics whether or not JVM-level metrics will be included in the output */ public MetricsServlet(boolean showJvmMetrics) { this(Clock.defaultClock(), VirtualMachineMetrics.getInstance(), Metrics.defaultRegistry(), DEFAULT_JSON_FACTORY, showJvmMetrics); }
public DatadogReporter(MetricsRegistry registry, String apiKey, String host) { this(registry, MetricPredicate.ALL, VirtualMachineMetrics.getInstance(), new HttpTransport("app.datadoghq.com", apiKey), Clock.defaultClock(), host); }
private FilteredGraphiteReporter buildGraphiteReporter() { FilteredGraphiteReporter graphiteReporter = null; try { graphiteReporter = new FilteredGraphiteReporter( Metrics.defaultRegistry(), metricPrefix, metricPredicate, metricDimensions, new FilteredGraphiteReporter.DefaultSocketProvider(graphiteHost, graphitePort), Clock.defaultClock() ); } catch (IOException e) { LOG.error("Unable to initialize GraphiteReporter", e); } return graphiteReporter; } }
/** * Public constructor. */ @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") public MetricsRegistry() { // TODO(barp): Read the settings from a config file [#2] this( new TsdMetricsFactory.Builder() .setClusterName(System.getProperty("METRICS_YAMMER_EXTRA_CLUSTER", "YammerCluster")) .setServiceName(System.getProperty("METRICS_YAMMER_EXTRA_SERVICE", "YammerService")) .setSinks(Collections.singletonList( new TsdLogSink.Builder() .setDirectory( new File(System.getProperty("METRICS_YAMMER_EXTRA_DIRECTORY", "/tmp"))) .build())) .build(), Clock.defaultClock()); }
/** * Enables the graphite reporter to send data to graphite server with the specified period. * * @param metricsRegistry the metrics registry * @param period the period between successive outputs * @param unit the time unit of {@code period} * @param host the host name of graphite server (carbon-cache agent) * @param port the port number on which the graphite server is listening * @param prefix the string which is prepended to all metric names * @param predicate filters metrics to be reported */ public static void enable(MetricsRegistry metricsRegistry, long period, TimeUnit unit, String host, int port, String prefix, MetricPredicate predicate) { try { final GraphiteReporter reporter = new GraphiteReporter(metricsRegistry, prefix, predicate, new DefaultSocketProvider(host, port), Clock.defaultClock()); reporter.start(period, unit); } catch (Exception e) { LOG.error("Error creating/starting Graphite reporter:", e); } }
@Override public AdminServlet get() { for (HealthCheck healthCheck : healthChecks) { healthCheckRegistry.register(healthCheck); } final JsonFactory factory = jsonFactory == null ? new JsonFactory(new ObjectMapper()) : jsonFactory; return new AdminServlet(new HealthCheckServlet(healthCheckRegistry), new MetricsServlet(Clock.defaultClock(), VirtualMachineMetrics.getInstance(), metricsRegistry, factory, true), new PingServlet(), new ThreadDumpServlet(VirtualMachineMetrics.getInstance()), healthcheckUri, metricsUri, pingUri, threadsUri); } }
@Override public boolean enable() { if (!isClassAvailable(SENDER_CLASS)) { log.error("Tried to enable Zabbix Reporter, but class {} was not found", SENDER_CLASS); return false; } if (hostName == null) hostName = System.getenv("COMPUTERNAME"); if (hostName == null) hostName = System.getenv("HOSTNAME"); if (hostName == null) hostName = "localhost"; // note: don't go via InetAddress.getLocalHost() as that may return unexpected results or // take a long time (DNS roundtrips/timeouts) or even an exception being throws, for (HostPort hostPort : getFullHostList()) { ZabbixSender sender = new ZabbixSender(hostPort.getHost(), hostPort.getPort(), connectTimeout, socketTimeout); ZabbixReporter reporter = new ZabbixReporter(sender, hostName, prefix, name, getRealRateunit(), getRealDurationunit(), MetricPredicateTransformer.generatePredicate(getPredicate()), Clock.defaultClock()); reporter.start(getPeriod(), getRealTimeunit()); } return true; }
getResolvedPrefix(), MetricPredicateTransformer.generatePredicate(getPredicate()), Clock.defaultClock(), new StatsDConstructorHack(hostPort.getHost(), hostPort.getPort())); reporter.start(getPeriod(), getRealTimeunit());