@Test void testPrometheus() { final StringBuilder sb = new StringBuilder(); meter.prometheusData(sb, meterID, true); String data = sb.toString(); assertThat(data, startsWith(EXPECTED_PROMETHEUS_START)); assertThat(data, containsString("# TYPE application_requests_one_min_rate_per_second gauge\n" + "application_requests_one_min_rate_per_second ")); assertThat(data, containsString("# TYPE application_requests_five_min_rate_per_second gauge\n" + "application_requests_five_min_rate_per_second ")); assertThat(data, containsString("# TYPE application_requests_fifteen_min_rate_per_second gauge\n" + "application_requests_fifteen_min_rate_per_second ")); }
@Override public void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType) { String name = metricID.getName(); String nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_total"; String tags = prometheusTags(metricID.getTags()); if (withHelpType) { prometheusType(sb, nameUnits, "counter"); prometheusHelp(sb, nameUnits); } sb.append(nameUnits) .append(tags) .append(" ") .append(getCount()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getMeanRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_one_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getOneMinuteRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_five_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getFiveMinuteRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_fifteen_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getFifteenMinuteRate()) .append("\n"); }
HelidonMeter extends MetricImpl implements Meter { @Override public void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType) { String name = metricID.getName(); String nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_total"; String tags = prometheusTags(metricID.getTags()); if (withHelpType) { prometheusType(sb, nameUnits, "counter"); prometheusHelp(sb, nameUnits); } sb.append(nameUnits) .append(tags) .append(" ") .append(getCount()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getMeanRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_one_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getOneMinuteRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_five_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getFiveMinuteRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_fifteen_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getFifteenMinuteRate()) .append("\n"); } }
HelidonMeter extends MetricImpl implements Meter { @Override public void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType) { String name = metricID.getName(); String nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_total"; String tags = prometheusTags(metricID.getTags()); if (withHelpType) { prometheusType(sb, nameUnits, "counter"); prometheusHelp(sb, nameUnits); } sb.append(nameUnits) .append(tags) .append(" ") .append(getCount()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getMeanRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_one_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getOneMinuteRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_five_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getFiveMinuteRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_fifteen_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getFifteenMinuteRate()) .append("\n"); } private  HelidonMeter(String type, Metadata metadata, Meter delegate); }
HelidonMeter extends MetricImpl implements Meter { @Override public void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType) { String name = metricID.getName(); String nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_total"; String tags = prometheusTags(metricID.getTags()); if (withHelpType) { prometheusType(sb, nameUnits, "counter"); prometheusHelp(sb, nameUnits); } sb.append(nameUnits) .append(tags) .append(" ") .append(getCount()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getMeanRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_one_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getOneMinuteRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_five_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getFiveMinuteRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_fifteen_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getFifteenMinuteRate()) .append("\n"); } private  HelidonMeter(String type, Metadata metadata, Meter delegate); @Override void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType); @Override String prometheusValue(); @Override void jsonData(JsonObjectBuilder builder, MetricID metricID); @Override void mark(); @Override void mark(long n); @Override long getCount(); @Override double getFifteenMinuteRate(); @Override double getFiveMinuteRate(); @Override double getMeanRate(); @Override double getOneMinuteRate(); @Override boolean equals(Object o); @Override int hashCode(); }
HelidonMeter extends MetricImpl implements Meter { @Override public void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType) { String name = metricID.getName(); String nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_total"; String tags = prometheusTags(metricID.getTags()); if (withHelpType) { prometheusType(sb, nameUnits, "counter"); prometheusHelp(sb, nameUnits); } sb.append(nameUnits) .append(tags) .append(" ") .append(getCount()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getMeanRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_one_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getOneMinuteRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_five_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getFiveMinuteRate()) .append("\n"); nameUnits = prometheusNameWithUnits(name, Optional.empty()) + "_fifteen_min_rate_per_second"; if (withHelpType) { prometheusType(sb, nameUnits, "gauge"); } sb.append(nameUnits) .append(tags) .append(" ") .append(getFifteenMinuteRate()) .append("\n"); } private  HelidonMeter(String type, Metadata metadata, Meter delegate); @Override void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType); @Override String prometheusValue(); @Override void jsonData(JsonObjectBuilder builder, MetricID metricID); @Override void mark(); @Override void mark(long n); @Override long getCount(); @Override double getFifteenMinuteRate(); @Override double getFiveMinuteRate(); @Override double getMeanRate(); @Override double getOneMinuteRate(); @Override boolean equals(Object o); @Override int hashCode();  }