public static Map<String, Double> explodeSampling(Sampling sampling) { return explodeSampling(sampling, false); }
public static Map<String, Double> explodeSummarizable(Summarizable metric) { return explodeSummarizable(metric, false); }
private static void writeMeteredFields(Metered metered, JsonGenerator json) throws IOException { for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeMetered(metered).entrySet()) { json.writeNumberField(entry.getKey(), entry.getValue()); } } }
private void upsertJavaMetrics() { upsertGauges("jvm.memory", MetricsToTimeseries.memoryMetrics(vm)); upsertGauges("jvm.buffers.direct", MetricsToTimeseries.buffersMetrics(vm.getBufferPoolStats().get("direct"))); upsertGauges("jvm.buffers.mapped", MetricsToTimeseries.buffersMetrics(vm.getBufferPoolStats().get("mapped"))); upsertGauges("jvm.thread-states", MetricsToTimeseries.threadStateMetrics(vm)); upsertGauges("jvm", MetricsToTimeseries.vmMetrics(vm)); upsertGauges("current_time", (double) clock.time()); for (Map.Entry<String, VirtualMachineMetrics.GarbageCollectorStats> entry : vm.garbageCollectors().entrySet()) { upsertGauges("jvm.garbage-collectors." + entry.getKey(), MetricsToTimeseries.gcMetrics(entry.getValue())); } }
@Override public void processHistogram(MetricName name, Histogram histogram, FlushProcessorContext context) throws Exception { if (histogram instanceof WavefrontHistogram && useWavefrontHistograms) { WavefrontHistogram wavefrontHistogram = (WavefrontHistogram) histogram; wavefront.report.Histogram.Builder builder = wavefront.report.Histogram.newBuilder(); builder.setBins(Lists.newLinkedList()); builder.setCounts(Lists.newLinkedList()); long minMillis = Long.MAX_VALUE; if (wavefrontHistogram.count() == 0) return; for (WavefrontHistogram.MinuteBin minuteBin : wavefrontHistogram.bins(true)) { builder.getBins().add(minuteBin.getDist().quantile(.5)); builder.getCounts().add(Math.toIntExact(minuteBin.getDist().size())); minMillis = Long.min(minMillis, minuteBin.getMinMillis()); } builder.setType(HistogramType.TDIGEST); builder.setDuration(Math.toIntExact(currentMillis.get() - minMillis)); context.report(builder.build()); } else { context.reportSubMetric(histogram.count(), "count"); for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeSummarizable(histogram, reportEmptyHistogramStats).entrySet()) { context.reportSubMetric(entry.getValue(), entry.getKey()); } for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeSampling(histogram, reportEmptyHistogramStats).entrySet()) { context.reportSubMetric(entry.getValue(), entry.getKey()); } histogram.clear(); } sentCounter.inc(); }
public static String sanitize(MetricName metricName) { return sanitize(metricName.getGroup() + "." + metricName.getName()); }
json.writeStartObject(); mergeMapIntoJson(json, MetricsToTimeseries.memoryMetrics(vm)); json.writeFieldName("memory_pool_usages"); // jvm.memory.memory_pool_usages json.writeStartObject(); mergeMapIntoJson(json, MetricsToTimeseries.memoryPoolsMetrics(vm)); json.writeStartObject(); mergeMapIntoJson(json, MetricsToTimeseries.buffersMetrics(bufferPoolStats.get("direct"))); json.writeStartObject(); mergeMapIntoJson(json, MetricsToTimeseries.buffersMetrics(bufferPoolStats.get("mapped"))); mergeMapIntoJson(json, MetricsToTimeseries.vmMetrics(vm)); // jvm.<vm_metric> json.writeNumberField("current_time", clock.time()); json.writeStartObject(); mergeMapIntoJson(json, MetricsToTimeseries.threadStateMetrics(vm)); mergeMapIntoJson(json, MetricsToTimeseries.gcMetrics(entry.getValue()));
@Override public void processHistogram(MetricName name, Histogram histogram, FlushProcessorContext context) throws Exception { if (histogram instanceof WavefrontHistogram && useWavefrontHistograms) { WavefrontHistogram wavefrontHistogram = (WavefrontHistogram) histogram; wavefront.report.Histogram.Builder builder = wavefront.report.Histogram.newBuilder(); builder.setBins(Lists.newLinkedList()); builder.setCounts(Lists.newLinkedList()); long minMillis = Long.MAX_VALUE; if (wavefrontHistogram.count() == 0) return; for (WavefrontHistogram.MinuteBin minuteBin : wavefrontHistogram.bins(true)) { builder.getBins().add(minuteBin.getDist().quantile(.5)); builder.getCounts().add(Math.toIntExact(minuteBin.getDist().size())); minMillis = Long.min(minMillis, minuteBin.getMinMillis()); } builder.setType(HistogramType.TDIGEST); builder.setDuration(Math.toIntExact(currentMillis.get() - minMillis)); context.report(builder.build()); } else { context.reportSubMetric(histogram.count(), "count"); for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeSummarizable(histogram, reportEmptyHistogramStats).entrySet()) { context.reportSubMetric(entry.getValue(), entry.getKey()); } for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeSampling(histogram, reportEmptyHistogramStats).entrySet()) { context.reportSubMetric(entry.getValue(), entry.getKey()); } histogram.clear(); } sentCounter.inc(); }
public static String sanitize(MetricName metricName) { return sanitize(metricName.getGroup() + "." + metricName.getName()); }
json.writeStartObject(); mergeMapIntoJson(json, MetricsToTimeseries.memoryMetrics(vm)); json.writeFieldName("memory_pool_usages"); // jvm.memory.memory_pool_usages json.writeStartObject(); mergeMapIntoJson(json, MetricsToTimeseries.memoryPoolsMetrics(vm)); json.writeStartObject(); mergeMapIntoJson(json, MetricsToTimeseries.buffersMetrics(bufferPoolStats.get("direct"))); json.writeStartObject(); mergeMapIntoJson(json, MetricsToTimeseries.buffersMetrics(bufferPoolStats.get("mapped"))); mergeMapIntoJson(json, MetricsToTimeseries.vmMetrics(vm)); // jvm.<vm_metric> json.writeNumberField("current_time", clock.time()); json.writeStartObject(); mergeMapIntoJson(json, MetricsToTimeseries.threadStateMetrics(vm)); mergeMapIntoJson(json, MetricsToTimeseries.gcMetrics(entry.getValue()));
public static Map<String, Double> explodeSummarizable(Summarizable metric) { return explodeSummarizable(metric, false); }
public static Map<String, Double> explodeSampling(Sampling sampling) { return explodeSampling(sampling, false); }
private void upsertGauges(String metricName, Double t) { gaugeMap.put(metricName, t); // This call to newGauge only mutates the metrics registry the first time through. Thats why it's important // to access gaugeMap indirectly, as opposed to counting on new calls to newGauage to replace the underlying // double supplier. getMetricsRegistry().newGauge( new MetricName("", "", MetricsToTimeseries.sanitize(metricName)), new Gauge<Double>() { @Override public Double value() { return gaugeMap.get(metricName); } }); }
private static void writeMeteredFields(Metered metered, JsonGenerator json) throws IOException { for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeMetered(metered).entrySet()) { json.writeNumberField(entry.getKey(), entry.getValue()); } } }
private static void writeSummarizable(Summarizable metric, JsonGenerator json) throws IOException { for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeSummarizable(metric).entrySet()) { json.writeNumberField(entry.getKey(), entry.getValue()); } }
private static void writeSampling(Sampling metric, JsonGenerator json) throws IOException { for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeSampling(metric).entrySet()) { json.writeNumberField(entry.getKey(), entry.getValue()); } }
private void writeMetered(MetricName name, Metered metered) throws Exception { for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeMetered(metered).entrySet()) { writeMetric(name, entry.getKey(), entry.getValue()); } }
private static void writeSummarizable(Summarizable metric, JsonGenerator json) throws IOException { for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeSummarizable(metric).entrySet()) { json.writeNumberField(entry.getKey(), entry.getValue()); } }
private static void writeSampling(Sampling metric, JsonGenerator json) throws IOException { for (Map.Entry<String, Double> entry : MetricsToTimeseries.explodeSampling(metric).entrySet()) { json.writeNumberField(entry.getKey(), entry.getValue()); } }