@Test public void testCollect() { labels.labels("a").inc(); List<Collector.MetricFamilySamples> mfs = labels.collect(); ArrayList<Collector.MetricFamilySamples.Sample> samples = new ArrayList<Collector.MetricFamilySamples.Sample>(); ArrayList<String> labelNames = new ArrayList<String>(); labelNames.add("l"); ArrayList<String> labelValues = new ArrayList<String>(); labelValues.add("a"); samples.add(new Collector.MetricFamilySamples.Sample("labels", labelNames, labelValues, 1.0)); Collector.MetricFamilySamples mfsFixture = new Collector.MetricFamilySamples("labels", Collector.Type.GAUGE, "help", samples); assertEquals(1, mfs.size()); assertEquals(mfsFixture, mfs.get(0)); }
@Override public List<MetricFamilySamples> collect() { List<MetricFamilySamples.Sample> samples = new ArrayList<MetricFamilySamples.Sample>(children.size()); for(Map.Entry<List<String>, Child> c: children.entrySet()) { samples.add(new MetricFamilySamples.Sample(fullname, labelNames, c.getKey(), c.getValue().get())); } return familySamplesList(Type.GAUGE, samples); }
Gauge extends SimpleCollector<Gauge.Child> implements Collector.Describable { @Override public List<MetricFamilySamples> collect() { List<MetricFamilySamples.Sample> samples = new ArrayList<MetricFamilySamples.Sample>(children.size()); for(Map.Entry<List<String>, Child> c: children.entrySet()) { samples.add(new MetricFamilySamples.Sample(fullname, labelNames, c.getKey(), c.getValue().get())); } return familySamplesList(Type.GAUGE, samples); } }
Gauge extends SimpleCollector<Gauge.Child> implements Collector.Describable { @Override public List<MetricFamilySamples> collect() { List<MetricFamilySamples.Sample> samples = new ArrayList<MetricFamilySamples.Sample>(children.size()); for(Map.Entry<List<String>, Child> c: children.entrySet()) { samples.add(new MetricFamilySamples.Sample(fullname, labelNames, c.getKey(), c.getValue().get())); } return familySamplesList(Type.GAUGE, samples); } Gauge(Builder b); }
Gauge extends SimpleCollector<Gauge.Child> implements Collector.Describable { @Override public List<MetricFamilySamples> collect() { List<MetricFamilySamples.Sample> samples = new ArrayList<MetricFamilySamples.Sample>(children.size()); for(Map.Entry<List<String>, Child> c: children.entrySet()) { samples.add(new MetricFamilySamples.Sample(fullname, labelNames, c.getKey(), c.getValue().get())); } return familySamplesList(Type.GAUGE, samples); } Gauge(Builder b); static Builder build(String name, String help); static Builder build(); void inc(); void inc(double amt); void dec(); void dec(double amt); void set(double val); void setToCurrentTime(); Timer startTimer(); double setToTime(Runnable timeable); E setToTime(Callable<E> timeable); double get(); @Override List<MetricFamilySamples> collect(); @Override List<MetricFamilySamples> describe(); }
Gauge extends SimpleCollector<Gauge.Child> implements Collector.Describable { @Override public List<MetricFamilySamples> collect() { List<MetricFamilySamples.Sample> samples = new ArrayList<MetricFamilySamples.Sample>(children.size()); for(Map.Entry<List<String>, Child> c: children.entrySet()) { samples.add(new MetricFamilySamples.Sample(fullname, labelNames, c.getKey(), c.getValue().get())); } return familySamplesList(Type.GAUGE, samples); } Gauge(Builder b); static Builder build(String name, String help); static Builder build(); void inc(); void inc(double amt); void dec(); void dec(double amt); void set(double val); void setToCurrentTime(); Timer startTimer(); double setToTime(Runnable timeable); E setToTime(Callable<E> timeable); double get(); @Override List<MetricFamilySamples> collect(); @Override List<MetricFamilySamples> describe();  }