Refine search
/** * Logs the timing for a metric * * @param fullTimerName The full name of timer * @param duration The log time duration time value * @param timeUnit The log time duration time unit */ private void addValueToTimer(String fullTimerName, final long duration, final TimeUnit timeUnit) { final MetricName metricName = new MetricName(_clazz, fullTimerName); com.yammer.metrics.core.Timer timer = MetricsHelper.newTimer(_metricsRegistry, metricName, TimeUnit.MILLISECONDS, TimeUnit.SECONDS); MetricsHelper.newTimer(_metricsRegistry, metricName, TimeUnit.MILLISECONDS, TimeUnit.SECONDS) .update(duration, timeUnit); }
context.brokerId(), metricName, timer.fiveMinuteRate()); context.reporter().sendCruiseControlMetric(ccm); context.brokerId(), metricName, timer.max(), MetricsUtils.ATTRIBUTE_MAX); context.reporter().sendCruiseControlMetric(ccm); context.brokerId(), metricName, timer.mean(), MetricsUtils.ATTRIBUTE_MEAN); context.reporter().sendCruiseControlMetric(ccm); Snapshot snapshot = timer.getSnapshot(); snapshot.getMedian(), MetricsUtils.ATTRIBUTE_50TH_PERCENTILE); context.reporter().sendCruiseControlMetric(ccm); context.brokerId(), metricName, snapshot.get999thPercentile(), MetricsUtils.ATTRIBUTE_999TH_PERCENTILE); context.reporter().sendCruiseControlMetric(ccm);
@Override public void processTimer(MetricName name, Timer timer, PrintStream stream) { processMeter(name, timer, stream); final String durationUnit = abbrev(timer.durationUnit()); final Snapshot snapshot = timer.getSnapshot(); stream.printf(locale, " min = %2.2f%s\n", timer.min(), durationUnit); stream.printf(locale, " max = %2.2f%s\n", timer.max(), durationUnit); stream.printf(locale, " mean = %2.2f%s\n", timer.mean(), durationUnit); stream.printf(locale, " stddev = %2.2f%s\n", timer.stdDev(), durationUnit); stream.printf(locale, " median = %2.2f%s\n", snapshot.getMedian(), durationUnit); stream.printf(locale, " 75%% <= %2.2f%s\n", snapshot.get75thPercentile(), durationUnit); stream.printf(locale, " 95%% <= %2.2f%s\n", snapshot.get95thPercentile(), durationUnit); stream.printf(locale, " 98%% <= %2.2f%s\n", snapshot.get98thPercentile(), durationUnit); stream.printf(locale, " 99%% <= %2.2f%s\n", snapshot.get99thPercentile(), durationUnit); stream.printf(locale, " 99.9%% <= %2.2f%s\n", snapshot.get999thPercentile(), durationUnit); }
@Test public void reportsTimerValues() throws Exception { final Timer timer = mock(Timer.class); when(timer.eventType()).thenReturn("events"); when(timer.durationUnit()).thenReturn(TimeUnit.MILLISECONDS); when(timer.rateUnit()).thenReturn(TimeUnit.SECONDS); when(timer.count()).thenReturn(1L); when(timer.meanRate()).thenReturn(2.0); when(timer.oneMinuteRate()).thenReturn(3.0); when(timer.fiveMinuteRate()).thenReturn(4.0); when(timer.fifteenMinuteRate()).thenReturn(5.0); when(timer.max()).thenReturn(2.0); when(timer.mean()).thenReturn(3.0); when(timer.min()).thenReturn(4.0); when(timer.stdDev()).thenReturn(5.0); when(snapshot.getMedian()).thenReturn((double) 500); when(snapshot.get75thPercentile()).thenReturn((double) 600); when(snapshot.get95thPercentile()).thenReturn((double) 700); when(snapshot.get98thPercentile()).thenReturn((double) 800); when(snapshot.get99thPercentile()).thenReturn((double) 900); when(snapshot.get999thPercentile()).thenReturn((double) 1000); when(timer.getSnapshot()).thenReturn(snapshot);
@Override public Future submit( final Collection<Count> counts ) { return executor.submit( new Callable<Object>() { final TimerContext timer = addTimer.time(); @Override public Object call() throws Exception { cassandraCounterStore.save( counts ); timer.stop(); return true; } } ); }
@Override public void processTimer(MetricName name, Timer timer, Long timestamp) { Map<String, Double> fields = new HashMap<String, Double>(); fields.put("Count", Double.valueOf(timer.count())); fields.put("MeanRate", timer.meanRate()); fields.put("FifteenMinuteRate", timer.fifteenMinuteRate()); fields.put("FiveMinuteRate", timer.fiveMinuteRate()); fields.put("OneMinuteRate", timer.oneMinuteRate()); fields.put("Max", timer.max()); fields.put("Mean", timer.mean()); fields.put("Min", timer.min()); fields.put("StdDev", timer.stdDev()); fields.put("Sum", timer.sum()); publish(createMeasurement(name, timestamp, fixedTags, fields)); }
@Override public double get50thPercentile() { return metric.getSnapshot().getMedian(); }
@Override public double get999thPercentile() { return metric.getSnapshot().get999thPercentile(); }
@Override public void processTimer(MetricName name, Timer timer, Context context) throws Exception { final JsonGenerator json = context.json; json.writeStartObject(); { json.writeFieldName("duration"); json.writeStartObject(); { json.writeStringField("unit", timer.durationUnit().toString().toLowerCase()); writeSummarizable(timer, json); writeSampling(timer, json); if (context.showFullSamples) { json.writeObjectField("values", timer.getSnapshot().getValues()); } } json.writeEndObject(); json.writeFieldName("rate"); json.writeStartObject(); { writeMeteredFields(timer, json); } json.writeEndObject(); } json.writeEndObject(); if (clear) timer.clear(); } }
@Override public double get95thPercentile() { return metric.getSnapshot().get95thPercentile(); }
@Override public double get99thPercentile() { return metric.getSnapshot().get99thPercentile(); }
@Override public double get75thPercentile() { return metric.getSnapshot().get75thPercentile(); }
@Override public double get98thPercentile() { return metric.getSnapshot().get98thPercentile(); }
@Override public void processTimer(MetricName name, Timer timer, Context context) throws Exception { final JsonGenerator json = context.json; json.writeStartObject(); { json.writeStringField("type", "timer"); json.writeFieldName("duration"); json.writeStartObject(); { json.writeStringField("unit", timer.durationUnit().toString().toLowerCase()); writeSummarizable(timer, json); writeSampling(timer, json); if (context.showFullSamples) { json.writeObjectField("values", timer.getSnapshot().getValues()); } } json.writeEndObject(); json.writeFieldName("rate"); json.writeStartObject(); { writeMeteredFields(timer, json); } json.writeEndObject(); } json.writeEndObject(); }
public void run() { SpeculativeRetry retryPolicy = ColumnFamilyStore.this.metadata.getSpeculativeRetry(); switch (retryPolicy.type) { case PERCENTILE: // get percentile in nanos assert metric.coordinatorReadLatency.durationUnit() == TimeUnit.MICROSECONDS; sampleLatencyNanos = (long) (metric.coordinatorReadLatency.getSnapshot().getValue(retryPolicy.value) * 1000d); break; case CUSTOM: // convert to nanos, since configuration is in millisecond sampleLatencyNanos = (long) (retryPolicy.value * 1000d * 1000d); break; default: sampleLatencyNanos = Long.MAX_VALUE; break; } } }, DatabaseDescriptor.getReadRpcTimeout(), DatabaseDescriptor.getReadRpcTimeout(), TimeUnit.MILLISECONDS);
@Override public double[] values() { return metric.getSnapshot().getValues(); } }
/** MBean related methods */ public long getOperations() { return metric.latency.count(); }
@Override public double getMean() { return metric.mean(); }