Refine search![Refine arrow](//d16xvuom8mr9m8.cloudfront.net/code/public/images/refine-arrow.226bef887e7b1c430d6d498717d9d561.svg)
public void addRequestResponseStats(long bytesSent, long numRequests, long bytesReceived, boolean isError, long sendRequestMs, long responseLatencyMs) { _requestsSent.inc(numRequests); _bytesSent.inc(bytesSent); _bytesReceived.inc(bytesReceived); if (isError) { _errors.inc(); } _sendRequestMsHistogram.update(sendRequestMs); _responseLatencyMsHistogram.update(responseLatencyMs); }
context.brokerId(), metricName, histogram.max(), MetricsUtils.ATTRIBUTE_MAX); context.reporter().sendCruiseControlMetric(ccm); context.brokerId(), metricName, histogram.mean(), MetricsUtils.ATTRIBUTE_MEAN); context.reporter().sendCruiseControlMetric(ccm); Snapshot snapshot = histogram.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 String toString() { return "NettyServerMetric [_requestsReceived=" + _requestsReceived.count() + ", _bytesSent=" + _bytesSent.count() + ", _bytesReceived=" + _bytesReceived.count() + ", _errors=" + _errors.count() + ", _sendResponseMsGauge=" + _sendResponseMsHistogram.count() + ", _processingLatencyMsGauge=" + _processingLatencyMsHistogram.count() + "]"; }
if (hist instanceof Histogram) { Histogram h = (Histogram) hist; _min = Math.min(_min, h.min()); _max = Math.max(_max, h.max()); _sum += h.sum(); meanSum += h.mean(); } else { AggregatedHistogram<Sampling> h = (AggregatedHistogram<Sampling>) hist; meanSum += h.mean(); double[] val = hist.getSnapshot().getValues(); for (double d : val) { values.add(d); _snapshot = new Snapshot(vals);
@Override public void processHistogram(MetricName name, Histogram histogram, PrintStream stream) { final Snapshot snapshot = histogram.getSnapshot(); stream.printf(locale, " min = %2.2f\n", histogram.min()); stream.printf(locale, " max = %2.2f\n", histogram.max()); stream.printf(locale, " mean = %2.2f\n", histogram.mean()); stream.printf(locale, " stddev = %2.2f\n", histogram.stdDev()); stream.printf(locale, " median = %2.2f\n", snapshot.getMedian()); stream.printf(locale, " 75%% <= %2.2f\n", snapshot.get75thPercentile()); stream.printf(locale, " 95%% <= %2.2f\n", snapshot.get95thPercentile()); stream.printf(locale, " 98%% <= %2.2f\n", snapshot.get98thPercentile()); stream.printf(locale, " 99%% <= %2.2f\n", snapshot.get99thPercentile()); stream.printf(locale, " 99.9%% <= %2.2f\n", snapshot.get999thPercentile()); }
@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)); }
@Override public String toString() { Snapshot snapshot = this.age.getSnapshot(); return "count=" + count + ", dataBlockCount=" + this.dataBlockCount + ", size=" + size + ", dataSize=" + getDataSize() + ", mean age=" + this.age.mean() + ", stddev age=" + this.age.stdDev() + ", min age=" + this.age.min() + ", max age=" + this.age.max() + ", 95th percentile age=" + snapshot.get95thPercentile() + ", 99th percentile age=" + snapshot.get99thPercentile(); } }
@Override public double get50thPercentile() { return metric.getSnapshot().getMedian(); }
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 double get999thPercentile() { return metric.getSnapshot().get999thPercentile(); }
@Override public double get99thPercentile() { return metric.getSnapshot().get99thPercentile(); }
@Override public double get95thPercentile() { return metric.getSnapshot().get95thPercentile(); }
@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()); }
@Test public void testRun_MultipleUpdatePackets_Histograms() throws IOException, InterruptedException { String json; byte[] jsonBytes; double minVal = 2; double maxVal = 7; long timestamp = System.currentTimeMillis() / 1000L; json = "[" + "{\"name\":\"" + metricName + "\",\"value\":" + maxVal + "," + "\"type\":\"biased\"," + "\"timestamp\":" + timestamp++ + "}" + "]"; jsonBytes = json.getBytes(); sendingSocket.send(new DatagramPacket(jsonBytes, jsonBytes.length, localhost, listeningSocket.getLocalPort())); json = "[" + "{\"name\":\"" + metricName + "\",\"value\":" + minVal + "," + "\"type\":\"biased\"," + "\"timestamp\":" + timestamp++ + "}" + "]"; jsonBytes = json.getBytes(); sendingSocket.send(new DatagramPacket(jsonBytes, jsonBytes.length, localhost, listeningSocket.getLocalPort())); metricCatcher.start(); Thread.sleep(500); metricCatcher.shutdown(); assertEquals(2, ((Histogram) metricCache.get(metricName)).count()); assertEquals(minVal, ((Histogram) metricCache.get(metricName)).min(), 0); assertEquals(maxVal, ((Histogram) metricCache.get(metricName)).max(), 0); }
@Override public double get75thPercentile() { return metric.getSnapshot().get75thPercentile(); }
@Override public void processHistogram(MetricName name, Histogram histogram, Void context) throws Exception { if (histogram instanceof WavefrontHistogram) { WavefrontHistogram wavefrontHistogram = (WavefrontHistogram) histogram; List<WavefrontHistogram.MinuteBin> bins = wavefrontHistogram.bins(clear); if (bins.isEmpty()) return; // don't send empty histograms. for (WavefrontHistogram.MinuteBin minuteBin : bins) { StringBuilder sb = new StringBuilder(); sb.append("!M ").append(minuteBin.getMinMillis() / 1000); for (Centroid c : minuteBin.getDist().centroids()) { sb.append(" #").append(c.count()).append(" ").append(c.mean()); } sb.append(" \"").append(getName(name)).append("\"").append(tagsForMetricName(name)).append("\n"); histogramsSocket.write(sb.toString()); } } else { if (!sendEmptyHistograms && histogram.count() == 0) { // send count still but skip the others. writeMetric(name, "count", 0); } else { writeMetric(name, "count", histogram.count()); writeSampling(name, histogram); writeSummarizable(name, histogram); if (clear) histogram.clear(); } } }
@Override public double get98thPercentile() { return metric.getSnapshot().get98thPercentile(); }
@Override public Snapshot getSnapshot() { final double[] values = histogram.getSnapshot().getValues(); final double[] converted = new double[values.length]; for (int i = 0; i < values.length; i++) { converted[i] = convertFromNS(values[i]); } return new Snapshot(converted); }