com.codahale.metrics.Clock Java Examples
The following examples show how to use
com.codahale.metrics.Clock.
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: GraphiteReporterTest.java From styx with Apache License 2.0 | 6 votes |
@BeforeEach public void setUp() { Clock clock = mock(Clock.class); graphite = mock(Graphite.class); MetricRegistry registry = mock(MetricRegistry.class); when(clock.getTime()).thenReturn(TIMESTAMP * 1000); reporter = forRegistry(registry) .withClock(clock) .prefixedWith("prefix") .convertRatesTo(SECONDS) .convertDurationsTo(MILLISECONDS) .filter(MetricFilter.ALL) .build(graphite); logging = new LoggingTestSupport(GraphiteReporter.class); }
Example #2
Source File: MetricReporter.java From sofa-jraft with Apache License 2.0 | 6 votes |
private MetricReporter(MetricRegistry registry, // PrintStream output, // String prefix, // Locale locale, // Clock clock, // TimeZone timeZone, // TimeUnit rateUnit, // TimeUnit durationUnit, // MetricFilter filter, // Set<MetricAttribute> disabledMetricAttributes) { this.registry = registry; this.output = output; this.prefix = prefix; this.locale = locale; this.clock = clock; this.dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale); this.dateFormat.setTimeZone(timeZone); this.rateFactor = rateUnit.toSeconds(1); this.rateUnit = calculateRateUnit(rateUnit); this.durationFactor = durationUnit.toNanos(1); this.durationUnit = durationUnit.toString().toLowerCase(Locale.US); this.filter = filter; this.disabledMetricAttributes = disabledMetricAttributes != null ? disabledMetricAttributes : Collections .emptySet(); }
Example #3
Source File: MetricSuppliers.java From lucene-solr with Apache License 2.0 | 6 votes |
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: IrisMetricsTopicReporter.java From arcusplatform with Apache License 2.0 | 6 votes |
@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 #5
Source File: DatadogReporter.java From hudi with Apache License 2.0 | 6 votes |
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 #6
Source File: TestReporter.java From micro-server with Apache License 2.0 | 5 votes |
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 #7
Source File: ElasticsearchReporter.java From oneops with Apache License 2.0 | 5 votes |
public ElasticsearchReporter(MetricRegistry registry, String[] hosts, int timeout, String index, String indexDateFormat, int bulkSize, Clock clock, String prefix, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter, MetricFilter percolationFilter, Notifier percolationNotifier, String timestampFieldname,Map<String,String> context) throws MalformedURLException { super(registry, "elasticsearch-reporter", filter, rateUnit, durationUnit); this.hosts = hosts; this.index = index; this.bulkSize = bulkSize; this.clock = clock; this.prefix = prefix; this.timeout = timeout; if (indexDateFormat != null && indexDateFormat.length() > 0) { this.indexDateFormat = new SimpleDateFormat(indexDateFormat); } if (percolationNotifier != null && percolationFilter != null) { this.percolationFilter = percolationFilter; this.notifier = percolationNotifier; } if (timestampFieldname == null || timestampFieldname.trim().length() == 0) { LOGGER.error("Timestampfieldname {} is not valid, using default @timestamp", timestampFieldname); timestampFieldname = "@timestamp"; } objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); objectMapper.configure(SerializationFeature.CLOSE_CLOSEABLE, false); // auto closing means, that the objectmapper is closing after the first write call, which does not work for bulk requests objectMapper.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false); objectMapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false); objectMapper.registerModule(new MetricsElasticsearchModule(rateUnit, durationUnit, timestampFieldname)); writer = objectMapper.writer(); checkForIndexTemplate(); }
Example #8
Source File: GraphiteReporter.java From styx with Apache License 2.0 | 5 votes |
private GraphiteReporter(MetricRegistry registry, GraphiteSender graphite, Clock clock, String prefix, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter) { super(registry, "graphite-reporter", filter, rateUnit, durationUnit); this.graphite = graphite; this.clock = clock; this.prefix = prefix; }
Example #9
Source File: DelegatingDerivingMeterTest.java From semantic-metrics with Apache License 2.0 | 5 votes |
private void setupRateTest() throws InterruptedException { Clock clock = mock(Clock.class); meter = new DelegatingDerivingMeter(new Meter(clock)); when(clock.getTick()).thenReturn(0L); meter.mark(0); meter.mark(2000); // need to 'wait' more than 5 seconds for the Codahale metrics meter to 'tick'. when(clock.getTick()).thenReturn(TimeUnit.NANOSECONDS.convert(6, TimeUnit.SECONDS)); }
Example #10
Source File: MetricsConfigTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testDefaults() throws Exception { NodeConfig cfg = loadNodeConfig(); SolrMetricManager mgr = new SolrMetricManager(cfg.getSolrResourceLoader(), cfg.getMetricsConfig()); assertTrue(mgr.getCounterSupplier() instanceof MetricSuppliers.DefaultCounterSupplier); assertTrue(mgr.getMeterSupplier() instanceof MetricSuppliers.DefaultMeterSupplier); assertTrue(mgr.getTimerSupplier() instanceof MetricSuppliers.DefaultTimerSupplier); assertTrue(mgr.getHistogramSupplier() instanceof MetricSuppliers.DefaultHistogramSupplier); Clock clk = ((MetricSuppliers.DefaultTimerSupplier)mgr.getTimerSupplier()).clk; assertTrue(clk instanceof Clock.UserTimeClock); Reservoir rsv = ((MetricSuppliers.DefaultTimerSupplier)mgr.getTimerSupplier()).getReservoir(); assertTrue(rsv instanceof ExponentiallyDecayingReservoir); }
Example #11
Source File: TestReporter.java From micro-server with Apache License 2.0 | 5 votes |
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 #12
Source File: CloudWatchReporter.java From codahale-aggregated-metrics-cloudwatch-reporter with MIT License | 5 votes |
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 #13
Source File: ExtendedMeter.java From datacollector with Apache License 2.0 | 5 votes |
public ExtendedMeter(Clock clock) { super(clock); this.clock = clock; this.lastTick = new AtomicLong(this.clock.getTick()); m30Rate = new EWMA(M30_ALPHA, INTERVAL, TimeUnit.SECONDS); h1Rate = new EWMA(H1_ALPHA, INTERVAL, TimeUnit.SECONDS); h6Rate = new EWMA(H6_ALPHA, INTERVAL, TimeUnit.SECONDS); h12Rate = new EWMA(H12_ALPHA, INTERVAL, TimeUnit.SECONDS); h24Rate = new EWMA(H24_ALPHA, INTERVAL, TimeUnit.SECONDS); }
Example #14
Source File: OutputStreamReporter.java From incubator-gobblin with Apache License 2.0 | 5 votes |
protected Builder() { this.name = "OutputStreamReporter"; this.output = System.out; this.locale = Locale.getDefault(); this.clock = Clock.defaultClock(); this.timeZone = TimeZone.getDefault(); }
Example #15
Source File: NewtsReporter.java From newts with Apache License 2.0 | 5 votes |
private Builder(MetricRegistry registry) { this.registry = registry; this.rateUnit = TimeUnit.SECONDS; this.durationUnit = TimeUnit.MILLISECONDS; this.clock = Clock.defaultClock(); this.filter = MetricFilter.ALL; }
Example #16
Source File: NewtsReporter.java From newts with Apache License 2.0 | 5 votes |
private NewtsReporter(MetricRegistry registry, SampleRepository repository, String name, TimeUnit rateUnit, TimeUnit durationUnit, Clock clock, MetricFilter filter) { super(registry, "newts-reporter", filter, rateUnit, durationUnit); this.repository = repository; this.name = name; this.clock = clock; }
Example #17
Source File: QuotaManagerTest.java From ambry with Apache License 2.0 | 5 votes |
/** * A helper function to create quotaMap with controllable clock. */ private Map<RestMethod, RejectThrottler> createQuotaMock(FrontendConfig frontendConfig, Clock clock) { JSONObject quota = new JSONObject(frontendConfig.restRequestQuota); Map<RestMethod, RejectThrottler> quotaMap = new HashMap<>(); for (RestMethod restMethod : RestMethod.values()) { int restMethodQuota = quota.optInt(restMethod.name(), -1); quotaMap.put(restMethod, new RejectThrottler(restMethodQuota, new Meter(clock))); } return quotaMap; }
Example #18
Source File: CachedHistogram.java From ambry with Apache License 2.0 | 5 votes |
/** * Exposed for testing. * @param clock the {@link Clock} to use for the {@link CachedGauge}. * @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. */ CachedHistogram(Clock clock, Reservoir reservoir, long timeoutMs, double quantile) { super(reservoir); cache = new CachedGauge<Double>(clock, timeoutMs, TimeUnit.MILLISECONDS) { @Override protected Double loadValue() { return getSnapshot().getValue(quantile); } }; }
Example #19
Source File: ElasticsearchReporter.java From oneops with Apache License 2.0 | 5 votes |
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 #20
Source File: MetricReporter.java From sofa-jraft with Apache License 2.0 | 5 votes |
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 #21
Source File: ElasticsearchReporter.java From oneops with Apache License 2.0 | 4 votes |
/** * Inject your custom definition of how time passes. Usually the default clock is sufficient */ public Builder withClock(Clock clock) { this.clock = clock; return this; }
Example #22
Source File: ResettableTimer.java From bistoury with GNU General Public License v3.0 | 4 votes |
public ResettableTimer(Clock clock, double[] percentiles, int timerSize) { this.meter = new Meter(clock); this.timer = new StatsBuffer(timerSize, percentiles); }
Example #23
Source File: FlinkMeterWrapper.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public FlinkMeterWrapper(Meter meter, Clock clock) { super(clock); this.meter = meter; }
Example #24
Source File: ResettingHistogram.java From signalfx-java with Apache License 2.0 | 4 votes |
public ResettingHistogram(int size, double alpha, Clock clock) { super(new ResettingExponentiallyDecayingReservoir(size, alpha, clock)); }
Example #25
Source File: ResettingTimer.java From signalfx-java with Apache License 2.0 | 4 votes |
public ResettingTimer(Clock clock) { super(new ResettingExponentiallyDecayingReservoir(), clock); }
Example #26
Source File: FlinkMeterWrapper.java From flink with Apache License 2.0 | 4 votes |
public FlinkMeterWrapper(Meter meter, Clock clock) { super(clock); this.meter = meter; }
Example #27
Source File: FlinkMeterWrapper.java From flink with Apache License 2.0 | 4 votes |
public FlinkMeterWrapper(Meter meter, Clock clock) { super(clock); this.meter = meter; }
Example #28
Source File: TaggedCachedGauge.java From metrics-opentsdb with Apache License 2.0 | 4 votes |
protected TaggedCachedGauge(long timeout, TimeUnit timeoutUnit) { this(Clock.defaultClock(), timeout, timeoutUnit); }
Example #29
Source File: TaggedCachedGauge.java From metrics-opentsdb with Apache License 2.0 | 4 votes |
protected TaggedCachedGauge(Clock clock, long timeout, TimeUnit timeoutUnit) { super(clock, timeout, timeoutUnit); }
Example #30
Source File: IrisMetricSet.java From arcusplatform with Apache License 2.0 | 4 votes |
public Meter meter(Clock clock) { return new Meter(clock); }