Java 类org.springframework.boot.actuate.metrics.repository.InMemoryMetricRepository 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AggregateMetricReader.java   
private void update(InMemoryMetricRepository result, String key, Metric<?> metric) {
    String name = this.prefix + key;
    Metric<?> aggregate = result.findOne(name);
    if (aggregate == null) {
        aggregate = new Metric<Number>(name, metric.getValue(),
                metric.getTimestamp());
    }
    else if (key.contains("counter.")) {
        // accumulate all values
        aggregate = new Metric<Number>(name,
                metric.increment(aggregate.getValue().intValue()).getValue(),
                metric.getTimestamp());
    }
    else if (aggregate.getTimestamp().before(metric.getTimestamp())) {
        // sort by timestamp and only take the latest
        aggregate = new Metric<Number>(name, metric.getValue(),
                metric.getTimestamp());
    }
    result.set(aggregate);
}
项目:spring-boot-concourse    文件:AggregateMetricReader.java   
private void update(InMemoryMetricRepository result, String key, Metric<?> metric) {
    String name = this.prefix + key;
    Metric<?> aggregate = result.findOne(name);
    if (aggregate == null) {
        aggregate = new Metric<Number>(name, metric.getValue(),
                metric.getTimestamp());
    }
    else if (key.contains("counter.")) {
        // accumulate all values
        aggregate = new Metric<Number>(name,
                metric.increment(aggregate.getValue().intValue()).getValue(),
                metric.getTimestamp());
    }
    else if (aggregate.getTimestamp().before(metric.getTimestamp())) {
        // sort by timestamp and only take the latest
        aggregate = new Metric<Number>(name, metric.getValue(),
                metric.getTimestamp());
    }
    result.set(aggregate);
}
项目:contestparser    文件:AggregateMetricReader.java   
private void update(InMemoryMetricRepository result, String key, Metric<?> metric) {
    String name = this.prefix + key;
    Metric<?> aggregate = result.findOne(name);
    if (aggregate == null) {
        aggregate = new Metric<Number>(name, metric.getValue(),
                metric.getTimestamp());
    }
    else if (key.contains("counter.")) {
        // accumulate all values
        aggregate = new Metric<Number>(name,
                metric.increment(aggregate.getValue().intValue()).getValue(),
                metric.getTimestamp());
    }
    else if (aggregate.getTimestamp().before(metric.getTimestamp())) {
        // sort by timestamp and only take the latest
        aggregate = new Metric<Number>(name, metric.getValue(),
                metric.getTimestamp());
    }
    result.set(aggregate);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AggregateMetricReader.java   
@Override
public Metric<?> findOne(String metricName) {
    if (!metricName.startsWith(this.prefix)) {
        return null;
    }
    InMemoryMetricRepository result = new InMemoryMetricRepository();
    String baseName = metricName.substring(this.prefix.length());
    for (Metric<?> metric : this.source.findAll()) {
        String name = getSourceKey(metric.getName());
        if (baseName.equals(name)) {
            update(result, name, metric);
        }
    }
    return result.findOne(metricName);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AggregateMetricReader.java   
@Override
public Iterable<Metric<?>> findAll() {
    InMemoryMetricRepository result = new InMemoryMetricRepository();
    for (Metric<?> metric : this.source.findAll()) {
        String key = getSourceKey(metric.getName());
        if (key != null) {
            update(result, key, metric);
        }
    }
    return result.findAll();
}
项目:spring-boot-concourse    文件:AggregateMetricReader.java   
@Override
public Metric<?> findOne(String metricName) {
    if (!metricName.startsWith(this.prefix)) {
        return null;
    }
    InMemoryMetricRepository result = new InMemoryMetricRepository();
    String baseName = metricName.substring(this.prefix.length());
    for (Metric<?> metric : this.source.findAll()) {
        String name = getSourceKey(metric.getName());
        if (baseName.equals(name)) {
            update(result, name, metric);
        }
    }
    return result.findOne(metricName);
}
项目:spring-boot-concourse    文件:AggregateMetricReader.java   
@Override
public Iterable<Metric<?>> findAll() {
    InMemoryMetricRepository result = new InMemoryMetricRepository();
    for (Metric<?> metric : this.source.findAll()) {
        String key = getSourceKey(metric.getName());
        if (key != null) {
            update(result, key, metric);
        }
    }
    return result.findAll();
}
项目:contestparser    文件:AggregateMetricReader.java   
@Override
public Metric<?> findOne(String metricName) {
    if (!metricName.startsWith(this.prefix)) {
        return null;
    }
    InMemoryMetricRepository result = new InMemoryMetricRepository();
    String baseName = metricName.substring(this.prefix.length());
    for (Metric<?> metric : this.source.findAll()) {
        String name = getSourceKey(metric.getName());
        if (baseName.equals(name)) {
            update(result, name, metric);
        }
    }
    return result.findOne(metricName);
}
项目:contestparser    文件:AggregateMetricReader.java   
@Override
public Iterable<Metric<?>> findAll() {
    InMemoryMetricRepository result = new InMemoryMetricRepository();
    for (Metric<?> metric : this.source.findAll()) {
        String key = getSourceKey(metric.getName());
        if (key != null) {
            update(result, key, metric);
        }
    }
    return result.findAll();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MetricRepositoryAutoConfiguration.java   
@Bean
@ExportMetricReader
@ActuatorMetricWriter
public InMemoryMetricRepository actuatorMetricRepository() {
    return new InMemoryMetricRepository();
}
项目:spring-boot-concourse    文件:MetricRepositoryAutoConfiguration.java   
@Bean
@ExportMetricReader
@ActuatorMetricWriter
public InMemoryMetricRepository actuatorMetricRepository() {
    return new InMemoryMetricRepository();
}
项目:spring-cloud-dataflow    文件:AbstractShellIntegrationTest.java   
@Bean
public MetricRepository metricRepository() {
    return new InMemoryMetricRepository();
}
项目:contestparser    文件:MetricRepositoryAutoConfiguration.java   
@Bean
@ExportMetricReader
@ActuatorMetricWriter
public InMemoryMetricRepository actuatorMetricRepository() {
    return new InMemoryMetricRepository();
}
项目:bulbs-core    文件:MonitoringConfig.java   
@Bean
public MetricRepository metricRepository() {
    return new InMemoryMetricRepository();
}