use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class RichGaugeExporter method next.
@Override
protected Iterable<Metric<?>> next(String group) {
RichGauge rich = this.reader.findOne(group);
Collection<Metric<?>> metrics = new ArrayList<>();
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;
}
use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class InMemoryMetricRepository method increment.
@Override
public void increment(Delta<?> delta) {
final String metricName = delta.getName();
final int amount = delta.getValue().intValue();
final Date timestamp = delta.getTimestamp();
this.metrics.update(metricName, new Callback<Metric<?>>() {
@Override
public Metric<?> modify(Metric<?> current) {
if (current != null) {
return new Metric<>(metricName, current.increment(amount).getValue(), timestamp);
}
return new Metric<>(metricName, (long) amount, timestamp);
}
});
}
use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class BufferGaugeServiceSpeedTests method reader.
@Theory
public void reader(String input) throws Exception {
iterate("writeReader");
double rate = number / watch.getLastTaskTimeMillis() * 1000;
System.err.println("Rate(" + count + ")=" + rate + ", " + watch);
watch.start("readReader" + count);
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> metric) {
err.println(metric);
}
});
final LongAdder total = new LongAdder();
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> value) {
total.add(value.getValue().intValue());
}
});
watch.stop();
System.err.println("Read(" + count + ")=" + watch.getLastTaskTimeMillis() + "ms");
assertThat(0 < total.longValue()).isTrue();
}
use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class CounterServiceSpeedTests method reader.
@Theory
public void reader(String input) throws Exception {
iterate("writeReader");
double rate = number / watch.getLastTaskTimeMillis() * 1000;
System.err.println("Rate(" + count + ")=" + rate + ", " + watch);
watch.start("readReader" + count);
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> metric) {
err.println(metric);
}
});
final LongAdder total = new LongAdder();
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> value) {
total.add(value.getValue().intValue());
}
});
watch.stop();
System.err.println("Read(" + count + ")=" + watch.getLastTaskTimeMillis() + "ms");
assertThat(total.longValue()).isEqualTo(number * threadCount);
}
use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class DefaultGaugeServiceSpeedTests method gauges.
@Theory
public void gauges(String input) throws Exception {
watch.start("gauges" + count++);
ExecutorService pool = Executors.newFixedThreadPool(threadCount);
Runnable task = new Runnable() {
@Override
public void run() {
for (int i = 0; i < number; i++) {
String name = sample[i % sample.length];
DefaultGaugeServiceSpeedTests.this.gaugeService.submit(name, count + i);
}
}
};
Collection<Future<?>> futures = new HashSet<>();
for (int i = 0; i < threadCount; i++) {
futures.add(pool.submit(task));
}
for (Future<?> future : futures) {
future.get();
}
watch.stop();
double rate = number / watch.getLastTaskTimeMillis() * 1000;
System.err.println("Gauges rate(" + count + ")=" + rate + ", " + watch);
watch.start("read" + count);
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> metric) {
err.println(metric);
}
});
final LongAdder total = new LongAdder();
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> value) {
total.add(value.getValue().intValue());
}
});
watch.stop();
System.err.println("Read(" + count + ")=" + watch.getLastTaskTimeMillis() + "ms");
assertThat(0 < total.longValue()).isTrue();
}
Aggregations