@Override public String toString() { return "NettyServerMetric [_requestsReceived=" + _requestsReceived.count() + ", _bytesSent=" + _bytesSent.count() + ", _bytesReceived=" + _bytesReceived.count() + ", _errors=" + _errors.count() + ", _sendResponseMsGauge=" + _sendResponseMsHistogram.count() + ", _processingLatencyMsGauge=" + _processingLatencyMsHistogram.count() + "]"; }
@Override public String toString() { return "NettyClientMetric [_requestsSent=" + _requestsSent.count() + ", _bytesSent=" + _bytesSent.count() + ", _bytesReceived=" + _bytesReceived.count() + ", _errors=" + _errors.count() + ", _sendRequestMsGauge=" + _sendRequestMsHistogram.count() + ", _responseLatencyMsGauge=" + _responseLatencyMsHistogram.count() + ", _connectMsGauge=" + _connectMsGauge.value() + "]"; }
@Override public long count() { return histogram.count(); }
@Override public long getCount() { return metric.count(); }
@Override public double max() { if (count() > 0) { return max.get(); } return 0.0; }
@Override public double min() { if (count() > 0) { return min.get(); } return 0.0; }
private void updateVariance(long value) { while (true) { final double[] oldValues = variance.get(); final double[] newValues = new double[2]; if (oldValues[0] == -1) { newValues[0] = value; newValues[1] = 0; } else { final double oldM = oldValues[0]; final double oldS = oldValues[1]; final double newM = oldM + ((value - oldM) / count()); final double newS = oldS + ((value - oldM) * (value - newM)); newValues[0] = newM; newValues[1] = newS; } if (variance.compareAndSet(oldValues, newValues)) { return; } } }
@Override public double stdDev() { if (count() > 0) { return sqrt(variance()); } return 0.0; }
@Override public void processHistogram(MetricName name, Histogram histogram, PrintStream stream) { super.processHistogram(name, histogram, stream); stream.printf(Locale.getDefault(), " count = %d%n", histogram.count()); } }
@Override public void processHistogram(MetricName name, Histogram histogram, PrintStream stream) { stream.printf(" sum = %,2.2f%n", histogram.sum()); super.processHistogram(name, histogram, stream); stream.printf(" count = %d%n", histogram.count()); } } .run();
private void internalProcessYammerHistogram(Histogram histogram, Context context) throws Exception { final JsonGenerator json = context.json; json.writeStartObject(); { json.writeNumberField("count", histogram.count()); writeSummarizable(histogram, json); writeSampling(histogram, json); if (context.showFullSamples) { json.writeObjectField("values", histogram.getSnapshot().getValues()); } if (clear) histogram.clear(); } json.writeEndObject(); }
private void internalProcessYammerHistogram(Histogram histogram, Context context) throws Exception { final JsonGenerator json = context.json; json.writeStartObject(); { json.writeNumberField("count", histogram.count()); writeSummarizable(histogram, json); writeSampling(histogram, json); if (context.showFullSamples) { json.writeObjectField("values", histogram.getSnapshot().getValues()); } if (clear) histogram.clear(); } json.writeEndObject(); }
@Override public void processHistogram(MetricName name, Histogram histogram, Context context) throws Exception { final JsonGenerator json = context.json; json.writeStartObject(); { json.writeStringField("type", "histogram"); json.writeNumberField("count", histogram.count()); writeSummarizable(histogram, json); writeSampling(histogram, json); if (context.showFullSamples) { json.writeObjectField("values", histogram.getSnapshot().getValues()); } } json.writeEndObject(); }
/** * @return bytes per minute for requests submissions. Null if no data is available yet. */ @Nullable public Long getBytesPerMinute() { if (resultPostingMeter.fifteenMinuteRate() == 0 || resultPostingSizes.mean() == 0 || resultPostingSizes.count() < 50) { return null; } return (long) (resultPostingSizes.mean() * resultPostingMeter.fifteenMinuteRate()); }
/** * @return bytes per minute for requests submissions. Null if no data is available yet. */ @Nullable public Long getBytesPerMinute() { if (resultPostingMeter.fifteenMinuteRate() == 0 || resultPostingSizes.mean() == 0 || resultPostingSizes.count() < 50) { return null; } return (long) (resultPostingSizes.mean() * resultPostingMeter.fifteenMinuteRate()); }
@Override public void processHistogram(MetricName name, Histogram histogram, Long timestamp) { Map<String, Double> fields = new HashMap<String, Double>(); fields.put("Count", Double.valueOf(histogram.count())); fields.put("Max", histogram.max()); fields.put("Mean", histogram.mean()); fields.put("Min", histogram.min()); fields.put("StdDev", histogram.stdDev()); fields.put("Sum", histogram.sum()); Snapshot snapshot = histogram.getSnapshot(); fields.put("95thPercentile", snapshot.get95thPercentile()); fields.put("98thPercentile", snapshot.get98thPercentile()); fields.put("99thPercentile", snapshot.get99thPercentile()); fields.put("999thPercentile", snapshot.get999thPercentile()); publish(createMeasurement(name, timestamp, fixedTags, fields)); }
@Test public void testUpdateMetric_Histogram_Biased() { jsonMetric.setType("biased"); Histogram metric = (Histogram) metricCatcher.createMetric(jsonMetric); metricCatcher.updateMetric(metric, 1); assertEquals(1, metric.count()); }
@Test public void testUpdateMetric_Histogram_MultipleUpdates() { jsonMetric.setType("biased"); Histogram metric = (Histogram) metricCatcher.createMetric(jsonMetric); int count = 7; for (int x = 0; x < 7; x++) { metricCatcher.updateMetric(metric, 1); } assertEquals(count, metric.count()); }