Java Code Examples for com.codahale.metrics.Clock#defaultClock()

The following examples show how to use com.codahale.metrics.Clock#defaultClock() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IrisMetricsTopicReporter.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
@Inject
public IrisMetricsTopicReporter(
      MetricRegistry registry,
      IrisMetricsReporterConfig reporterConfig,
      KafkaOpsConfig config
) {
   this.registry = registry;

   this.metrics = new IrisTopicReporterMetrics(IrisMetrics.metrics("metrics.kafkareporter"));
   this.clock = Clock.defaultClock();
   this.kafkaProducer = new KafkaProducer<String, String>(config.toNuProducerProperties(), new StringSerializer(), new StringSerializer());
   this.executor = ThreadPoolBuilder.newSingleThreadedScheduler("metrics-" + config.getTopicMetrics() + "-reporter");
   this.kafkaTopic = config.getTopicMetrics();

   this.reporting = reporterConfig.getEnabled();
   this.filter = reporterConfig.getTopicFilter();
   this.reportingIntervalMs = TimeUnit.MILLISECONDS.convert(reporterConfig.getReportingUnit(), reporterConfig.getReportingUnitType());
   this.counterBatchSize = reporterConfig.getBatchSize();
   this.rateFactor = reporterConfig.getTopicRateUnit().toSeconds(1);
   this.durationFactor = 1.0 / reporterConfig.getTopicDurationUnit().toNanos(1);
}
 
Example 2
Source File: DatadogReporter.java    From hudi with Apache License 2.0 6 votes vote down vote up
protected DatadogReporter(
    MetricRegistry registry,
    DatadogHttpClient client,
    String prefix,
    Option<String> host,
    Option<List<String>> tags,
    MetricFilter filter,
    TimeUnit rateUnit,
    TimeUnit durationUnit) {
  super(registry, "hudi-datadog-reporter", filter, rateUnit, durationUnit);
  this.client = client;
  this.prefix = prefix;
  this.host = host;
  this.tags = tags;
  this.clock = Clock.defaultClock();
}
 
Example 3
Source File: MetricSuppliers.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private static Clock getClock(PluginInfo info, String param) {
  if (info == null) {
    return Clock.defaultClock();
  }
  String clock = null;
  if (info.attributes != null) {
    clock = info.attributes.get(param);
  }
  if (clock == null && info.initArgs != null) {
    clock = (String)info.initArgs.get(param);
  }
  Clock clk = Clock.defaultClock();
  if (clock != null) {
    if (clock.equalsIgnoreCase(CLOCK_USER)) {
      clk = USER_CLOCK;
    } else if (clock.equalsIgnoreCase(CLOCK_CPU)) {
      clk = CPU_CLOCK;
    }
  }
  return clk;
}
 
Example 4
Source File: MetricReporter.java    From sofa-jraft with Apache License 2.0 5 votes vote down vote up
private Builder(MetricRegistry registry) {
    this.registry = registry;
    this.prefix = "";
    this.output = System.out;
    this.locale = Locale.getDefault();
    this.clock = Clock.defaultClock();
    this.timeZone = TimeZone.getDefault();
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.filter = MetricFilter.ALL;
    this.disabledMetricAttributes = Collections.emptySet();
}
 
Example 5
Source File: NewtsReporter.java    From newts with Apache License 2.0 5 votes vote down vote up
private Builder(MetricRegistry registry) {
    this.registry = registry;
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.clock = Clock.defaultClock();
    this.filter = MetricFilter.ALL;
}
 
Example 6
Source File: OutputStreamReporter.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
protected Builder() {
  this.name = "OutputStreamReporter";
  this.output = System.out;
  this.locale = Locale.getDefault();
  this.clock = Clock.defaultClock();
  this.timeZone = TimeZone.getDefault();
}
 
Example 7
Source File: TestReporter.java    From micro-server with Apache License 2.0 5 votes vote down vote up
private Builder(MetricRegistry registry) {
    this.registry = registry;
    this.output = System.out;
    this.locale = Locale.getDefault();
    this.clock = Clock.defaultClock();
    this.timeZone = TimeZone.getDefault();
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.filter = MetricFilter.ALL;
}
 
Example 8
Source File: TestReporter.java    From micro-server with Apache License 2.0 5 votes vote down vote up
private Builder(MetricRegistry registry) {
    this.registry = registry;
    this.output = System.out;
    this.locale = Locale.getDefault();
    this.clock = Clock.defaultClock();
    this.timeZone = TimeZone.getDefault();
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.filter = MetricFilter.ALL;
}
 
Example 9
Source File: CloudWatchReporter.java    From codahale-aggregated-metrics-cloudwatch-reporter with MIT License 5 votes vote down vote up
private Builder(final MetricRegistry metricRegistry, final CloudWatchAsyncClient cloudWatchAsyncClient, final String namespace) {
    this.metricRegistry = metricRegistry;
    this.cloudWatchAsyncClient = cloudWatchAsyncClient;
    this.namespace = namespace;
    this.percentiles = new Percentile[]{Percentile.P75, Percentile.P95, Percentile.P999};
    this.metricFilter = MetricFilter.ALL;
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.globalDimensions = new LinkedHashSet<>();
    this.cwMeterUnit = Optional.empty();
    this.cwRateUnit = toStandardUnit(rateUnit);
    this.cwDurationUnit = toStandardUnit(durationUnit);
    this.clock = Clock.defaultClock();
}
 
Example 10
Source File: ElasticsearchReporter.java    From oneops with Apache License 2.0 5 votes vote down vote up
private Builder(MetricRegistry registry) {
    this.registry = registry;
    this.clock = Clock.defaultClock();
    this.prefix = null;
    this.rateUnit = TimeUnit.SECONDS;
    this.durationUnit = TimeUnit.MILLISECONDS;
    this.filter = MetricFilter.ALL;
}
 
Example 11
Source File: MetricsModule.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void configure() {
  // NOTE: AdminServletModule (metrics-guice integration) generates invalid links, so wire up servlets ourselves

  final Clock clock = Clock.defaultClock();
  bind(Clock.class).toInstance(clock);

  final JsonFactory jsonFactory = new JsonFactory(new ObjectMapper());
  bind(JsonFactory.class).toInstance(jsonFactory);

  install(new ServletModule()
  {
    @Override
    protected void configureServlets() {
      bind(MetricsServlet.class);
      bind(HealthCheckServlet.class);

      serve(MOUNT_POINT + "/ping").with(new PingServlet());
      serve(MOUNT_POINT + "/threads").with(new ThreadDumpServlet());
      serve(MOUNT_POINT + "/data").with(MetricsServlet.class);
      serve(MOUNT_POINT + "/healthcheck").with(HealthCheckServlet.class);
      serve(MOUNT_POINT + "/prometheus").with(new io.prometheus.client.exporter.MetricsServlet());

      // record metrics for all webapp access
      filter("/*").through(new InstrumentedFilter());

      bind(SecurityFilter.class);

      // configure security
      filter(MOUNT_POINT + "/*").through(SecurityFilter.class);
    }
  });

  // require permission to use endpoints
  install(new FilterChainModule()
  {
    @Override
    protected void configure() {
      addFilterChain(MOUNT_POINT + "/**",
          NexusAuthenticationFilter.NAME,
          AnonymousFilter.NAME,
          AntiCsrfFilter.NAME,
          PermissionsFilter.config("nexus:metrics:read"));
    }
  });

  log.info("Metrics support configured");
}
 
Example 12
Source File: GraphiteMetricSender.java    From circus-train with Apache License 2.0 4 votes vote down vote up
public static GraphiteMetricSender newInstance(String host, String prefix) {
  InetSocketAddress address = new InetSocketAddressFactory().newInstance(host);
  Graphite graphite = new Graphite(address);
  return new GraphiteMetricSender(graphite, Clock.defaultClock(), prefix);
}
 
Example 13
Source File: Timer.java    From SpinalTap with Apache License 2.0 4 votes vote down vote up
public Timer(com.codahale.metrics.Timer... timers) {
  this(Clock.defaultClock(), timers);
}
 
Example 14
Source File: Manager.java    From passopolis-server with GNU General Public License v3.0 4 votes vote down vote up
public Pool() {
  this(Clock.defaultClock());
}
 
Example 15
Source File: ExtendedMeter.java    From datacollector with Apache License 2.0 4 votes vote down vote up
public ExtendedMeter() {
  this(Clock.defaultClock());
}
 
Example 16
Source File: TaggedCachedGauge.java    From metrics-opentsdb with Apache License 2.0 4 votes vote down vote up
protected TaggedCachedGauge(long timeout, TimeUnit timeoutUnit) {
this(Clock.defaultClock(), timeout, timeoutUnit);
  }
 
Example 17
Source File: AsyncTimer.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
private Context()
{
   clock = Clock.defaultClock();

   startTimeNanos = clock.getTick();
}
 
Example 18
Source File: ResettableTimer.java    From bistoury with GNU General Public License v3.0 4 votes vote down vote up
public ResettableTimer() {
    this(Clock.defaultClock(), DEFAULT_PER, DEFAULT_TIMER_SIZE);
}
 
Example 19
Source File: CachedHistogram.java    From ambry with Apache License 2.0 2 votes vote down vote up
/**
 * @param reservoir the {@link Reservoir} to use for the histogram.
 * @param timeoutMs the timeout for the value stored in the cache in milliseconds. After this time has passed, a new
 *                  value of the histogram at {@code quantile} will be calculated.
 * @param quantile the quantile of the histogram to cache.
 */
public CachedHistogram(Reservoir reservoir, long timeoutMs, double quantile) {
  this(Clock.defaultClock(), reservoir, timeoutMs, quantile);
}