@Test public void testJavadocExample() { class YourCustomCollector extends Collector { public List<MetricFamilySamples> collect() { List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>(); mfs.add(new SummaryMetricFamily("my_summary", "help", 1, 42)); SummaryMetricFamily labeledSummary = new SummaryMetricFamily("my_other_summary", "help", Arrays.asList("labelname"), Arrays.asList(.95, .99)); labeledSummary.addMetric(Arrays.asList("foo"), 2, 10, Arrays.asList(3.0, 5.0)); mfs.add(labeledSummary); return mfs; } } new YourCustomCollector().register(registry); assertEquals(1.0, registry.getSampleValue("my_summary_count").doubleValue(), .001); assertEquals(42.0, registry.getSampleValue("my_summary_sum").doubleValue(), .001); assertEquals(2.0, registry.getSampleValue("my_other_summary_count", new String[]{"labelname"}, new String[]{"foo"}).doubleValue(), .001); assertEquals(10.0, registry.getSampleValue("my_other_summary_sum", new String[]{"labelname"}, new String[]{"foo"}).doubleValue(), .001); assertEquals(3.0, registry.getSampleValue("my_other_summary", new String[]{"labelname", "quantile"}, new String[]{"foo", "0.95"}).doubleValue(), .001); assertEquals(5.0, registry.getSampleValue("my_other_summary", new String[]{"labelname", "quantile"}, new String[]{"foo", "0.99"}).doubleValue(), .001); }
public SummaryMetricFamily addMetric(List<String> labelValues, double count, double sum) { return addMetric(labelValues, count, sum, Collections.<Double>emptyList()); }
SummaryMetricFamily extends Collector.MetricFamilySamples { public SummaryMetricFamily addMetric(List<String> labelValues, double count, double sum) { return addMetric(labelValues, count, sum, Collections.<Double>emptyList()); } }
SummaryMetricFamily extends Collector.MetricFamilySamples { public SummaryMetricFamily addMetric(List<String> labelValues, double count, double sum) { return addMetric(labelValues, count, sum, Collections.<Double>emptyList()); } SummaryMetricFamily(String name, String help, double count, double sum);  SummaryMetricFamily(String name, String help, List<String> labelNames);  SummaryMetricFamily(String name, String help, List<String> labelNames, List<Double>quantiles); }
SummaryMetricFamily extends Collector.MetricFamilySamples { public SummaryMetricFamily addMetric(List<String> labelValues, double count, double sum) { return addMetric(labelValues, count, sum, Collections.<Double>emptyList()); } SummaryMetricFamily(String name, String help, double count, double sum);  SummaryMetricFamily(String name, String help, List<String> labelNames);  SummaryMetricFamily(String name, String help, List<String> labelNames, List<Double>quantiles); SummaryMetricFamily addMetric(List<String> labelValues, double count, double sum); SummaryMetricFamily addMetric(List<String> labelValues, double count, double sum, List<Double> quantiles); }
SummaryMetricFamily extends Collector.MetricFamilySamples { public SummaryMetricFamily addMetric(List<String> labelValues, double count, double sum) { return addMetric(labelValues, count, sum, Collections.<Double>emptyList()); } SummaryMetricFamily(String name, String help, double count, double sum);  SummaryMetricFamily(String name, String help, List<String> labelNames);  SummaryMetricFamily(String name, String help, List<String> labelNames, List<Double>quantiles); SummaryMetricFamily addMetric(List<String> labelValues, double count, double sum); SummaryMetricFamily addMetric(List<String> labelValues, double count, double sum, List<Double> quantiles);  }