mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
caller updates for documented metrics
This commit is contained in:
parent
84f9b84a6e
commit
3f6abf12f8
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package io.nosqlbench.engine.api.metrics;
|
package io.nosqlbench.engine.api.metrics;
|
||||||
|
|
||||||
|
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
|
||||||
import io.nosqlbench.nb.api.labels.NBLabels;
|
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||||
import io.nosqlbench.nb.api.engine.metrics.DeltaHdrHistogramReservoir;
|
import io.nosqlbench.nb.api.engine.metrics.DeltaHdrHistogramReservoir;
|
||||||
import io.nosqlbench.nb.api.engine.metrics.HistoIntervalLogger;
|
import io.nosqlbench.nb.api.engine.metrics.HistoIntervalLogger;
|
||||||
@ -47,7 +48,14 @@ public class HistoIntervalLoggerTest {
|
|||||||
final int significantDigits = 4;
|
final int significantDigits = 4;
|
||||||
|
|
||||||
NBMetricHistogram NBHistogram = new NBMetricHistogram(
|
NBMetricHistogram NBHistogram = new NBMetricHistogram(
|
||||||
NBLabels.forKV("name", "histo1"), new DeltaHdrHistogramReservoir(NBLabels.forKV("name", "histo1"), significantDigits));
|
NBLabels.forKV("name", "histo1"),
|
||||||
|
new DeltaHdrHistogramReservoir(
|
||||||
|
NBLabels.forKV("name", "histo1"),
|
||||||
|
significantDigits
|
||||||
|
),
|
||||||
|
"test basic logger",
|
||||||
|
MetricCategory.Verification
|
||||||
|
);
|
||||||
|
|
||||||
hil.onHistogramAdded("histo1", NBHistogram);
|
hil.onHistogramAdded("histo1", NBHistogram);
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package io.nosqlbench.engine.api.metrics;
|
package io.nosqlbench.engine.api.metrics;
|
||||||
|
|
||||||
|
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
|
||||||
import io.nosqlbench.nb.api.labels.NBLabels;
|
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||||
import io.nosqlbench.nb.api.engine.metrics.ConvenientSnapshot;
|
import io.nosqlbench.nb.api.engine.metrics.ConvenientSnapshot;
|
||||||
import io.nosqlbench.nb.api.engine.metrics.DeltaHdrHistogramReservoir;
|
import io.nosqlbench.nb.api.engine.metrics.DeltaHdrHistogramReservoir;
|
||||||
@ -28,8 +29,15 @@ public class NBMetricHistogramTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNicerHistogramValues() {
|
public void testNicerHistogramValues() {
|
||||||
NBMetricHistogram nh = new NBMetricHistogram(NBLabels.forKV("name","testhisto"), new DeltaHdrHistogramReservoir(
|
NBMetricHistogram nh = new NBMetricHistogram(
|
||||||
NBLabels.forKV("name", "testhisto"), 4));
|
NBLabels.forKV("name","testhisto"),
|
||||||
|
new DeltaHdrHistogramReservoir(
|
||||||
|
NBLabels.forKV("name", "testhisto"),
|
||||||
|
4
|
||||||
|
),
|
||||||
|
"test nicer histogram values",
|
||||||
|
MetricCategory.Verification
|
||||||
|
);
|
||||||
for (int i = 1; 100 >= i; i++) {
|
for (int i = 1; 100 >= i; i++) {
|
||||||
nh.update(i);
|
nh.update(i);
|
||||||
}
|
}
|
||||||
|
@ -59,58 +59,62 @@ public class NBCreators {
|
|||||||
|
|
||||||
public NBMetricTimer timer(String metricFamilyName, int hdrdigits, MetricCategory category, String description) {
|
public NBMetricTimer timer(String metricFamilyName, int hdrdigits, MetricCategory category, String description) {
|
||||||
NBLabels labels = base.getLabels().and("name", metricFamilyName);
|
NBLabels labels = base.getLabels().and("name", metricFamilyName);
|
||||||
NBMetricTimer timer = new NBMetricTimer(labels, new DeltaHdrHistogramReservoir(labels, hdrdigits));
|
NBMetricTimer timer = new NBMetricTimer(
|
||||||
|
labels,
|
||||||
|
new DeltaHdrHistogramReservoir(labels, hdrdigits),
|
||||||
|
description, category
|
||||||
|
);
|
||||||
base.addComponentMetric(timer, category, description);
|
base.addComponentMetric(timer, category, description);
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Meter meter(String metricFamilyName, MetricCategory category, String requiredDescription) {
|
public Meter meter(String metricFamilyName, MetricCategory category, String description) {
|
||||||
NBLabels labels = base.getLabels().and("name", metricFamilyName);
|
NBLabels labels = base.getLabels().and("name", metricFamilyName);
|
||||||
NBMetricMeter meter = new NBMetricMeter(labels);
|
NBMetricMeter meter = new NBMetricMeter(labels,description, category);
|
||||||
base.addComponentMetric(meter, category, requiredDescription);
|
base.addComponentMetric(meter, category, description);
|
||||||
return meter;
|
return meter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public NBMetricCounter counter(String metricFamilyName, MetricCategory category, String requiredDescription) {
|
public NBMetricCounter counter(String metricFamilyName, MetricCategory category, String description) {
|
||||||
NBLabels labels = base.getLabels().and("name", metricFamilyName);
|
NBLabels labels = base.getLabels().and("name", metricFamilyName);
|
||||||
NBMetricCounter counter = new NBMetricCounter(labels);
|
NBMetricCounter counter = new NBMetricCounter(labels, description, category);
|
||||||
base.addComponentMetric(counter, category, requiredDescription);
|
base.addComponentMetric(counter, category, description);
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public NBFunctionGauge gauge(String metricFamilyName, Supplier<Double> valueSource, MetricCategory category, String requiredDescription) {
|
public NBFunctionGauge gauge(String metricFamilyName, Supplier<Double> valueSource, MetricCategory category, String description) {
|
||||||
NBFunctionGauge gauge = new NBFunctionGauge(base, valueSource, metricFamilyName);
|
NBFunctionGauge gauge = new NBFunctionGauge(base, valueSource, metricFamilyName, description, category);
|
||||||
base.addComponentMetric(gauge, category, requiredDescription);
|
base.addComponentMetric(gauge, category, description);
|
||||||
return gauge;
|
return gauge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NBVariableGauge variableGauge(String metricFamilyName, double initialValue, MetricCategory category, String requiredDescription, String... additionalLabels) {
|
public NBVariableGauge variableGauge(String metricFamilyName, double initialValue, MetricCategory category, String description, NBLabels additionalLabels) {
|
||||||
NBVariableGauge gauge = new NBVariableGauge(base, metricFamilyName, initialValue, additionalLabels);
|
NBVariableGauge gauge = new NBVariableGauge(base, metricFamilyName, initialValue, additionalLabels, description, category);
|
||||||
base.addComponentMetric(gauge, category, requiredDescription);
|
base.addComponentMetric(gauge, category, description);
|
||||||
return gauge;
|
return gauge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DoubleSummaryGauge summaryGauge(String name, List<String> statspecs, MetricCategory category, String requiredDescription) {
|
public DoubleSummaryGauge summaryGauge(String name, List<String> statspecs, MetricCategory category, String description) {
|
||||||
List<DoubleSummaryGauge.Stat> stats = statspecs.stream().map(DoubleSummaryGauge.Stat::valueOf).toList();
|
List<DoubleSummaryGauge.Stat> stats = statspecs.stream().map(DoubleSummaryGauge.Stat::valueOf).toList();
|
||||||
DoubleSummaryStatistics reservoir = new DoubleSummaryStatistics();
|
DoubleSummaryStatistics reservoir = new DoubleSummaryStatistics();
|
||||||
DoubleSummaryGauge anyGauge = null;
|
DoubleSummaryGauge anyGauge = null;
|
||||||
for (DoubleSummaryGauge.Stat stat : stats) {
|
for (DoubleSummaryGauge.Stat stat : stats) {
|
||||||
anyGauge = new DoubleSummaryGauge(base.getLabels().and(NBLabels.forKV("name",name,"stat", stat)), stat, reservoir);
|
anyGauge = new DoubleSummaryGauge(base.getLabels().and(NBLabels.forKV("name",name,"stat", stat)), stat, reservoir, description, category);
|
||||||
base.addComponentMetric(anyGauge, category, requiredDescription);
|
base.addComponentMetric(anyGauge, category, description);
|
||||||
}
|
}
|
||||||
return anyGauge;
|
return anyGauge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NBMetricHistogram histogram(String metricFamilyName, MetricCategory category, String requiredDescription) {
|
public NBMetricHistogram histogram(String metricFamilyName, MetricCategory category, String description) {
|
||||||
return histogram(metricFamilyName,4, category, requiredDescription);
|
return histogram(metricFamilyName,4, category, description);
|
||||||
}
|
}
|
||||||
public NBMetricHistogram histogram(String metricFamilyName, int hdrdigits, MetricCategory category, String requiredDescription) {
|
public NBMetricHistogram histogram(String metricFamilyName, int hdrdigits, MetricCategory category, String description) {
|
||||||
NBLabels labels = base.getLabels().and("name", metricFamilyName);
|
NBLabels labels = base.getLabels().and("name", metricFamilyName);
|
||||||
NBMetricHistogram histogram = new NBMetricHistogram(labels, new DeltaHdrHistogramReservoir(labels, hdrdigits));
|
NBMetricHistogram histogram = new NBMetricHistogram(labels, new DeltaHdrHistogramReservoir(labels, hdrdigits), description, category);
|
||||||
base.addComponentMetric(histogram, category, requiredDescription);
|
base.addComponentMetric(histogram, category, description);
|
||||||
return histogram;
|
return histogram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package io.nosqlbench.nb.api.engine.metrics;
|
package io.nosqlbench.nb.api.engine.metrics;
|
||||||
|
|
||||||
|
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
|
||||||
import io.nosqlbench.nb.api.labels.NBLabels;
|
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||||
import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetricGauge;
|
import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetricGauge;
|
||||||
|
|
||||||
@ -30,12 +31,24 @@ public class DoubleSummaryGauge implements NBMetricGauge, DoubleConsumer {
|
|||||||
private final NBLabels labels;
|
private final NBLabels labels;
|
||||||
private final Stat stat;
|
private final Stat stat;
|
||||||
private final DoubleSummaryStatistics stats;
|
private final DoubleSummaryStatistics stats;
|
||||||
|
private final String description;
|
||||||
|
private final MetricCategory[] categories;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String typeName() {
|
public String typeName() {
|
||||||
return "gauge";
|
return "gauge";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetricCategory[] getCategories() {
|
||||||
|
return this.categories;
|
||||||
|
}
|
||||||
|
|
||||||
public enum Stat {
|
public enum Stat {
|
||||||
Min,
|
Min,
|
||||||
Max,
|
Max,
|
||||||
@ -44,16 +57,20 @@ public class DoubleSummaryGauge implements NBMetricGauge, DoubleConsumer {
|
|||||||
Sum
|
Sum
|
||||||
}
|
}
|
||||||
|
|
||||||
public DoubleSummaryGauge(NBLabels labels, Stat stat, DoubleSummaryStatistics stats) {
|
public DoubleSummaryGauge(NBLabels labels, Stat stat, DoubleSummaryStatistics stats, String description, MetricCategory... categories) {
|
||||||
this.labels = labels;
|
this.labels = labels;
|
||||||
this.stat = stat;
|
this.stat = stat;
|
||||||
this.stats = stats;
|
this.stats = stats;
|
||||||
|
this.description = description;
|
||||||
|
this.categories = categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DoubleSummaryGauge(NBLabels labels, Stat stat) {
|
public DoubleSummaryGauge(NBLabels labels, Stat stat,String description, MetricCategory... categories) {
|
||||||
this.labels = labels;
|
this.labels = labels;
|
||||||
this.stat = stat;
|
this.stat = stat;
|
||||||
this.stats = new DoubleSummaryStatistics();
|
this.stats = new DoubleSummaryStatistics();
|
||||||
|
this.description = description;
|
||||||
|
this.categories = categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void accept(double value) {
|
public synchronized void accept(double value) {
|
||||||
|
@ -20,9 +20,13 @@ import io.nosqlbench.nb.api.labels.NBLabels;
|
|||||||
|
|
||||||
public class NBBaseMetric implements NBMetric {
|
public class NBBaseMetric implements NBMetric {
|
||||||
private final NBLabels labels;
|
private final NBLabels labels;
|
||||||
|
private String description;
|
||||||
|
private MetricCategory[] categories;
|
||||||
|
|
||||||
public NBBaseMetric(String... labels) {
|
public NBBaseMetric(NBLabels labels, String description, MetricCategory... categories) {
|
||||||
this.labels = NBLabels.forKV((Object[]) labels);
|
this.labels = labels;
|
||||||
|
this.description = description;
|
||||||
|
this.categories = categories;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public NBLabels getLabels() {
|
public NBLabels getLabels() {
|
||||||
@ -33,4 +37,14 @@ public class NBBaseMetric implements NBMetric {
|
|||||||
public String typeName() {
|
public String typeName() {
|
||||||
return "basetype";
|
return "basetype";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetricCategory[] getCategories() {
|
||||||
|
return this.categories;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,14 +28,31 @@ public class NBFunctionGauge implements NBMetricGauge {
|
|||||||
private final Supplier<Double> source;
|
private final Supplier<Double> source;
|
||||||
private final NBLabeledElement parent;
|
private final NBLabeledElement parent;
|
||||||
private final NBLabels labels;
|
private final NBLabels labels;
|
||||||
|
private String description;
|
||||||
|
private MetricCategory[] categories;
|
||||||
|
|
||||||
public NBFunctionGauge(NBComponent parent, Supplier<Double> source, String metricFamilyName, Map<String,String> additionalLabels) {
|
public NBFunctionGauge(
|
||||||
|
NBComponent parent,
|
||||||
|
Supplier<Double> source,
|
||||||
|
String metricFamilyName,
|
||||||
|
Map<String,String> additionalLabels,
|
||||||
|
String description,
|
||||||
|
MetricCategory... categories
|
||||||
|
) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.labels = NBLabels.forMap(additionalLabels).and("name",metricFamilyName);
|
this.labels = NBLabels.forMap(additionalLabels).and("name",metricFamilyName);
|
||||||
this.source = source;
|
this.source = source;
|
||||||
|
this.description = description;
|
||||||
|
this.categories = categories;
|
||||||
}
|
}
|
||||||
public NBFunctionGauge(NBComponent parent, Supplier<Double> source, String metricFamilyName) {
|
public NBFunctionGauge(
|
||||||
this(parent, source, metricFamilyName,Map.of());
|
NBComponent parent,
|
||||||
|
Supplier<Double> source,
|
||||||
|
String metricFamilyName,
|
||||||
|
String description,
|
||||||
|
MetricCategory... categories
|
||||||
|
) {
|
||||||
|
this(parent, source, metricFamilyName,Map.of(), description, categories);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Double getValue() {
|
public Double getValue() {
|
||||||
@ -56,6 +73,16 @@ public class NBFunctionGauge implements NBMetricGauge {
|
|||||||
public String typeName() {
|
public String typeName() {
|
||||||
return "gauge";
|
return "gauge";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetricCategory[] getCategories() {
|
||||||
|
return this.categories;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,4 +24,7 @@ public interface NBMetric extends Metric, NBLabeledElement {
|
|||||||
return this.getLabels().linearizeAsMetrics();
|
return this.getLabels().linearizeAsMetrics();
|
||||||
}
|
}
|
||||||
String typeName();
|
String typeName();
|
||||||
|
|
||||||
|
String getDescription();
|
||||||
|
MetricCategory[] getCategories();
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,13 @@ import io.nosqlbench.nb.api.labels.NBLabels;
|
|||||||
public class NBMetricCounter extends Counter implements NBMetric {
|
public class NBMetricCounter extends Counter implements NBMetric {
|
||||||
|
|
||||||
private final NBLabels labels;
|
private final NBLabels labels;
|
||||||
|
private String description;
|
||||||
|
private MetricCategory[] categories;
|
||||||
|
|
||||||
public NBMetricCounter(final NBLabels labels) {
|
public NBMetricCounter(final NBLabels labels, String description, MetricCategory... categories) {
|
||||||
this.labels = labels;
|
this.labels = labels;
|
||||||
|
this.description = description;
|
||||||
|
this.categories = categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,6 +41,16 @@ public class NBMetricCounter extends Counter implements NBMetric {
|
|||||||
return "counter";
|
return "counter";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetricCategory[] getCategories() {
|
||||||
|
return this.categories;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return description();
|
return description();
|
||||||
|
@ -23,14 +23,18 @@ public class NBMetricGaugeWrapper implements NBMetricGauge, NBMetric {
|
|||||||
|
|
||||||
private final Gauge<Double> gauge;
|
private final Gauge<Double> gauge;
|
||||||
private final NBLabels labels;
|
private final NBLabels labels;
|
||||||
|
private final String description;
|
||||||
|
private final MetricCategory[] categories;
|
||||||
|
|
||||||
public NBMetricGaugeWrapper(NBLabels labels, Gauge<Double> gauge) {
|
public NBMetricGaugeWrapper(NBLabels labels, Gauge<Double> gauge, String description, MetricCategory... categories) {
|
||||||
this.gauge = gauge;
|
this.gauge = gauge;
|
||||||
if (gauge.getValue() instanceof Double d) {
|
if (gauge.getValue() instanceof Double d) {
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("NBMetricGauges only support Double values");
|
throw new RuntimeException("NBMetricGauges only support Double values");
|
||||||
}
|
}
|
||||||
this.labels = labels;
|
this.labels = labels;
|
||||||
|
this.description = description;
|
||||||
|
this.categories = categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,4 +51,14 @@ public class NBMetricGaugeWrapper implements NBMetricGauge, NBMetric {
|
|||||||
public String typeName() {
|
public String typeName() {
|
||||||
return "gauge";
|
return "gauge";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetricCategory[] getCategories() {
|
||||||
|
return this.categories;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,17 +31,33 @@ public class NBMetricHistogram extends Histogram implements DeltaSnapshotter, Hd
|
|||||||
private long cacheExpiryMillis;
|
private long cacheExpiryMillis;
|
||||||
private long cacheTimeMillis;
|
private long cacheTimeMillis;
|
||||||
private List<Histogram> mirrors;
|
private List<Histogram> mirrors;
|
||||||
|
private MetricCategory[] categories;
|
||||||
|
private String description;
|
||||||
|
|
||||||
public NBMetricHistogram(NBLabels labels, DeltaHdrHistogramReservoir hdrHistogramReservoir) {
|
public NBMetricHistogram(
|
||||||
|
NBLabels labels,
|
||||||
|
DeltaHdrHistogramReservoir hdrHistogramReservoir,
|
||||||
|
String description,
|
||||||
|
MetricCategory... categories
|
||||||
|
) {
|
||||||
super(hdrHistogramReservoir);
|
super(hdrHistogramReservoir);
|
||||||
this.labels = labels;
|
this.labels = labels;
|
||||||
this.hdrDeltaReservoir = hdrHistogramReservoir;
|
this.hdrDeltaReservoir = hdrHistogramReservoir;
|
||||||
|
this.description = description;
|
||||||
|
this.categories = categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NBMetricHistogram(String name, DeltaHdrHistogramReservoir hdrHistogramReservoir) {
|
public NBMetricHistogram(
|
||||||
|
String name,
|
||||||
|
DeltaHdrHistogramReservoir hdrHistogramReservoir,
|
||||||
|
String description,
|
||||||
|
MetricCategory... categories
|
||||||
|
) {
|
||||||
super(hdrHistogramReservoir);
|
super(hdrHistogramReservoir);
|
||||||
this.labels = NBLabels.forKV("name",name);
|
this.labels = NBLabels.forKV("name",name);
|
||||||
this.hdrDeltaReservoir = hdrHistogramReservoir;
|
this.hdrDeltaReservoir = hdrHistogramReservoir;
|
||||||
|
this.description = description;
|
||||||
|
this.categories = categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -76,7 +92,7 @@ public class NBMetricHistogram extends Histogram implements DeltaSnapshotter, Hd
|
|||||||
mirrors = new CopyOnWriteArrayList<>();
|
mirrors = new CopyOnWriteArrayList<>();
|
||||||
}
|
}
|
||||||
DeltaHdrHistogramReservoir mirrorReservoir = this.hdrDeltaReservoir.copySettings();
|
DeltaHdrHistogramReservoir mirrorReservoir = this.hdrDeltaReservoir.copySettings();
|
||||||
NBMetricHistogram mirror = new NBMetricHistogram("mirror-" + this.labels.linearizeValues("name"), mirrorReservoir);
|
NBMetricHistogram mirror = new NBMetricHistogram("mirror-" + this.labels.linearizeValues("name"), mirrorReservoir, description, categories);
|
||||||
mirrors.add(mirror);
|
mirrors.add(mirror);
|
||||||
return mirror;
|
return mirror;
|
||||||
}
|
}
|
||||||
@ -115,6 +131,16 @@ public class NBMetricHistogram extends Histogram implements DeltaSnapshotter, Hd
|
|||||||
return "histogram";
|
return "histogram";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetricCategory[] getCategories() {
|
||||||
|
return this.categories;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return description();
|
return description();
|
||||||
|
@ -22,9 +22,13 @@ import io.nosqlbench.nb.api.labels.NBLabels;
|
|||||||
public class NBMetricMeter extends Meter implements NBMetric {
|
public class NBMetricMeter extends Meter implements NBMetric {
|
||||||
|
|
||||||
private final NBLabels labels;
|
private final NBLabels labels;
|
||||||
|
private final MetricCategory[] categories;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
public NBMetricMeter(NBLabels labels) {
|
public NBMetricMeter(NBLabels labels, String description, MetricCategory... categories) {
|
||||||
this.labels = labels;
|
this.labels = labels;
|
||||||
|
this.description = description;
|
||||||
|
this.categories = categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -36,4 +40,14 @@ public class NBMetricMeter extends Meter implements NBMetric {
|
|||||||
public String typeName() {
|
public String typeName() {
|
||||||
return "meter";
|
return "meter";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetricCategory[] getCategories() {
|
||||||
|
return this.categories;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,21 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
public class NBMetricTimer extends Timer implements DeltaSnapshotter, HdrDeltaHistogramAttachment, TimerAttachment, NBMetric {
|
public class NBMetricTimer extends Timer implements DeltaSnapshotter, HdrDeltaHistogramAttachment, TimerAttachment, NBMetric {
|
||||||
private final DeltaHdrHistogramReservoir deltaHdrHistogramReservoir;
|
private final DeltaHdrHistogramReservoir deltaHdrHistogramReservoir;
|
||||||
|
private final String description;
|
||||||
|
private final MetricCategory[] categories;
|
||||||
private long cacheExpiry;
|
private long cacheExpiry;
|
||||||
private List<Timer> mirrors;
|
private List<Timer> mirrors;
|
||||||
private final NBLabels labels;
|
private final NBLabels labels;
|
||||||
|
|
||||||
public NBMetricTimer(final NBLabels labels, final DeltaHdrHistogramReservoir deltaHdrHistogramReservoir) {
|
public NBMetricTimer(
|
||||||
|
final NBLabels labels,
|
||||||
|
final DeltaHdrHistogramReservoir deltaHdrHistogramReservoir,
|
||||||
|
String description,
|
||||||
|
MetricCategory... categories
|
||||||
|
) {
|
||||||
super(deltaHdrHistogramReservoir);
|
super(deltaHdrHistogramReservoir);
|
||||||
|
this.description = description;
|
||||||
|
this.categories = categories;
|
||||||
this.labels = labels;
|
this.labels = labels;
|
||||||
this.deltaHdrHistogramReservoir = deltaHdrHistogramReservoir;
|
this.deltaHdrHistogramReservoir = deltaHdrHistogramReservoir;
|
||||||
}
|
}
|
||||||
@ -60,7 +69,7 @@ public class NBMetricTimer extends Timer implements DeltaSnapshotter, HdrDeltaHi
|
|||||||
public synchronized NBMetricTimer attachHdrDeltaHistogram() {
|
public synchronized NBMetricTimer attachHdrDeltaHistogram() {
|
||||||
if (null == mirrors) this.mirrors = new CopyOnWriteArrayList<>();
|
if (null == mirrors) this.mirrors = new CopyOnWriteArrayList<>();
|
||||||
final DeltaHdrHistogramReservoir sameConfigReservoir = deltaHdrHistogramReservoir.copySettings();
|
final DeltaHdrHistogramReservoir sameConfigReservoir = deltaHdrHistogramReservoir.copySettings();
|
||||||
final NBMetricTimer mirror = new NBMetricTimer(labels, sameConfigReservoir);
|
final NBMetricTimer mirror = new NBMetricTimer(labels, sameConfigReservoir, description, categories);
|
||||||
this.mirrors.add(mirror);
|
this.mirrors.add(mirror);
|
||||||
return mirror;
|
return mirror;
|
||||||
}
|
}
|
||||||
@ -96,4 +105,14 @@ public class NBMetricTimer extends Timer implements DeltaSnapshotter, HdrDeltaHi
|
|||||||
public String typeName() {
|
public String typeName() {
|
||||||
return "timer";
|
return "timer";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetricCategory[] getCategories() {
|
||||||
|
return this.categories;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,22 @@ public class NBVariableGauge implements NBMetricGauge {
|
|||||||
private double value;
|
private double value;
|
||||||
private final NBLabeledElement parent;
|
private final NBLabeledElement parent;
|
||||||
private final NBLabels labels;
|
private final NBLabels labels;
|
||||||
|
private String description;
|
||||||
|
private MetricCategory[] categories;
|
||||||
|
|
||||||
public NBVariableGauge(NBComponent parent, String metricFamilyName, double initialValue, String... additionalLabels) {
|
public NBVariableGauge(
|
||||||
|
NBComponent parent,
|
||||||
|
String metricFamilyName,
|
||||||
|
double initialValue,
|
||||||
|
NBLabels additionalLabels,
|
||||||
|
String description,
|
||||||
|
MetricCategory... categories
|
||||||
|
) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.labels = NBLabels.forKV((Object[]) additionalLabels).and("name", metricFamilyName);
|
this.labels = additionalLabels.and("name", metricFamilyName);
|
||||||
this.value = initialValue;
|
this.value = initialValue;
|
||||||
|
this.description = description;
|
||||||
|
this.categories = categories;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,4 +61,14 @@ public class NBVariableGauge implements NBMetricGauge {
|
|||||||
public String typeName() {
|
public String typeName() {
|
||||||
return "gauge";
|
return "gauge";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetricCategory[] getCategories() {
|
||||||
|
return this.categories;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import io.nosqlbench.nb.api.components.core.NBBaseComponentMetrics;
|
|||||||
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
|
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
|
||||||
import io.nosqlbench.nb.api.engine.metrics.instruments.NBBaseMetric;
|
import io.nosqlbench.nb.api.engine.metrics.instruments.NBBaseMetric;
|
||||||
import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetric;
|
import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetric;
|
||||||
|
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,13 +32,13 @@ class NBBaseComponentMetricsTest {
|
|||||||
@Test
|
@Test
|
||||||
void testBasicAddAndLookup() {
|
void testBasicAddAndLookup() {
|
||||||
NBBaseComponentMetrics cm = new NBBaseComponentMetrics();
|
NBBaseComponentMetrics cm = new NBBaseComponentMetrics();
|
||||||
NBMetric m1 = new NBBaseMetric("k","20");
|
NBMetric m1 = new NBBaseMetric(NBLabels.forKV("k","20"),"test metric", MetricCategory.Verification);
|
||||||
String m1Handle = cm.addComponentMetric(
|
String m1Handle = cm.addComponentMetric(
|
||||||
m1,
|
m1,
|
||||||
MetricCategory.Verification,
|
MetricCategory.Verification,
|
||||||
"testing metric"
|
"testing metric"
|
||||||
);
|
);
|
||||||
NBMetric m2 = new NBBaseMetric("k","27","l","62");
|
NBMetric m2 = new NBBaseMetric(NBLabels.forKV("k","27","l","62"),"test metric", MetricCategory.Verification);
|
||||||
String m2Handle = cm.addComponentMetric(
|
String m2Handle = cm.addComponentMetric(
|
||||||
m2,
|
m2,
|
||||||
MetricCategory.Verification,
|
MetricCategory.Verification,
|
||||||
@ -50,13 +51,13 @@ class NBBaseComponentMetricsTest {
|
|||||||
@Test
|
@Test
|
||||||
void find() {
|
void find() {
|
||||||
NBBaseComponentMetrics cm = new NBBaseComponentMetrics();
|
NBBaseComponentMetrics cm = new NBBaseComponentMetrics();
|
||||||
NBMetric m1 = new NBBaseMetric("k","20");
|
NBMetric m1 = new NBBaseMetric(NBLabels.forKV("k","20"),"test metric", MetricCategory.Verification);
|
||||||
String m1Handle = cm.addComponentMetric(
|
String m1Handle = cm.addComponentMetric(
|
||||||
m1,
|
m1,
|
||||||
MetricCategory.Verification,
|
MetricCategory.Verification,
|
||||||
"testing metric"
|
"testing metric"
|
||||||
);
|
);
|
||||||
NBMetric m2 = new NBBaseMetric("k","27","l","62");
|
NBMetric m2 = new NBBaseMetric(NBLabels.forKV("k","27","l","62"),"test metric", MetricCategory.Verification);
|
||||||
String m2Handle = cm.addComponentMetric(
|
String m2Handle = cm.addComponentMetric(
|
||||||
m2,
|
m2,
|
||||||
MetricCategory.Verification,
|
MetricCategory.Verification,
|
||||||
|
@ -20,6 +20,7 @@ import io.nosqlbench.nb.api.config.standard.TestComponent;
|
|||||||
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
|
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
|
||||||
import io.nosqlbench.nb.api.engine.metrics.instruments.NBBaseMetric;
|
import io.nosqlbench.nb.api.engine.metrics.instruments.NBBaseMetric;
|
||||||
import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetric;
|
import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetric;
|
||||||
|
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,19 +32,31 @@ class NBMetricsQueryTest {
|
|||||||
private final static TestComponent root = new TestComponent("root","root","type","rootelement");
|
private final static TestComponent root = new TestComponent("root","root","type","rootelement");
|
||||||
private final static TestComponent root_c2 = new TestComponent(root,"c2","c2");
|
private final static TestComponent root_c2 = new TestComponent(root,"c2","c2");
|
||||||
private final static TestComponent root_c3 = new TestComponent(root,"c3","c3");
|
private final static TestComponent root_c3 = new TestComponent(root,"c3","c3");
|
||||||
private final static NBMetric m1 = new NBBaseMetric("m1","m1");
|
private final static NBMetric m1 = new NBBaseMetric(
|
||||||
|
NBLabels.forKV("m1", "m1"),
|
||||||
|
"test metric",
|
||||||
|
MetricCategory.Verification
|
||||||
|
);
|
||||||
private final static String m1Handle = root.addComponentMetric(
|
private final static String m1Handle = root.addComponentMetric(
|
||||||
m1,
|
m1,
|
||||||
MetricCategory.Verification,
|
MetricCategory.Verification,
|
||||||
"testing metric"
|
"testing metric"
|
||||||
);
|
);
|
||||||
private final static NBMetric m2 = new NBBaseMetric("m2","m2");
|
private final static NBMetric m2 = new NBBaseMetric(
|
||||||
|
NBLabels.forKV("m2", "m2"),
|
||||||
|
"test metric",
|
||||||
|
MetricCategory.Verification
|
||||||
|
);
|
||||||
private final static String m2Handle = root_c2.addComponentMetric(
|
private final static String m2Handle = root_c2.addComponentMetric(
|
||||||
m2,
|
m2,
|
||||||
MetricCategory.Verification,
|
MetricCategory.Verification,
|
||||||
"testing metric"
|
"testing metric"
|
||||||
);
|
);
|
||||||
private final static NBMetric m3 = new NBBaseMetric("m3","m3");
|
private final static NBMetric m3 = new NBBaseMetric(
|
||||||
|
NBLabels.forKV("m3", "m3"),
|
||||||
|
"test metric",
|
||||||
|
MetricCategory.Verification
|
||||||
|
);
|
||||||
private final static String m3Handle = root_c3.addComponentMetric(
|
private final static String m3Handle = root_c3.addComponentMetric(
|
||||||
m3,
|
m3,
|
||||||
MetricCategory.Verification,
|
MetricCategory.Verification,
|
||||||
|
@ -46,7 +46,11 @@ public class PromExpositionFormatTest {
|
|||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testCounterFormat() {
|
public void testCounterFormat() {
|
||||||
Counter counter = new NBMetricCounter(NBLabels.forKV("name","counter_test_2342", "origin","mars"));
|
Counter counter = new NBMetricCounter(
|
||||||
|
NBLabels.forKV("name","counter_test_2342", "origin","mars"),
|
||||||
|
"test counter format",
|
||||||
|
MetricCategory.Verification
|
||||||
|
);
|
||||||
counter.inc(23423L);
|
counter.inc(23423L);
|
||||||
|
|
||||||
String buffer = PromExpositionFormat.format(nowclock, counter);
|
String buffer = PromExpositionFormat.format(nowclock, counter);
|
||||||
@ -64,7 +68,12 @@ public class PromExpositionFormatTest {
|
|||||||
for (long i = 0; 1000 > i; i++) {
|
for (long i = 0; 1000 > i; i++) {
|
||||||
hdr.update(i * 37L);
|
hdr.update(i * 37L);
|
||||||
}
|
}
|
||||||
NBMetricHistogram nbHistogram = new NBMetricHistogram(NBLabels.forKV("name","mynameismud","label3", "value3"), hdr);
|
NBMetricHistogram nbHistogram = new NBMetricHistogram(
|
||||||
|
NBLabels.forKV("name","mynameismud","label3", "value3"),
|
||||||
|
hdr,
|
||||||
|
"test histogram format",
|
||||||
|
MetricCategory.Verification
|
||||||
|
);
|
||||||
String formatted = PromExpositionFormat.format(nowclock, nbHistogram);
|
String formatted = PromExpositionFormat.format(nowclock, nbHistogram);
|
||||||
|
|
||||||
assertThat(formatted).matches(Pattern.compile("""
|
assertThat(formatted).matches(Pattern.compile("""
|
||||||
@ -95,7 +104,12 @@ public class PromExpositionFormatTest {
|
|||||||
public void testTimerFormat() {
|
public void testTimerFormat() {
|
||||||
|
|
||||||
DeltaHdrHistogramReservoir hdr = new DeltaHdrHistogramReservoir(NBLabels.forKV("name","monsieurmarius","label4","value4"),3);
|
DeltaHdrHistogramReservoir hdr = new DeltaHdrHistogramReservoir(NBLabels.forKV("name","monsieurmarius","label4","value4"),3);
|
||||||
NBMetricTimer nbMetricTimer = new NBMetricTimer(NBLabels.forKV("name","monsieurmarius","label4", "value4"), hdr);
|
NBMetricTimer nbMetricTimer = new NBMetricTimer(
|
||||||
|
NBLabels.forKV("name","monsieurmarius","label4", "value4"),
|
||||||
|
hdr,
|
||||||
|
"test timer format",
|
||||||
|
MetricCategory.Verification
|
||||||
|
);
|
||||||
for (long i = 0; 1000 > i; i++)
|
for (long i = 0; 1000 > i; i++)
|
||||||
nbMetricTimer.update(i * 37L, TimeUnit.NANOSECONDS);
|
nbMetricTimer.update(i * 37L, TimeUnit.NANOSECONDS);
|
||||||
|
|
||||||
@ -135,7 +149,11 @@ public class PromExpositionFormatTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMeterFormat() {
|
public void testMeterFormat() {
|
||||||
NBMetricMeter nbMetricMeter = new NBMetricMeter(NBLabels.forKV("name","eponine","label5", "value5"));
|
NBMetricMeter nbMetricMeter = new NBMetricMeter(
|
||||||
|
NBLabels.forKV("name","eponine","label5", "value5"),
|
||||||
|
"test meter format",
|
||||||
|
MetricCategory.Verification
|
||||||
|
);
|
||||||
String formatted = PromExpositionFormat.format(nowclock, nbMetricMeter);
|
String formatted = PromExpositionFormat.format(nowclock, nbMetricMeter);
|
||||||
|
|
||||||
assertThat(formatted).matches(Pattern.compile("""
|
assertThat(formatted).matches(Pattern.compile("""
|
||||||
@ -155,7 +173,12 @@ public class PromExpositionFormatTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGaugeFormat() {
|
public void testGaugeFormat() {
|
||||||
Gauge cosetteGauge = () -> 1500d;
|
Gauge cosetteGauge = () -> 1500d;
|
||||||
NBMetricGauge nbMetricGauge = new NBMetricGaugeWrapper(NBLabels.forKV("name","cosette","label6", "value6"), cosetteGauge);
|
NBMetricGauge nbMetricGauge = new NBMetricGaugeWrapper(
|
||||||
|
NBLabels.forKV("name","cosette","label6", "value6"),
|
||||||
|
cosetteGauge,
|
||||||
|
"test gauge format",
|
||||||
|
MetricCategory.Verification
|
||||||
|
);
|
||||||
String formatted = PromExpositionFormat.format(nowclock, nbMetricGauge);
|
String formatted = PromExpositionFormat.format(nowclock, nbMetricGauge);
|
||||||
|
|
||||||
assertThat(formatted).matches(Pattern.compile("""
|
assertThat(formatted).matches(Pattern.compile("""
|
||||||
@ -164,7 +187,12 @@ public class PromExpositionFormatTest {
|
|||||||
"""));
|
"""));
|
||||||
|
|
||||||
Gauge cosetteGauge2 = () -> 2000.0d;
|
Gauge cosetteGauge2 = () -> 2000.0d;
|
||||||
NBMetricGauge nbMetricGauge2 = new NBMetricGaugeWrapper(NBLabels.forKV("name","cosette2","label7", "value7"), cosetteGauge2);
|
NBMetricGauge nbMetricGauge2 = new NBMetricGaugeWrapper(
|
||||||
|
NBLabels.forKV("name","cosette2","label7", "value7"),
|
||||||
|
cosetteGauge2,
|
||||||
|
"test gauge format 2",
|
||||||
|
MetricCategory.Verification
|
||||||
|
);
|
||||||
String formatted2 = PromExpositionFormat.format(nowclock, nbMetricGauge2);
|
String formatted2 = PromExpositionFormat.format(nowclock, nbMetricGauge2);
|
||||||
|
|
||||||
assertThat(formatted2).matches(Pattern.compile("""
|
assertThat(formatted2).matches(Pattern.compile("""
|
||||||
|
Loading…
Reference in New Issue
Block a user