@Test void testPrometheus() throws IOException, ParseException { final StringBuilder sb = new StringBuilder(); histoInt.prometheusData(sb, histoIntID, true); parsePrometheusText(new LineNumberReader(new StringReader(sb.toString())).lines()) .forEach(entry -> assertThat("Unexpected value checking " + entry.getKey(), EXPECTED_PROMETHEUS_RESULTS.get(entry.getKey()), is(withinTolerance(entry.getValue())))); }
@Override public void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType) { Units units = getUnits(); String tags = prometheusTags(metricID.getTags()); String name = metricID.getName(); String nameUnits; Optional<String> unit = units.getPrometheusUnit(); Snapshot snap = getSnapshot(); nameUnits = prometheusNameWithUnits(name + "_mean", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMean())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_max", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMax())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_min", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMin())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_stddev", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getStdDev())) .append("\n"); nameUnits = prometheusNameWithUnits(name, unit); if (withHelpType) { prometheusType(sb, nameUnits, "summary"); prometheusHelp(sb, nameUnits); } nameUnits = prometheusNameWithUnits(name, unit) + "_count"; sb.append(nameUnits) .append(tags) .append(" ") .append(getCount()) .append('\n'); nameUnits = prometheusNameWithUnits(name, unit); prometheusQuantile(sb, tags, units, nameUnits, "0.5", snap::getMedian); prometheusQuantile(sb, tags, units, nameUnits, "0.75", snap::get75thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.95", snap::get95thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.98", snap::get98thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.99", snap::get99thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.999", snap::get999thPercentile); }
HelidonHistogram extends MetricImpl implements Histogram { @Override public void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType) { Units units = getUnits(); String tags = prometheusTags(metricID.getTags()); String name = metricID.getName(); String nameUnits; Optional<String> unit = units.getPrometheusUnit(); Snapshot snap = getSnapshot(); nameUnits = prometheusNameWithUnits(name + "_mean", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMean())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_max", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMax())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_min", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMin())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_stddev", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getStdDev())) .append("\n"); nameUnits = prometheusNameWithUnits(name, unit); if (withHelpType) { prometheusType(sb, nameUnits, "summary"); prometheusHelp(sb, nameUnits); } nameUnits = prometheusNameWithUnits(name, unit) + "_count"; sb.append(nameUnits) .append(tags) .append(" ") .append(getCount()) .append('\n'); nameUnits = prometheusNameWithUnits(name, unit); prometheusQuantile(sb, tags, units, nameUnits, "0.5", snap::getMedian); prometheusQuantile(sb, tags, units, nameUnits, "0.75", snap::get75thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.95", snap::get95thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.98", snap::get98thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.99", snap::get99thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.999", snap::get999thPercentile); } }
HelidonHistogram extends MetricImpl implements Histogram { @Override public void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType) { Units units = getUnits(); String tags = prometheusTags(metricID.getTags()); String name = metricID.getName(); String nameUnits; Optional<String> unit = units.getPrometheusUnit(); Snapshot snap = getSnapshot(); nameUnits = prometheusNameWithUnits(name + "_mean", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMean())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_max", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMax())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_min", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMin())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_stddev", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getStdDev())) .append("\n"); nameUnits = prometheusNameWithUnits(name, unit); if (withHelpType) { prometheusType(sb, nameUnits, "summary"); prometheusHelp(sb, nameUnits); } nameUnits = prometheusNameWithUnits(name, unit) + "_count"; sb.append(nameUnits) .append(tags) .append(" ") .append(getCount()) .append('\n'); nameUnits = prometheusNameWithUnits(name, unit); prometheusQuantile(sb, tags, units, nameUnits, "0.5", snap::getMedian); prometheusQuantile(sb, tags, units, nameUnits, "0.75", snap::get75thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.95", snap::get95thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.98", snap::get98thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.99", snap::get99thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.999", snap::get999thPercentile); } private  HelidonHistogram(String type, Metadata metadata, Histogram delegate); }
HelidonHistogram extends MetricImpl implements Histogram { @Override public void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType) { Units units = getUnits(); String tags = prometheusTags(metricID.getTags()); String name = metricID.getName(); String nameUnits; Optional<String> unit = units.getPrometheusUnit(); Snapshot snap = getSnapshot(); nameUnits = prometheusNameWithUnits(name + "_mean", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMean())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_max", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMax())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_min", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMin())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_stddev", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getStdDev())) .append("\n"); nameUnits = prometheusNameWithUnits(name, unit); if (withHelpType) { prometheusType(sb, nameUnits, "summary"); prometheusHelp(sb, nameUnits); } nameUnits = prometheusNameWithUnits(name, unit) + "_count"; sb.append(nameUnits) .append(tags) .append(" ") .append(getCount()) .append('\n'); nameUnits = prometheusNameWithUnits(name, unit); prometheusQuantile(sb, tags, units, nameUnits, "0.5", snap::getMedian); prometheusQuantile(sb, tags, units, nameUnits, "0.75", snap::get75thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.95", snap::get95thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.98", snap::get98thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.99", snap::get99thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.999", snap::get999thPercentile); } private  HelidonHistogram(String type, Metadata metadata, Histogram delegate); @Override void update(int value); @Override void update(long value); @Override long getCount(); @Override Snapshot getSnapshot(); @Override void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType); @Override String prometheusValue(); @Override void jsonData(JsonObjectBuilder builder, MetricID metricID); @Override boolean equals(Object o); @Override int hashCode(); }
HelidonHistogram extends MetricImpl implements Histogram { @Override public void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType) { Units units = getUnits(); String tags = prometheusTags(metricID.getTags()); String name = metricID.getName(); String nameUnits; Optional<String> unit = units.getPrometheusUnit(); Snapshot snap = getSnapshot(); nameUnits = prometheusNameWithUnits(name + "_mean", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMean())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_max", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMax())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_min", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getMin())) .append("\n"); nameUnits = prometheusNameWithUnits(name + "_stddev", unit); if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(units.convert(snap.getStdDev())) .append("\n"); nameUnits = prometheusNameWithUnits(name, unit); if (withHelpType) { prometheusType(sb, nameUnits, "summary"); prometheusHelp(sb, nameUnits); } nameUnits = prometheusNameWithUnits(name, unit) + "_count"; sb.append(nameUnits) .append(tags) .append(" ") .append(getCount()) .append('\n'); nameUnits = prometheusNameWithUnits(name, unit); prometheusQuantile(sb, tags, units, nameUnits, "0.5", snap::getMedian); prometheusQuantile(sb, tags, units, nameUnits, "0.75", snap::get75thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.95", snap::get95thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.98", snap::get98thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.99", snap::get99thPercentile); prometheusQuantile(sb, tags, units, nameUnits, "0.999", snap::get999thPercentile); } private  HelidonHistogram(String type, Metadata metadata, Histogram delegate); @Override void update(int value); @Override void update(long value); @Override long getCount(); @Override Snapshot getSnapshot(); @Override void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType); @Override String prometheusValue(); @Override void jsonData(JsonObjectBuilder builder, MetricID metricID); @Override boolean equals(Object o); @Override int hashCode();  }