Java Code Examples for com.codahale.metrics.Histogram#getSnapshot()
The following examples show how to use
com.codahale.metrics.Histogram#getSnapshot() .
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: MqMetricReporter.java From pmq with Apache License 2.0 | 6 votes |
private Set<Metric> buildHistograms(String name, Histogram histogram, long timestamp, Map<String, String> tags) { final MetricsCollector collector = MetricsCollector.createNew(name, tags, timestamp); final Snapshot snapshot = histogram.getSnapshot(); if (getChangeCount(name, histogram.getCount()) == 0) { return Collections.emptySet(); } return collector.addMetric("count", histogram.getCount()) .addMetric("max", snapshot.getMax()) .addMetric("min", snapshot.getMin()) .addMetric("mean", snapshot.getMean()) .addMetric("stddev", snapshot.getStdDev()) .addMetric("median", snapshot.getMedian()) .addMetric("p75", snapshot.get75thPercentile()) .addMetric("p95", snapshot.get95thPercentile()) .addMetric("p98", snapshot.get98thPercentile()) .addMetric("p99", snapshot.get99thPercentile()) .addMetric("p999", snapshot.get999thPercentile()) .build(); }
Example 2
Source File: MetricReporter.java From sofa-jraft with Apache License 2.0 | 6 votes |
private void printHistogram(final Histogram histogram) { printIfEnabled(MetricAttribute.COUNT, String.format(this.locale, " count = %d", histogram.getCount())); final Snapshot snapshot = histogram.getSnapshot(); printIfEnabled(MetricAttribute.MIN, String.format(this.locale, " min = %d", snapshot.getMin())); printIfEnabled(MetricAttribute.MAX, String.format(this.locale, " max = %d", snapshot.getMax())); printIfEnabled(MetricAttribute.MEAN, String.format(this.locale, " mean = %2.2f", snapshot.getMean())); printIfEnabled(MetricAttribute.STDDEV, String.format(this.locale, " stddev = %2.2f", snapshot.getStdDev())); printIfEnabled(MetricAttribute.P50, String.format(this.locale, " median = %2.2f", snapshot.getMedian())); printIfEnabled(MetricAttribute.P75, String.format(this.locale, " 75%% <= %2.2f", snapshot.get75thPercentile())); printIfEnabled(MetricAttribute.P95, String.format(this.locale, " 95%% <= %2.2f", snapshot.get95thPercentile())); printIfEnabled(MetricAttribute.P98, String.format(this.locale, " 98%% <= %2.2f", snapshot.get98thPercentile())); printIfEnabled(MetricAttribute.P99, String.format(this.locale, " 99%% <= %2.2f", snapshot.get99thPercentile())); printIfEnabled(MetricAttribute.P999, String.format(this.locale, " 99.9%% <= %2.2f", snapshot.get999thPercentile())); }
Example 3
Source File: MqMetricReporter.java From pmq with Apache License 2.0 | 6 votes |
private Set<Metric> buildHistograms(String name, Histogram histogram, long timestamp, Map<String, String> tags) { final MetricsCollector collector = MetricsCollector.createNew(name, tags, timestamp); final Snapshot snapshot = histogram.getSnapshot(); if (getChangeCount(name, histogram.getCount()) == 0) { return Collections.emptySet(); } return collector.addMetric("count", histogram.getCount()) .addMetric("max", snapshot.getMax()) .addMetric("min", snapshot.getMin()) .addMetric("mean", snapshot.getMean()) .addMetric("stddev", snapshot.getStdDev()) .addMetric("median", snapshot.getMedian()) .addMetric("p75", snapshot.get75thPercentile()) .addMetric("p95", snapshot.get95thPercentile()) .addMetric("p98", snapshot.get98thPercentile()) .addMetric("p99", snapshot.get99thPercentile()) .addMetric("p999", snapshot.get999thPercentile()) .build(); }
Example 4
Source File: PlatformDriverExecutorRegistry.java From arcusplatform with Apache License 2.0 | 6 votes |
private Map<String, Object> queueBacklog() { Histogram backlog = new Histogram(new UniformReservoir(64)); for(DriverExecutor executor: executorCache.asMap().values()) { backlog.update(((DefaultDriverExecutor) executor).getQueuedMessageCount()); } Snapshot snap = backlog.getSnapshot(); return ImmutableMap .<String, Object>builder() .put("count", backlog.getCount()) .put("min", snap.getMin()) .put("max", snap.getMax()) .put("mean", snap.getMean()) .put("stddev", snap.getStdDev()) .put("p50", snap.getMedian()) .put("p75", snap.get75thPercentile()) .put("p95", snap.get95thPercentile()) .put("p98", snap.get98thPercentile()) .put("p99", snap.get99thPercentile()) .put("p999", snap.get999thPercentile()) .build(); }
Example 5
Source File: MetricsModule.java From hugegraph with Apache License 2.0 | 6 votes |
@Override public void serialize(Histogram histogram, JsonGenerator json, SerializerProvider provider) throws IOException { json.writeStartObject(); final Snapshot snapshot = histogram.getSnapshot(); json.writeNumberField("count", histogram.getCount()); json.writeNumberField("max", snapshot.getMax()); json.writeNumberField("mean", snapshot.getMean()); json.writeNumberField("min", snapshot.getMin()); json.writeNumberField("p50", snapshot.getMedian()); json.writeNumberField("p75", snapshot.get75thPercentile()); json.writeNumberField("p95", snapshot.get95thPercentile()); json.writeNumberField("p98", snapshot.get98thPercentile()); json.writeNumberField("p99", snapshot.get99thPercentile()); json.writeNumberField("p999", snapshot.get999thPercentile()); if (this.showSamples) { json.writeObjectField("values", snapshot.getValues()); } json.writeNumberField("stddev", snapshot.getStdDev()); json.writeEndObject(); }
Example 6
Source File: InfluxDbReporter.java From dropwizard-metrics-influxdb with Apache License 2.0 | 6 votes |
private void reportHistogram(String name, Histogram histogram, long now) { if (canSkipMetric(name, histogram)) { return; } final Snapshot snapshot = histogram.getSnapshot(); Map<String, Object> fields = new HashMap<String, Object>(); fields.put("count", histogram.getCount()); fields.put("min", snapshot.getMin()); fields.put("max", snapshot.getMax()); fields.put("mean", snapshot.getMean()); fields.put("stddev", snapshot.getStdDev()); fields.put("p50", snapshot.getMedian()); fields.put("p75", snapshot.get75thPercentile()); fields.put("p95", snapshot.get95thPercentile()); fields.put("p98", snapshot.get98thPercentile()); fields.put("p99", snapshot.get99thPercentile()); fields.put("p999", snapshot.get999thPercentile()); influxDb.appendPoints( new InfluxDbPoint( getMeasurementName(name), getTags(name), now, fields)); }
Example 7
Source File: MetricsElasticsearchModule.java From oneops with Apache License 2.0 | 6 votes |
@Override public void serialize(JsonHistogram jsonHistogram, JsonGenerator json, SerializerProvider provider) throws IOException { json.writeStartObject(); json.writeStringField("name", jsonHistogram.name()); json.writeObjectField(timestampFieldname, jsonHistogram.timestampAsDate()); Histogram histogram = jsonHistogram.value(); final Snapshot snapshot = histogram.getSnapshot(); json.writeNumberField("count", histogram.getCount()); json.writeNumberField("max", snapshot.getMax()); json.writeNumberField("mean", snapshot.getMean()); json.writeNumberField("min", snapshot.getMin()); json.writeNumberField("p50", snapshot.getMedian()); json.writeNumberField("p75", snapshot.get75thPercentile()); json.writeNumberField("p95", snapshot.get95thPercentile()); json.writeNumberField("p98", snapshot.get98thPercentile()); json.writeNumberField("p99", snapshot.get99thPercentile()); json.writeNumberField("p999", snapshot.get999thPercentile()); json.writeNumberField("stddev", snapshot.getStdDev()); addOneOpsMetadata(json); json.writeEndObject(); }
Example 8
Source File: HistogramSerializer.java From watcher with Apache License 2.0 | 6 votes |
@Override public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException { Histogram histogram = (Histogram) object; SerializeWriter writer = serializer.getWriter(); final Snapshot snapshot = histogram.getSnapshot(); writer.writeFieldValue('{', "count", histogram.getCount()); writer.writeFieldValue(',', "max", snapshot.getMax()); writer.writeFieldValue(',', "mean", snapshot.getMean()); writer.writeFieldValue(',', "min", snapshot.getMin()); writer.writeFieldValue(',', "p50", snapshot.getMedian()); writer.writeFieldValue(',', "p75", snapshot.get75thPercentile()); writer.writeFieldValue(',', "p95", snapshot.get95thPercentile()); writer.writeFieldValue(',', "p98", snapshot.get98thPercentile()); writer.writeFieldValue(',', "p99", snapshot.get99thPercentile()); writer.writeFieldValue(',', "p999", snapshot.get999thPercentile()); writer.writeFieldValue(',', "stddev", snapshot.getStdDev()); writer.write('}'); }
Example 9
Source File: MetricsCloudWatchReporter.java From chassis with Apache License 2.0 | 6 votes |
private void addHistograms(SortedMap<String, Histogram> histograms, LinkedList<PutMetricDataRequest> requests, Date timestamp) { logger.debug("Adding Histograms..."); for (String name : histograms.keySet()) { Histogram histogram = histograms.get(name); Snapshot snapshot = histogram.getSnapshot(); checkAndAddDatum(MetricFilter.Stat.COUNT, name, histogram.getCount(), requests, timestamp); checkAndAddDatum(MetricFilter.Stat.MIN, name, snapshot.getMin(), requests, timestamp); checkAndAddDatum(MetricFilter.Stat.MAX, name, snapshot.getMax(), requests, timestamp); checkAndAddDatum(MetricFilter.Stat.MEAN, name, snapshot.getMean(), requests, timestamp); checkAndAddDatum(MetricFilter.Stat.STDDEV, name, snapshot.getStdDev(), requests, timestamp); checkAndAddDatum(MetricFilter.Stat.PERCENTILE_75, name, snapshot.get75thPercentile(), requests, timestamp); checkAndAddDatum(MetricFilter.Stat.PERCENTILE_95, name, snapshot.get95thPercentile(), requests, timestamp); checkAndAddDatum(MetricFilter.Stat.PERCENTILE_98, name, snapshot.get98thPercentile(), requests, timestamp); checkAndAddDatum(MetricFilter.Stat.PERCENTILE_99, name, snapshot.get99thPercentile(), requests, timestamp); checkAndAddDatum(MetricFilter.Stat.PERCENTILE_999, name, snapshot.get999thPercentile(), requests, timestamp); } }
Example 10
Source File: JBossLoggingReporter.java From hawkular-agent with Apache License 2.0 | 6 votes |
private String logHistogram(String name, Histogram histogram) { final Snapshot snapshot = histogram.getSnapshot(); return String.format( "%s: type=[histogram], count=[%d], min=[%d], max=[%d], mean=[%f], stddev=[%f], " + "median=[%f], p75=[%f], p95=[%f], p98=[%f], p99=[%f], p999=[%f]", name, histogram.getCount(), snapshot.getMin(), snapshot.getMax(), snapshot.getMean(), snapshot.getStdDev(), snapshot.getMedian(), snapshot.get75thPercentile(), snapshot.get95thPercentile(), snapshot.get98thPercentile(), snapshot.get99thPercentile(), snapshot.get999thPercentile()); }
Example 11
Source File: TestPerformanceEvaluation.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testZipfian() throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { TestOptions opts = new PerformanceEvaluation.TestOptions(); opts.setValueZipf(true); final int valueSize = 1024; opts.setValueSize(valueSize); RandomReadTest rrt = new RandomReadTest(null, opts, null); Constructor<?> ctor = Histogram.class.getDeclaredConstructor(com.codahale.metrics.Reservoir.class); ctor.setAccessible(true); Histogram histogram = (Histogram)ctor.newInstance(new UniformReservoir(1024 * 500)); for (int i = 0; i < 100; i++) { histogram.update(rrt.getValueLength(null)); } Snapshot snapshot = histogram.getSnapshot(); double stddev = snapshot.getStdDev(); assertTrue(stddev != 0 && stddev != 1.0); assertTrue(snapshot.getStdDev() != 0); double median = snapshot.getMedian(); assertTrue(median != 0 && median != 1 && median != valueSize); }
Example 12
Source File: WavefrontMetricsReporter.java From dropwizard-wavefront with Apache License 2.0 | 5 votes |
private void reportHistogram(JsonGenerator json, String name, Histogram histogram) throws IOException { Snapshot snapshot = histogram.getSnapshot(); json.writeFieldName(sanitize(name)); json.writeStartObject(); json.writeNumberField("count", histogram.getCount()); writeSnapshot(json, snapshot); json.writeEndObject(); }
Example 13
Source File: HFilePrettyPrinter.java From hbase with Apache License 2.0 | 5 votes |
private void printHistogram(Histogram histogram) { Snapshot snapshot = histogram.getSnapshot(); output.printf(locale, " min = %d%n", snapshot.getMin()); output.printf(locale, " max = %d%n", snapshot.getMax()); output.printf(locale, " mean = %2.2f%n", snapshot.getMean()); output.printf(locale, " stddev = %2.2f%n", snapshot.getStdDev()); output.printf(locale, " median = %2.2f%n", snapshot.getMedian()); output.printf(locale, " 75%% <= %2.2f%n", snapshot.get75thPercentile()); output.printf(locale, " 95%% <= %2.2f%n", snapshot.get95thPercentile()); output.printf(locale, " 98%% <= %2.2f%n", snapshot.get98thPercentile()); output.printf(locale, " 99%% <= %2.2f%n", snapshot.get99thPercentile()); output.printf(locale, " 99.9%% <= %2.2f%n", snapshot.get999thPercentile()); output.printf(locale, " count = %d%n", histogram.getCount()); }
Example 14
Source File: YammerHistogramUtils.java From hbase with Apache License 2.0 | 5 votes |
/** @return a summary of {@code hist}. */ public static String getHistogramReport(final Histogram hist) { Snapshot sn = hist.getSnapshot(); return "mean=" + DOUBLE_FORMAT.format(sn.getMean()) + ", min=" + DOUBLE_FORMAT.format(sn.getMin()) + ", max=" + DOUBLE_FORMAT.format(sn.getMax()) + ", stdDev=" + DOUBLE_FORMAT.format(sn.getStdDev()) + ", 50th=" + DOUBLE_FORMAT.format(sn.getMedian()) + ", 75th=" + DOUBLE_FORMAT.format(sn.get75thPercentile()) + ", 95th=" + DOUBLE_FORMAT.format(sn.get95thPercentile()) + ", 99th=" + DOUBLE_FORMAT.format(sn.get99thPercentile()) + ", 99.9th=" + DOUBLE_FORMAT.format(sn.get999thPercentile()) + ", 99.99th=" + DOUBLE_FORMAT.format(sn.getValue(0.9999)) + ", 99.999th=" + DOUBLE_FORMAT.format(sn.getValue(0.99999)); }
Example 15
Source File: TimelineServerPerf.java From hudi with Apache License 2.0 | 5 votes |
private static PerfStats runOneRound(SyncableFileSystemView fsView, String partition, String fileId, int id, int numIterations) { Histogram latencyHistogram = new Histogram(new UniformReservoir(10000)); for (int i = 0; i < numIterations; i++) { long beginTs = System.currentTimeMillis(); Option<FileSlice> c = fsView.getLatestFileSlice(partition, fileId); long endTs = System.currentTimeMillis(); System.out.println("Latest File Slice for part=" + partition + ", fileId=" + fileId + ", Slice=" + c + ", Time=" + (endTs - beginTs)); latencyHistogram.update(endTs - beginTs); } return new PerfStats(partition, id, latencyHistogram.getSnapshot()); }
Example 16
Source File: HistogramSnapshotExtractionBenchmark.java From rolling-metrics with Apache License 2.0 | 5 votes |
private static Map<String, Object> getSnaphsotRepresentation(Histogram histogram) { Map<String, Object> view = new HashMap<>(); Snapshot snapshot = histogram.getSnapshot(); view.put("max", snapshot.getMax()); view.put("min", snapshot.getMin()); view.put("mean", snapshot.getMean()); view.put("median", snapshot.getMedian()); view.put("stdDeviation", snapshot.getStdDev()); view.put("75", snapshot.get75thPercentile()); view.put("95", snapshot.get95thPercentile()); view.put("98", snapshot.get98thPercentile()); view.put("99", snapshot.get99thPercentile()); view.put("999", snapshot.get999thPercentile()); return view; }
Example 17
Source File: NewtsReporter.java From newts with Apache License 2.0 | 5 votes |
private void reportHistogram(List<Sample> samples, Timestamp timestamp, String name, Histogram histogram) { final Snapshot snapshot = histogram.getSnapshot(); reportC(samples, timestamp, name, "count", histogram.getCount()); reportG(samples, timestamp, name, "max", snapshot.getMax()); reportG(samples, timestamp, name, "mean", snapshot.getMean()); reportG(samples, timestamp, name, "min", snapshot.getMin()); reportG(samples, timestamp, name, "stddev", snapshot.getStdDev()); reportG(samples, timestamp, name, "p50", snapshot.getMedian()); reportG(samples, timestamp, name, "p75", snapshot.get75thPercentile()); reportG(samples, timestamp, name, "p95", snapshot.get95thPercentile()); reportG(samples, timestamp, name, "p98", snapshot.get98thPercentile()); reportG(samples, timestamp, name, "p99", snapshot.get99thPercentile()); reportG(samples, timestamp, name, "p999", snapshot.get999thPercentile()); }
Example 18
Source File: OutputStreamReporter.java From incubator-gobblin with Apache License 2.0 | 5 votes |
private void printHistogram(Histogram histogram) { this.outputBufferPrintStream.printf(locale, " count = %d%n", histogram.getCount()); Snapshot snapshot = histogram.getSnapshot(); this.outputBufferPrintStream.printf(locale, " min = %d%n", snapshot.getMin()); this.outputBufferPrintStream.printf(locale, " max = %d%n", snapshot.getMax()); this.outputBufferPrintStream.printf(locale, " mean = %2.2f%n", snapshot.getMean()); this.outputBufferPrintStream.printf(locale, " stddev = %2.2f%n", snapshot.getStdDev()); this.outputBufferPrintStream.printf(locale, " median = %2.2f%n", snapshot.getMedian()); this.outputBufferPrintStream.printf(locale, " 75%% <= %2.2f%n", snapshot.get75thPercentile()); this.outputBufferPrintStream.printf(locale, " 95%% <= %2.2f%n", snapshot.get95thPercentile()); this.outputBufferPrintStream.printf(locale, " 98%% <= %2.2f%n", snapshot.get98thPercentile()); this.outputBufferPrintStream.printf(locale, " 99%% <= %2.2f%n", snapshot.get99thPercentile()); this.outputBufferPrintStream.printf(locale, " 99.9%% <= %2.2f%n", snapshot.get999thPercentile()); }
Example 19
Source File: MqMetricReporter.java From pmq with Apache License 2.0 | 5 votes |
private Set<Metric> buildHistograms(String name, Histogram histogram, long timestamp, Map<String, String> tags) { final MetricsCollector collector = MetricsCollector.createNew(name, tags, timestamp); final Snapshot snapshot = histogram.getSnapshot(); if (getChangeCount(name, histogram.getCount()) == 0) { return Collections.emptySet(); } return collector.addMetric("count", histogram.getCount()).addMetric("max", snapshot.getMax()) .addMetric("min", snapshot.getMin()).addMetric("mean", snapshot.getMean()) .addMetric("stddev", snapshot.getStdDev()).addMetric("median", snapshot.getMedian()) .addMetric("p75", snapshot.get75thPercentile()).addMetric("p95", snapshot.get95thPercentile()) .addMetric("p98", snapshot.get98thPercentile()).addMetric("p99", snapshot.get99thPercentile()) .addMetric("p999", snapshot.get999thPercentile()).build(); }
Example 20
Source File: Helper.java From vertx-dropwizard-metrics with Apache License 2.0 | 5 votes |
private static JsonObject toJson(Histogram histogram) { Snapshot snapshot = histogram.getSnapshot(); JsonObject json = new JsonObject(); json.put("type", "histogram"); json.put("count", histogram.getCount()); // Snapshot populateSnapshot(json, snapshot, 1); return json; }