Java 类org.springframework.boot.actuate.metrics.rich.RichGauge 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void richGaugePublicMetrics() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
            RichGaugeReaderConfig.class, MetricRepositoryAutoConfiguration.class,
            PublicMetricsAutoConfiguration.class);
    RichGaugeReader richGaugeReader = context.getBean(RichGaugeReader.class);
    assertThat(richGaugeReader).isNotNull();
    given(richGaugeReader.findAll())
            .willReturn(Collections.singletonList(new RichGauge("bar", 3.7d)));
    RichGaugeReaderPublicMetrics publicMetrics = context
            .getBean(RichGaugeReaderPublicMetrics.class);
    assertThat(publicMetrics).isNotNull();
    Collection<Metric<?>> metrics = publicMetrics.metrics();
    assertThat(metrics).isNotNull();
    assertThat(6).isEqualTo(metrics.size());
    assertHasMetric(metrics, new Metric<Double>("bar.val", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.avg", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.min", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.max", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.alpha", -1.d));
    assertHasMetric(metrics, new Metric<Long>("bar.count", 1L));
    context.close();
}
项目:spring-boot-concourse    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void richGaugePublicMetrics() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
            RichGaugeReaderConfig.class, MetricRepositoryAutoConfiguration.class,
            PublicMetricsAutoConfiguration.class);
    RichGaugeReader richGaugeReader = context.getBean(RichGaugeReader.class);
    assertThat(richGaugeReader).isNotNull();
    given(richGaugeReader.findAll())
            .willReturn(Collections.singletonList(new RichGauge("bar", 3.7d)));
    RichGaugeReaderPublicMetrics publicMetrics = context
            .getBean(RichGaugeReaderPublicMetrics.class);
    assertThat(publicMetrics).isNotNull();
    Collection<Metric<?>> metrics = publicMetrics.metrics();
    assertThat(metrics).isNotNull();
    assertThat(6).isEqualTo(metrics.size());
    assertHasMetric(metrics, new Metric<Double>("bar.val", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.avg", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.min", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.max", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.alpha", -1.d));
    assertHasMetric(metrics, new Metric<Long>("bar.count", 1L));
    context.close();
}
项目:contestparser    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void richGaugePublicMetrics() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
            RichGaugeReaderConfig.class, MetricRepositoryAutoConfiguration.class,
            PublicMetricsAutoConfiguration.class);
    RichGaugeReader richGaugeReader = context.getBean(RichGaugeReader.class);
    assertNotNull(richGaugeReader);
    given(richGaugeReader.findAll())
            .willReturn(Collections.singletonList(new RichGauge("bar", 3.7d)));
    RichGaugeReaderPublicMetrics publicMetrics = context
            .getBean(RichGaugeReaderPublicMetrics.class);
    assertNotNull(publicMetrics);
    Collection<Metric<?>> metrics = publicMetrics.metrics();
    assertNotNull(metrics);
    assertEquals(metrics.size(), 6);
    assertHasMetric(metrics, new Metric<Double>("bar.val", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.avg", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.min", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.max", 3.7d));
    assertHasMetric(metrics, new Metric<Double>("bar.alpha", -1.d));
    assertHasMetric(metrics, new Metric<Long>("bar.count", 1L));
    context.close();
}
项目:spring-boot-starter-batch-web    文件:MetricsListener.java   
@Override
public String format(List<RichGauge> gauges, List<Metric<?>> metrics) {
    StringBuilder builder = new StringBuilder("\n########## Metrics Start ##########\n");
    if (gauges != null) {
        for (RichGauge gauge : gauges) {
            builder.append(gauge.toString() + "\n");
        }
    }
    if (metrics != null) {
        for (Metric<?> metric : metrics) {
            builder.append(metric.toString() + "\n");
        }
    }
    builder.append("########## Metrics End ############");
    return builder.toString();
}
项目:spring-boot-starter-batch-web    文件:MetricsTestApplication.java   
@Bean
public MetricsOutputFormatter metricsOutputFormatter() {
    return new MetricsOutputFormatter() {

        @Override
        public String format(List<RichGauge> gauges, List<Metric<?>> metrics) {
            StringBuilder builder = new StringBuilder("\n########## Personal Header for metrics! #####\n########## Metrics Start ##########\n");
            if (gauges != null) {
                for (RichGauge gauge : gauges) {
                    builder.append(gauge.toString() + "\n");
                }
            }
            if (metrics != null) {
                for (Metric<?> metric : metrics) {
                    builder.append(metric.toString() + "\n");
                }
            }
            builder.append("########## Metrics End ############");
            return builder.toString();
        }

    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RichGaugeExporter.java   
@Override
protected Iterable<Metric<?>> next(String group) {
    RichGauge rich = this.reader.findOne(group);
    Collection<Metric<?>> metrics = new ArrayList<Metric<?>>();
    metrics.add(new Metric<Number>(group + MIN, rich.getMin()));
    metrics.add(new Metric<Number>(group + MAX, rich.getMax()));
    metrics.add(new Metric<Number>(group + COUNT, rich.getCount()));
    metrics.add(new Metric<Number>(group + VALUE, rich.getValue()));
    metrics.add(new Metric<Number>(group + AVG, rich.getAverage()));
    metrics.add(new Metric<Number>(group + ALPHA, rich.getAlpha()));
    return metrics;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RichGaugeExporter.java   
@Override
protected Iterable<String> groups() {
    Collection<String> names = new HashSet<String>();
    for (RichGauge rich : this.reader.findAll()) {
        names.add(rich.getName());
    }
    return names;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RichGaugeReaderPublicMetrics.java   
@Override
public Collection<Metric<?>> metrics() {
    List<Metric<?>> result = new ArrayList<Metric<?>>();
    for (RichGauge richGauge : this.richGaugeReader.findAll()) {
        result.addAll(convert(richGauge));
    }
    return result;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RichGaugeReaderPublicMetrics.java   
private List<Metric<?>> convert(RichGauge gauge) {
    List<Metric<?>> result = new ArrayList<Metric<?>>(6);
    result.add(
            new Metric<Double>(gauge.getName() + RichGauge.AVG, gauge.getAverage()));
    result.add(new Metric<Double>(gauge.getName() + RichGauge.VAL, gauge.getValue()));
    result.add(new Metric<Double>(gauge.getName() + RichGauge.MIN, gauge.getMin()));
    result.add(new Metric<Double>(gauge.getName() + RichGauge.MAX, gauge.getMax()));
    result.add(
            new Metric<Double>(gauge.getName() + RichGauge.ALPHA, gauge.getAlpha()));
    result.add(new Metric<Long>(gauge.getName() + RichGauge.COUNT, gauge.getCount()));
    return result;
}
项目:spring-boot-concourse    文件:RichGaugeExporter.java   
@Override
protected Iterable<Metric<?>> next(String group) {
    RichGauge rich = this.reader.findOne(group);
    Collection<Metric<?>> metrics = new ArrayList<Metric<?>>();
    metrics.add(new Metric<Number>(group + MIN, rich.getMin()));
    metrics.add(new Metric<Number>(group + MAX, rich.getMax()));
    metrics.add(new Metric<Number>(group + COUNT, rich.getCount()));
    metrics.add(new Metric<Number>(group + VALUE, rich.getValue()));
    metrics.add(new Metric<Number>(group + AVG, rich.getAverage()));
    metrics.add(new Metric<Number>(group + ALPHA, rich.getAlpha()));
    return metrics;
}
项目:spring-boot-concourse    文件:RichGaugeExporter.java   
@Override
protected Iterable<String> groups() {
    Collection<String> names = new HashSet<String>();
    for (RichGauge rich : this.reader.findAll()) {
        names.add(rich.getName());
    }
    return names;
}
项目:spring-boot-concourse    文件:RichGaugeReaderPublicMetrics.java   
@Override
public Collection<Metric<?>> metrics() {
    List<Metric<?>> result = new ArrayList<Metric<?>>();
    for (RichGauge richGauge : this.richGaugeReader.findAll()) {
        result.addAll(convert(richGauge));
    }
    return result;
}
项目:spring-boot-concourse    文件:RichGaugeReaderPublicMetrics.java   
private List<Metric<?>> convert(RichGauge gauge) {
    List<Metric<?>> result = new ArrayList<Metric<?>>(6);
    result.add(
            new Metric<Double>(gauge.getName() + RichGauge.AVG, gauge.getAverage()));
    result.add(new Metric<Double>(gauge.getName() + RichGauge.VAL, gauge.getValue()));
    result.add(new Metric<Double>(gauge.getName() + RichGauge.MIN, gauge.getMin()));
    result.add(new Metric<Double>(gauge.getName() + RichGauge.MAX, gauge.getMax()));
    result.add(
            new Metric<Double>(gauge.getName() + RichGauge.ALPHA, gauge.getAlpha()));
    result.add(new Metric<Long>(gauge.getName() + RichGauge.COUNT, gauge.getCount()));
    return result;
}
项目:contestparser    文件:RichGaugeExporter.java   
@Override
protected Iterable<Metric<?>> next(String group) {
    RichGauge rich = this.reader.findOne(group);
    Collection<Metric<?>> metrics = new ArrayList<Metric<?>>();
    metrics.add(new Metric<Number>(group + MIN, rich.getMin()));
    metrics.add(new Metric<Number>(group + MAX, rich.getMax()));
    metrics.add(new Metric<Number>(group + COUNT, rich.getCount()));
    metrics.add(new Metric<Number>(group + VALUE, rich.getValue()));
    metrics.add(new Metric<Number>(group + AVG, rich.getAverage()));
    metrics.add(new Metric<Number>(group + ALPHA, rich.getAlpha()));
    return metrics;
}
项目:contestparser    文件:RichGaugeExporter.java   
@Override
protected Iterable<String> groups() {
    Collection<String> names = new HashSet<String>();
    for (RichGauge rich : this.reader.findAll()) {
        names.add(rich.getName());
    }
    return names;
}
项目:contestparser    文件:RichGaugeReaderPublicMetrics.java   
@Override
public Collection<Metric<?>> metrics() {
    List<Metric<?>> result = new ArrayList<Metric<?>>();
    for (RichGauge richGauge : this.richGaugeReader.findAll()) {
        result.addAll(convert(richGauge));
    }
    return result;
}
项目:contestparser    文件:RichGaugeReaderPublicMetrics.java   
private List<Metric<?>> convert(RichGauge gauge) {
    List<Metric<?>> result = new ArrayList<Metric<?>>(6);
    result.add(
            new Metric<Double>(gauge.getName() + RichGauge.AVG, gauge.getAverage()));
    result.add(new Metric<Double>(gauge.getName() + RichGauge.VAL, gauge.getValue()));
    result.add(new Metric<Double>(gauge.getName() + RichGauge.MIN, gauge.getMin()));
    result.add(new Metric<Double>(gauge.getName() + RichGauge.MAX, gauge.getMax()));
    result.add(
            new Metric<Double>(gauge.getName() + RichGauge.ALPHA, gauge.getAlpha()));
    result.add(new Metric<Long>(gauge.getName() + RichGauge.COUNT, gauge.getCount()));
    return result;
}
项目:spring-boot-starter-batch-web    文件:MetricsListener.java   
private List<RichGauge> exportBatchRichGauges() {
    List<RichGauge> gauges = new ArrayList<RichGauge>();
    for (RichGauge gauge : richGaugeReader.findAll()) {
        gauges.add(gauge);
    }
    return gauges;
}
项目:spring-boot-starter-batch-web    文件:MetricsOutputFormatter.java   
public String format(List<RichGauge> gauges, List<Metric<?>> metrics);