Update to OTel 1.5 (#73)
This commit is contained in:
parent
b26bb07994
commit
efc9952336
|
|
@ -6,7 +6,7 @@ package io.opentelemetry.contrib.awsxray;
|
|||
|
||||
import com.google.auto.service.AutoService;
|
||||
import io.opentelemetry.sdk.autoconfigure.ConfigProperties;
|
||||
import io.opentelemetry.sdk.autoconfigure.OpenTelemetrySdkAutoConfiguration;
|
||||
import io.opentelemetry.sdk.autoconfigure.OpenTelemetryResourceAutoConfiguration;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurableSamplerProvider;
|
||||
import io.opentelemetry.sdk.trace.samplers.Sampler;
|
||||
import java.util.Map;
|
||||
|
|
@ -17,7 +17,8 @@ public class AwsXrayRemoteSamplerProvider implements ConfigurableSamplerProvider
|
|||
@Override
|
||||
public Sampler createSampler(ConfigProperties config) {
|
||||
AwsXrayRemoteSamplerBuilder builder =
|
||||
AwsXrayRemoteSampler.newBuilder(OpenTelemetrySdkAutoConfiguration.getResource());
|
||||
AwsXrayRemoteSampler.newBuilder(
|
||||
OpenTelemetryResourceAutoConfiguration.configureResource(config));
|
||||
|
||||
Map<String, String> params = config.getCommaSeparatedMap("otel.traces.sampler.arg");
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ class AwsXrayRemoteSamplerProviderTest {
|
|||
|
||||
@Test
|
||||
void setEndpoint() {
|
||||
when(config.getCommaSeparatedMap("otel.resource.attributes"))
|
||||
.thenReturn(Collections.emptyMap());
|
||||
when(config.getCommaSeparatedMap("otel.traces.sampler.arg"))
|
||||
.thenReturn(Collections.singletonMap("endpoint", "http://localhost:3000"));
|
||||
try (AwsXrayRemoteSampler sampler =
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ val DEPENDENCY_BOMS = listOf(
|
|||
"org.junit:junit-bom:5.7.2",
|
||||
"com.linecorp.armeria:armeria-bom:1.9.1",
|
||||
"io.grpc:grpc-bom:1.39.0",
|
||||
"io.opentelemetry:opentelemetry-bom:1.4.1",
|
||||
"io.opentelemetry:opentelemetry-bom-alpha:1.4.1-alpha",
|
||||
"io.opentelemetry:opentelemetry-bom:1.5.0",
|
||||
"io.opentelemetry:opentelemetry-bom-alpha:1.5.0-alpha",
|
||||
"org.testcontainers:testcontainers-bom:1.16.0"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,23 +5,18 @@
|
|||
package io.opentelemetry.contrib.jmxmetrics;
|
||||
|
||||
import io.opentelemetry.api.GlobalOpenTelemetry;
|
||||
import io.opentelemetry.api.metrics.AsynchronousInstrument;
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.api.common.AttributesBuilder;
|
||||
import io.opentelemetry.api.metrics.DoubleCounter;
|
||||
import io.opentelemetry.api.metrics.DoubleSumObserver;
|
||||
import io.opentelemetry.api.metrics.DoubleHistogram;
|
||||
import io.opentelemetry.api.metrics.DoubleUpDownCounter;
|
||||
import io.opentelemetry.api.metrics.DoubleUpDownSumObserver;
|
||||
import io.opentelemetry.api.metrics.DoubleValueObserver;
|
||||
import io.opentelemetry.api.metrics.DoubleValueRecorder;
|
||||
import io.opentelemetry.api.metrics.GlobalMeterProvider;
|
||||
import io.opentelemetry.api.metrics.LongCounter;
|
||||
import io.opentelemetry.api.metrics.LongSumObserver;
|
||||
import io.opentelemetry.api.metrics.LongHistogram;
|
||||
import io.opentelemetry.api.metrics.LongUpDownCounter;
|
||||
import io.opentelemetry.api.metrics.LongUpDownSumObserver;
|
||||
import io.opentelemetry.api.metrics.LongValueObserver;
|
||||
import io.opentelemetry.api.metrics.LongValueRecorder;
|
||||
import io.opentelemetry.api.metrics.Meter;
|
||||
import io.opentelemetry.api.metrics.common.Labels;
|
||||
import io.opentelemetry.api.metrics.common.LabelsBuilder;
|
||||
import io.opentelemetry.api.metrics.ObservableDoubleMeasurement;
|
||||
import io.opentelemetry.api.metrics.ObservableLongMeasurement;
|
||||
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
|
||||
import io.opentelemetry.sdk.metrics.common.InstrumentDescriptor;
|
||||
import io.opentelemetry.sdk.metrics.common.InstrumentType;
|
||||
|
|
@ -34,6 +29,7 @@ import java.util.Map;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class GroovyMetricEnvironment {
|
||||
|
||||
|
|
@ -48,9 +44,9 @@ public class GroovyMetricEnvironment {
|
|||
// updated w/ each instrument creation call. Otherwise no observed changes in MBean availability
|
||||
// would be possible. These registry stores are maps of instrument descriptor hashes to updater
|
||||
// consumer references.
|
||||
private final Map<Integer, AtomicReference<Consumer<AsynchronousInstrument.LongResult>>>
|
||||
private final Map<Integer, AtomicReference<Consumer<ObservableLongMeasurement>>>
|
||||
longUpdaterRegistry = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, AtomicReference<Consumer<AsynchronousInstrument.DoubleResult>>>
|
||||
private final Map<Integer, AtomicReference<Consumer<ObservableDoubleMeasurement>>>
|
||||
doubleUpdaterRegistry = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
|
|
@ -90,7 +86,7 @@ public class GroovyMetricEnvironment {
|
|||
exporter = InMemoryMetricExporter.create();
|
||||
}
|
||||
|
||||
meter = meterProvider.get(instrumentationName, instrumentationVersion);
|
||||
meter = meterProvider.get(instrumentationName, instrumentationVersion, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,14 +106,15 @@ public class GroovyMetricEnvironment {
|
|||
}
|
||||
}
|
||||
|
||||
protected static Labels mapToLabels(final Map<String, String> labelMap) {
|
||||
LabelsBuilder labels = Labels.builder();
|
||||
if (labelMap != null) {
|
||||
for (Map.Entry<String, String> kv : labelMap.entrySet()) {
|
||||
labels.put(kv.getKey(), kv.getValue());
|
||||
}
|
||||
protected static Attributes mapToAttributes(@Nullable final Map<String, String> labelMap) {
|
||||
if (labelMap == null) {
|
||||
return Attributes.empty();
|
||||
}
|
||||
return labels.build();
|
||||
AttributesBuilder attrs = Attributes.builder();
|
||||
for (Map.Entry<String, String> kv : labelMap.entrySet()) {
|
||||
attrs.put(kv.getKey(), kv.getValue());
|
||||
}
|
||||
return attrs.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -130,7 +127,7 @@ public class GroovyMetricEnvironment {
|
|||
*/
|
||||
public DoubleCounter getDoubleCounter(
|
||||
final String name, final String description, final String unit) {
|
||||
return meter.doubleCounterBuilder(name).setDescription(description).setUnit(unit).build();
|
||||
return meter.counterBuilder(name).setDescription(description).setUnit(unit).ofDoubles().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -143,7 +140,7 @@ public class GroovyMetricEnvironment {
|
|||
*/
|
||||
public LongCounter getLongCounter(
|
||||
final String name, final String description, final String unit) {
|
||||
return meter.longCounterBuilder(name).setDescription(description).setUnit(unit).build();
|
||||
return meter.counterBuilder(name).setDescription(description).setUnit(unit).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -156,7 +153,12 @@ public class GroovyMetricEnvironment {
|
|||
*/
|
||||
public DoubleUpDownCounter getDoubleUpDownCounter(
|
||||
final String name, final String description, final String unit) {
|
||||
return meter.doubleUpDownCounterBuilder(name).setDescription(description).setUnit(unit).build();
|
||||
return meter
|
||||
.upDownCounterBuilder(name)
|
||||
.setDescription(description)
|
||||
.setUnit(unit)
|
||||
.ofDoubles()
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -169,209 +171,201 @@ public class GroovyMetricEnvironment {
|
|||
*/
|
||||
public LongUpDownCounter getLongUpDownCounter(
|
||||
final String name, final String description, final String unit) {
|
||||
return meter.longUpDownCounterBuilder(name).setDescription(description).setUnit(unit).build();
|
||||
return meter.upDownCounterBuilder(name).setDescription(description).setUnit(unit).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build or retrieve previously registered {@link DoubleValueRecorder}.
|
||||
* Build or retrieve previously registered {@link DoubleHistogram}.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @return new or memoized {@link DoubleValueRecorder}
|
||||
* @return new or memoized {@link DoubleHistogram}
|
||||
*/
|
||||
public DoubleValueRecorder getDoubleValueRecorder(
|
||||
public DoubleHistogram getDoubleHistogram(
|
||||
final String name, final String description, final String unit) {
|
||||
return meter.doubleValueRecorderBuilder(name).setDescription(description).setUnit(unit).build();
|
||||
return meter.histogramBuilder(name).setDescription(description).setUnit(unit).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build or retrieve previously registered {@link LongValueRecorder}.
|
||||
* Build or retrieve previously registered {@link }.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @return new or memoized {@link LongValueRecorder}
|
||||
* @return new or memoized {@link LongHistogram}
|
||||
*/
|
||||
public LongValueRecorder getLongValueRecorder(
|
||||
public LongHistogram getLongHistogram(
|
||||
final String name, final String description, final String unit) {
|
||||
return meter.longValueRecorderBuilder(name).setDescription(description).setUnit(unit).build();
|
||||
return meter.histogramBuilder(name).setDescription(description).setUnit(unit).ofLongs().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build or retrieve previously registered {@link DoubleSumObserver}.
|
||||
* Register a double observable gauge.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @param updater - the value updater
|
||||
* @return new or memoized {@link DoubleSumObserver}
|
||||
*/
|
||||
public DoubleSumObserver getDoubleSumObserver(
|
||||
public void registerDoubleValueCallback(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final Consumer<AsynchronousInstrument.DoubleResult> updater) {
|
||||
return meter
|
||||
.doubleSumObserverBuilder(name)
|
||||
final Consumer<ObservableDoubleMeasurement> updater) {
|
||||
meter
|
||||
.gaugeBuilder(name)
|
||||
.setDescription(description)
|
||||
.setUnit(unit)
|
||||
.setUpdater(
|
||||
proxiedDoubleObserver(name, description, unit, InstrumentType.SUM_OBSERVER, updater))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build or retrieve previously registered {@link LongSumObserver}.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @param updater - the value updater
|
||||
* @return new or memoized {@link LongSumObserver}
|
||||
*/
|
||||
public LongSumObserver getLongSumObserver(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final Consumer<AsynchronousInstrument.LongResult> updater) {
|
||||
return meter
|
||||
.longSumObserverBuilder(name)
|
||||
.setDescription(description)
|
||||
.setUnit(unit)
|
||||
.setUpdater(
|
||||
proxiedLongObserver(name, description, unit, InstrumentType.SUM_OBSERVER, updater))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build or retrieve previously registered {@link DoubleUpDownSumObserver}.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @param updater - the value updater
|
||||
* @return new or memoized {@link DoubleUpDownSumObserver}
|
||||
*/
|
||||
public DoubleUpDownSumObserver getDoubleUpDownSumObserver(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final Consumer<AsynchronousInstrument.DoubleResult> updater) {
|
||||
return meter
|
||||
.doubleUpDownSumObserverBuilder(name)
|
||||
.setDescription(description)
|
||||
.setUnit(unit)
|
||||
.setUpdater(
|
||||
.buildWithCallback(
|
||||
proxiedDoubleObserver(
|
||||
name, description, unit, InstrumentType.UP_DOWN_SUM_OBSERVER, updater))
|
||||
.build();
|
||||
name, description, unit, InstrumentType.OBSERVABLE_GAUGE, updater));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build or retrieve previously registered {@link LongUpDownSumObserver}.
|
||||
* Register a long observable gauge.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @param updater - the value updater
|
||||
* @return new or memoized {@link LongUpDownSumObserver}
|
||||
*/
|
||||
public LongUpDownSumObserver getLongUpDownSumObserver(
|
||||
public void registerLongValueCallback(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final Consumer<AsynchronousInstrument.LongResult> updater) {
|
||||
return meter
|
||||
.longUpDownSumObserverBuilder(name)
|
||||
final Consumer<ObservableLongMeasurement> updater) {
|
||||
meter
|
||||
.gaugeBuilder(name)
|
||||
.ofLongs()
|
||||
.setDescription(description)
|
||||
.setUnit(unit)
|
||||
.setUpdater(
|
||||
.buildWithCallback(
|
||||
proxiedLongObserver(name, description, unit, InstrumentType.OBSERVABLE_GAUGE, updater));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an observable double counter.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @param updater - the value updater
|
||||
*/
|
||||
public void registerDoubleCounterCallback(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final Consumer<ObservableDoubleMeasurement> updater) {
|
||||
meter
|
||||
.counterBuilder(name)
|
||||
.ofDoubles()
|
||||
.setDescription(description)
|
||||
.setUnit(unit)
|
||||
.buildWithCallback(
|
||||
proxiedDoubleObserver(name, description, unit, InstrumentType.OBSERVABLE_SUM, updater));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an observable long counter.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @param updater - the value updater
|
||||
*/
|
||||
public void registerLongCounterCallback(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final Consumer<ObservableLongMeasurement> updater) {
|
||||
meter
|
||||
.counterBuilder(name)
|
||||
.setDescription(description)
|
||||
.setUnit(unit)
|
||||
.buildWithCallback(
|
||||
proxiedLongObserver(name, description, unit, InstrumentType.OBSERVABLE_SUM, updater));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an observable double updown counter.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @param updater - the value updater
|
||||
*/
|
||||
public void registerDoubleUpDownCounterCallback(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final Consumer<ObservableDoubleMeasurement> updater) {
|
||||
meter
|
||||
.upDownCounterBuilder(name)
|
||||
.ofDoubles()
|
||||
.setDescription(description)
|
||||
.setUnit(unit)
|
||||
.buildWithCallback(
|
||||
proxiedDoubleObserver(
|
||||
name, description, unit, InstrumentType.OBSERVABLE_UP_DOWN_SUM, updater));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an observable long updown counter.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @param updater - the value updater
|
||||
*/
|
||||
public void registerLongUpDownCounterCallback(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final Consumer<ObservableLongMeasurement> updater) {
|
||||
meter
|
||||
.upDownCounterBuilder(name)
|
||||
.setDescription(description)
|
||||
.setUnit(unit)
|
||||
.buildWithCallback(
|
||||
proxiedLongObserver(
|
||||
name, description, unit, InstrumentType.UP_DOWN_SUM_OBSERVER, updater))
|
||||
.build();
|
||||
name, description, unit, InstrumentType.OBSERVABLE_UP_DOWN_SUM, updater));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build or retrieve previously registered {@link DoubleValueObserver}.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @param updater - the value updater
|
||||
* @return new or memoized {@link DoubleValueObserver}
|
||||
*/
|
||||
public DoubleValueObserver getDoubleValueObserver(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final Consumer<AsynchronousInstrument.DoubleResult> updater) {
|
||||
return meter
|
||||
.doubleValueObserverBuilder(name)
|
||||
.setDescription(description)
|
||||
.setUnit(unit)
|
||||
.setUpdater(
|
||||
proxiedDoubleObserver(name, description, unit, InstrumentType.VALUE_OBSERVER, updater))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build or retrieve previously registered {@link LongValueObserver}.
|
||||
*
|
||||
* @param name - metric name
|
||||
* @param description metric description
|
||||
* @param unit - metric unit
|
||||
* @param updater - the value updater
|
||||
* @return new or memoized {@link LongValueObserver}
|
||||
*/
|
||||
public LongValueObserver getLongValueObserver(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final Consumer<AsynchronousInstrument.LongResult> updater) {
|
||||
return meter
|
||||
.longValueObserverBuilder(name)
|
||||
.setDescription(description)
|
||||
.setUnit(unit)
|
||||
.setUpdater(
|
||||
proxiedLongObserver(name, description, unit, InstrumentType.VALUE_OBSERVER, updater))
|
||||
.build();
|
||||
}
|
||||
|
||||
private Consumer<AsynchronousInstrument.DoubleResult> proxiedDoubleObserver(
|
||||
private Consumer<ObservableDoubleMeasurement> proxiedDoubleObserver(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final InstrumentType instrumentType,
|
||||
final Consumer<AsynchronousInstrument.DoubleResult> updater) {
|
||||
final Consumer<ObservableDoubleMeasurement> updater) {
|
||||
InstrumentDescriptor descriptor =
|
||||
InstrumentDescriptor.create(
|
||||
name, description, unit, instrumentType, InstrumentValueType.DOUBLE);
|
||||
doubleUpdaterRegistry.putIfAbsent(descriptor.hashCode(), new AtomicReference<>());
|
||||
AtomicReference<Consumer<AsynchronousInstrument.DoubleResult>> existingUpdater =
|
||||
AtomicReference<Consumer<ObservableDoubleMeasurement>> existingUpdater =
|
||||
doubleUpdaterRegistry.get(descriptor.hashCode());
|
||||
existingUpdater.set(updater);
|
||||
return doubleResult -> {
|
||||
Consumer<AsynchronousInstrument.DoubleResult> existing = existingUpdater.get();
|
||||
Consumer<ObservableDoubleMeasurement> existing = existingUpdater.get();
|
||||
existing.accept(doubleResult);
|
||||
};
|
||||
}
|
||||
|
||||
private Consumer<AsynchronousInstrument.LongResult> proxiedLongObserver(
|
||||
private Consumer<ObservableLongMeasurement> proxiedLongObserver(
|
||||
final String name,
|
||||
final String description,
|
||||
final String unit,
|
||||
final InstrumentType instrumentType,
|
||||
final Consumer<AsynchronousInstrument.LongResult> updater) {
|
||||
final Consumer<ObservableLongMeasurement> updater) {
|
||||
InstrumentDescriptor descriptor =
|
||||
InstrumentDescriptor.create(
|
||||
name, description, unit, instrumentType, InstrumentValueType.LONG);
|
||||
longUpdaterRegistry.putIfAbsent(descriptor.hashCode(), new AtomicReference<>());
|
||||
AtomicReference<Consumer<AsynchronousInstrument.LongResult>> existingUpdater =
|
||||
AtomicReference<Consumer<ObservableLongMeasurement>> existingUpdater =
|
||||
longUpdaterRegistry.get(descriptor.hashCode());
|
||||
existingUpdater.set(updater);
|
||||
return longResult -> {
|
||||
Consumer<AsynchronousInstrument.LongResult> existing = existingUpdater.get();
|
||||
Consumer<ObservableLongMeasurement> existing = existingUpdater.get();
|
||||
existing.accept(longResult);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ class InstrumentHelper {
|
|||
}
|
||||
|
||||
private static Closure prepareUpdateClosure(inst, value, labels) {
|
||||
def labelMap = GroovyMetricEnvironment.mapToLabels(labels)
|
||||
def labelMap = GroovyMetricEnvironment.mapToAttributes(labels)
|
||||
if (instrumentIsObserver(inst)) {
|
||||
return { result ->
|
||||
result.observe(value, labelMap)
|
||||
|
|
@ -152,12 +152,12 @@ class InstrumentHelper {
|
|||
|
||||
@PackageScope static boolean instrumentIsObserver(inst) {
|
||||
return [
|
||||
"doubleSumObserver",
|
||||
"doubleUpDownSumObserver",
|
||||
"longSumObserver",
|
||||
"longUpDownSumObserver",
|
||||
"doubleValueObserver" ,
|
||||
"longValueObserver"
|
||||
"doubleCounterCallback",
|
||||
"doubleUpDownCounterCallback",
|
||||
"longCounterCallback",
|
||||
"longUpDownCounterCallback",
|
||||
"doubleValueCallback" ,
|
||||
"longValueCallback"
|
||||
].contains(inst.method)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,18 +5,11 @@
|
|||
package io.opentelemetry.contrib.jmxmetrics
|
||||
|
||||
import io.opentelemetry.api.metrics.DoubleCounter
|
||||
import io.opentelemetry.api.metrics.DoubleSumObserver
|
||||
import io.opentelemetry.api.metrics.DoubleHistogram
|
||||
import io.opentelemetry.api.metrics.DoubleUpDownCounter
|
||||
import io.opentelemetry.api.metrics.DoubleUpDownSumObserver
|
||||
import io.opentelemetry.api.metrics.DoubleValueObserver
|
||||
import io.opentelemetry.api.metrics.DoubleValueRecorder
|
||||
import io.opentelemetry.api.metrics.LongCounter
|
||||
import io.opentelemetry.api.metrics.LongSumObserver
|
||||
import io.opentelemetry.api.metrics.LongHistogram
|
||||
import io.opentelemetry.api.metrics.LongUpDownCounter
|
||||
import io.opentelemetry.api.metrics.LongUpDownSumObserver
|
||||
import io.opentelemetry.api.metrics.LongValueObserver
|
||||
import io.opentelemetry.api.metrics.LongValueRecorder
|
||||
|
||||
import javax.management.ObjectName
|
||||
|
||||
class OtelHelper {
|
||||
|
|
@ -143,99 +136,99 @@ class OtelHelper {
|
|||
return longUpDownCounter(name, '')
|
||||
}
|
||||
|
||||
DoubleValueRecorder doubleValueRecorder(String name, String description, String unit) {
|
||||
return groovyMetricEnvironment.getDoubleValueRecorder(name, description, unit)
|
||||
DoubleHistogram doubleHistogram(String name, String description, String unit) {
|
||||
return groovyMetricEnvironment.getDoubleHistogram(name, description, unit)
|
||||
}
|
||||
|
||||
DoubleValueRecorder doubleValueRecorder(String name, String description) {
|
||||
return doubleValueRecorder(name, description, SCALAR)
|
||||
DoubleHistogram doubleHistogram(String name, String description) {
|
||||
return doubleHistogram(name, description, SCALAR)
|
||||
}
|
||||
|
||||
DoubleValueRecorder doubleValueRecorder(String name) {
|
||||
return doubleValueRecorder(name, '')
|
||||
DoubleHistogram doubleHistogram(String name) {
|
||||
return doubleHistogram(name, '')
|
||||
}
|
||||
|
||||
LongValueRecorder longValueRecorder(String name, String description, String unit) {
|
||||
return groovyMetricEnvironment.getLongValueRecorder(name, description, unit)
|
||||
LongHistogram longHistogram(String name, String description, String unit) {
|
||||
return groovyMetricEnvironment.getLongHistogram(name, description, unit)
|
||||
}
|
||||
|
||||
LongValueRecorder longValueRecorder(String name, String description) {
|
||||
return longValueRecorder(name, description, SCALAR)
|
||||
LongHistogram longHistogram(String name, String description) {
|
||||
return longHistogram(name, description, SCALAR)
|
||||
}
|
||||
|
||||
LongValueRecorder longValueRecorder(String name) {
|
||||
return longValueRecorder(name, '')
|
||||
LongHistogram longHistogram(String name) {
|
||||
return longHistogram(name, '')
|
||||
}
|
||||
|
||||
DoubleSumObserver doubleSumObserver(String name, String description, String unit, Closure updater) {
|
||||
return groovyMetricEnvironment.getDoubleSumObserver(name, description, unit, updater)
|
||||
void doubleCounterCallback(String name, String description, String unit, Closure updater) {
|
||||
groovyMetricEnvironment.registerDoubleCounterCallback(name, description, unit, updater)
|
||||
}
|
||||
|
||||
DoubleSumObserver doubleSumObserver(String name, String description, Closure updater) {
|
||||
return doubleSumObserver(name, description, SCALAR, updater)
|
||||
void doubleCounterCallback(String name, String description, Closure updater) {
|
||||
doubleCounterCallback(name, description, SCALAR, updater)
|
||||
}
|
||||
|
||||
DoubleSumObserver doubleSumObserver(String name, Closure updater) {
|
||||
return doubleSumObserver(name, '', updater)
|
||||
void doubleCounterCallback(String name, Closure updater) {
|
||||
doubleCounterCallback(name, '', updater)
|
||||
}
|
||||
|
||||
LongSumObserver longSumObserver(String name, String description, String unit, Closure updater) {
|
||||
return groovyMetricEnvironment.getLongSumObserver(name, description, unit, updater)
|
||||
void longCounterCallback(String name, String description, String unit, Closure updater) {
|
||||
groovyMetricEnvironment.registerLongCounterCallback(name, description, unit, updater)
|
||||
}
|
||||
|
||||
LongSumObserver longSumObserver(String name, String description, Closure updater) {
|
||||
return longSumObserver(name, description, SCALAR, updater)
|
||||
void longCounterCallback(String name, String description, Closure updater) {
|
||||
longCounterCallback(name, description, SCALAR, updater)
|
||||
}
|
||||
|
||||
LongSumObserver longSumObserver(String name, Closure updater) {
|
||||
return longSumObserver(name, '', updater)
|
||||
void longCounterCallback(String name, Closure updater) {
|
||||
longCounterCallback(name, '', updater)
|
||||
}
|
||||
|
||||
DoubleUpDownSumObserver doubleUpDownSumObserver(String name, String description, String unit, Closure updater) {
|
||||
return groovyMetricEnvironment.getDoubleUpDownSumObserver(name, description, unit, updater)
|
||||
void doubleUpDownCounterCallback(String name, String description, String unit, Closure updater) {
|
||||
groovyMetricEnvironment.registerDoubleUpDownCounterCallback(name, description, unit, updater)
|
||||
}
|
||||
|
||||
DoubleUpDownSumObserver doubleUpDownSumObserver(String name, String description, Closure updater) {
|
||||
return doubleUpDownSumObserver(name, description, SCALAR, updater)
|
||||
void doubleUpDownCounterCallback(String name, String description, Closure updater) {
|
||||
doubleUpDownCounterCallback(name, description, SCALAR, updater)
|
||||
}
|
||||
|
||||
DoubleUpDownSumObserver doubleUpDownSumObserver(String name, Closure updater) {
|
||||
return doubleUpDownSumObserver(name, '', updater)
|
||||
void doubleUpDownCounterCallback(String name, Closure updater) {
|
||||
doubleUpDownCounterCallback(name, '', updater)
|
||||
}
|
||||
|
||||
LongUpDownSumObserver longUpDownSumObserver(String name, String description, String unit, Closure updater) {
|
||||
return groovyMetricEnvironment.getLongUpDownSumObserver(name, description, unit, updater)
|
||||
void longUpDownCounterCallback(String name, String description, String unit, Closure updater) {
|
||||
groovyMetricEnvironment.registerLongUpDownCounterCallback(name, description, unit, updater)
|
||||
}
|
||||
|
||||
LongUpDownSumObserver longUpDownSumObserver(String name, String description, Closure updater) {
|
||||
return longUpDownSumObserver(name, description, SCALAR, updater)
|
||||
void longUpDownCounterCallback(String name, String description, Closure updater) {
|
||||
longUpDownCounterCallback(name, description, SCALAR, updater)
|
||||
}
|
||||
|
||||
LongUpDownSumObserver longUpDownSumObserver(String name, Closure updater) {
|
||||
return longUpDownSumObserver(name, '', updater)
|
||||
void longUpDownCounterCallback(String name, Closure updater) {
|
||||
longUpDownCounterCallback(name, '', updater)
|
||||
}
|
||||
|
||||
DoubleValueObserver doubleValueObserver(String name, String description, String unit, Closure updater) {
|
||||
return groovyMetricEnvironment.getDoubleValueObserver(name, description, unit, updater)
|
||||
void doubleValueCallback(String name, String description, String unit, Closure updater) {
|
||||
groovyMetricEnvironment.registerDoubleValueCallback(name, description, unit, updater)
|
||||
}
|
||||
|
||||
DoubleValueObserver doubleValueObserver(String name, String description, Closure updater) {
|
||||
return doubleValueObserver(name, description, SCALAR, updater)
|
||||
void doubleValueCallback(String name, String description, Closure updater) {
|
||||
doubleValueCallback(name, description, SCALAR, updater)
|
||||
}
|
||||
|
||||
DoubleValueObserver doubleValueObserver(String name, Closure updater) {
|
||||
return doubleValueObserver(name, '', updater)
|
||||
void doubleValueCallback(String name, Closure updater) {
|
||||
doubleValueCallback(name, '', updater)
|
||||
}
|
||||
|
||||
LongValueObserver longValueObserver(String name, String description, String unit, Closure updater) {
|
||||
return groovyMetricEnvironment.getLongValueObserver(name, description, unit, updater)
|
||||
void longValueCallback(String name, String description, String unit, Closure updater) {
|
||||
groovyMetricEnvironment.registerLongValueCallback(name, description, unit, updater)
|
||||
}
|
||||
|
||||
LongValueObserver longValueObserver(String name, String description, Closure updater) {
|
||||
return longValueObserver(name, description, SCALAR, updater)
|
||||
void longValueCallback(String name, String description, Closure updater) {
|
||||
longValueCallback(name, description, SCALAR, updater)
|
||||
}
|
||||
|
||||
LongValueObserver longValueObserver(String name, Closure updater) {
|
||||
return longValueObserver(name, '', updater)
|
||||
void longValueCallback(String name, Closure updater) {
|
||||
longValueCallback(name, '', updater)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,131 +21,131 @@ def clientRequestRangeSliceLatency = otel.mbean("${clientRequestRangeSlice},name
|
|||
otel.instrument(clientRequestRangeSliceLatency,
|
||||
"cassandra.client.request.range_slice.latency.50p",
|
||||
"Token range read request latency - 50th percentile", "µs", "50thPercentile",
|
||||
otel.&doubleValueObserver)
|
||||
otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(clientRequestRangeSliceLatency,
|
||||
"cassandra.client.request.range_slice.latency.99p",
|
||||
"Token range read request latency - 99th percentile", "µs", "99thPercentile",
|
||||
otel.&doubleValueObserver)
|
||||
otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(clientRequestRangeSliceLatency,
|
||||
"cassandra.client.request.range_slice.latency.count",
|
||||
"Total token range read request latency", "µs", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
otel.instrument(clientRequestRangeSliceLatency,
|
||||
"cassandra.client.request.range_slice.latency.max",
|
||||
"Maximum token range read request latency", "µs", "Max",
|
||||
otel.&doubleValueObserver)
|
||||
otel.&doubleValueCallback)
|
||||
|
||||
def clientRequestRangeSliceTimeouts = otel.mbean("${clientRequestRangeSlice},name=Timeouts")
|
||||
otel.instrument(clientRequestRangeSliceTimeouts,
|
||||
"cassandra.client.request.range_slice.timeout.count",
|
||||
"Number of token range read request timeouts encountered", "1", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
def clientRequestRangeSliceUnavailables = otel.mbean("${clientRequestRangeSlice},name=Unavailables")
|
||||
otel.instrument(clientRequestRangeSliceUnavailables,
|
||||
"cassandra.client.request.range_slice.unavailable.count",
|
||||
"Number of token range read request unavailable exceptions encountered", "1", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
def clientRequestRead = "${clientRequest},scope=Read"
|
||||
def clientRequestReadLatency = otel.mbean("${clientRequestRead},name=Latency")
|
||||
otel.instrument(clientRequestReadLatency,
|
||||
"cassandra.client.request.read.latency.50p",
|
||||
"Standard read request latency - 50th percentile", "µs", "50thPercentile",
|
||||
otel.&doubleValueObserver)
|
||||
otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(clientRequestReadLatency,
|
||||
"cassandra.client.request.read.latency.99p",
|
||||
"Standard read request latency - 99th percentile", "µs", "99thPercentile",
|
||||
otel.&doubleValueObserver)
|
||||
otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(clientRequestReadLatency,
|
||||
"cassandra.client.request.read.latency.count",
|
||||
"Total standard read request latency", "µs", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
otel.instrument(clientRequestReadLatency,
|
||||
"cassandra.client.request.read.latency.max",
|
||||
"Maximum standard read request latency", "µs", "Max",
|
||||
otel.&doubleValueObserver)
|
||||
otel.&doubleValueCallback)
|
||||
|
||||
def clientRequestReadTimeouts = otel.mbean("${clientRequestRead},name=Timeouts")
|
||||
otel.instrument(clientRequestReadTimeouts,
|
||||
"cassandra.client.request.read.timeout.count",
|
||||
"Number of standard read request timeouts encountered", "1", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
def clientRequestReadUnavailables = otel.mbean("${clientRequestRead},name=Unavailables")
|
||||
otel.instrument(clientRequestReadUnavailables,
|
||||
"cassandra.client.request.read.unavailable.count",
|
||||
"Number of standard read request unavailable exceptions encountered", "1", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
def clientRequestWrite = "${clientRequest},scope=Write"
|
||||
def clientRequestWriteLatency = otel.mbean("${clientRequestWrite},name=Latency")
|
||||
otel.instrument(clientRequestWriteLatency,
|
||||
"cassandra.client.request.write.latency.50p",
|
||||
"Regular write request latency - 50th percentile", "µs", "50thPercentile",
|
||||
otel.&doubleValueObserver)
|
||||
otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(clientRequestWriteLatency,
|
||||
"cassandra.client.request.write.latency.99p",
|
||||
"Regular write request latency - 99th percentile", "µs", "99thPercentile",
|
||||
otel.&doubleValueObserver)
|
||||
otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(clientRequestWriteLatency,
|
||||
"cassandra.client.request.write.latency.count",
|
||||
"Total regular write request latency", "µs", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
otel.instrument(clientRequestWriteLatency,
|
||||
"cassandra.client.request.write.latency.max",
|
||||
"Maximum regular write request latency", "µs", "Max",
|
||||
otel.&doubleValueObserver)
|
||||
otel.&doubleValueCallback)
|
||||
|
||||
def clientRequestWriteTimeouts = otel.mbean("${clientRequestWrite},name=Timeouts")
|
||||
otel.instrument(clientRequestWriteTimeouts,
|
||||
"cassandra.client.request.write.timeout.count",
|
||||
"Number of regular write request timeouts encountered", "1", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
def clientRequestWriteUnavailables = otel.mbean("${clientRequestWrite},name=Unavailables")
|
||||
otel.instrument(clientRequestWriteUnavailables,
|
||||
"cassandra.client.request.write.unavailable.count",
|
||||
"Number of regular write request unavailable exceptions encountered", "1", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
def storage = "${cassandraMetrics}:type=Storage"
|
||||
def storageLoad = otel.mbean("${storage},name=Load")
|
||||
otel.instrument(storageLoad,
|
||||
"cassandra.storage.load.count",
|
||||
"Size of the on disk data size this node manages", "by", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
def storageTotalHints = otel.mbean("${storage},name=TotalHints")
|
||||
otel.instrument(storageTotalHints,
|
||||
"cassandra.storage.total_hints.count",
|
||||
"Number of hint messages written to this node since [re]start", "1", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
def storageTotalHintsInProgress = otel.mbean("${storage},name=TotalHintsInProgress")
|
||||
otel.instrument(storageTotalHintsInProgress,
|
||||
"cassandra.storage.total_hints.in_progress.count",
|
||||
"Number of hints attempting to be sent currently", "1", "Count",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
||||
def compaction = "${cassandraMetrics}:type=Compaction"
|
||||
def compactionPendingTasks = otel.mbean("${compaction},name=PendingTasks")
|
||||
otel.instrument(compactionPendingTasks,
|
||||
"cassandra.compaction.tasks.pending",
|
||||
"Estimated number of compactions remaining to perform", "1", "Value",
|
||||
otel.&longValueObserver)
|
||||
otel.&longValueCallback)
|
||||
|
||||
def compactionCompletedTasks = otel.mbean("${compaction},name=CompletedTasks")
|
||||
otel.instrument(compactionCompletedTasks,
|
||||
"cassandra.compaction.tasks.completed",
|
||||
"Number of completed compactions since server [re]start", "1", "Value",
|
||||
otel.&longSumObserver)
|
||||
otel.&longCounterCallback)
|
||||
|
|
|
|||
|
|
@ -16,28 +16,28 @@
|
|||
|
||||
def classLoading = otel.mbean("java.lang:type=ClassLoading")
|
||||
otel.instrument(classLoading, "jvm.classes.loaded", "number of loaded classes",
|
||||
"1", "LoadedClassCount", otel.&longValueObserver)
|
||||
"1", "LoadedClassCount", otel.&longValueCallback)
|
||||
|
||||
def garbageCollector = otel.mbeans("java.lang:type=GarbageCollector,*")
|
||||
otel.instrument(garbageCollector, "jvm.gc.collections.count", "total number of collections that have occurred",
|
||||
"1", ["name" : { mbean -> mbean.name().getKeyProperty("name") }],
|
||||
"CollectionCount", otel.&longSumObserver)
|
||||
"CollectionCount", otel.&longCounterCallback)
|
||||
otel.instrument(garbageCollector, "jvm.gc.collections.elapsed",
|
||||
"the approximate accumulated collection elapsed time in milliseconds", "ms",
|
||||
["name" : { mbean -> mbean.name().getKeyProperty("name") }],
|
||||
"CollectionTime", otel.&longSumObserver)
|
||||
"CollectionTime", otel.&longCounterCallback)
|
||||
|
||||
def memory = otel.mbean("java.lang:type=Memory")
|
||||
otel.instrument(memory, "jvm.memory.heap", "current heap usage",
|
||||
"by", "HeapMemoryUsage", otel.&longValueObserver)
|
||||
"by", "HeapMemoryUsage", otel.&longValueCallback)
|
||||
otel.instrument(memory, "jvm.memory.nonheap", "current non-heap usage",
|
||||
"by", "NonHeapMemoryUsage", otel.&longValueObserver)
|
||||
"by", "NonHeapMemoryUsage", otel.&longValueCallback)
|
||||
|
||||
def memoryPool = otel.mbeans("java.lang:type=MemoryPool,*")
|
||||
otel.instrument(memoryPool, "jvm.memory.pool", "current memory pool usage",
|
||||
"by", ["name" : { mbean -> mbean.name().getKeyProperty("name") }],
|
||||
"Usage", otel.&longValueObserver)
|
||||
"Usage", otel.&longValueCallback)
|
||||
|
||||
def threading = otel.mbean("java.lang:type=Threading")
|
||||
otel.instrument(threading, "jvm.threads.count", "number of threads",
|
||||
"1", "ThreadCount", otel.&longValueObserver)
|
||||
"1", "ThreadCount", otel.&longValueCallback)
|
||||
|
|
|
|||
|
|
@ -18,43 +18,43 @@ def consumerFetchManagerMetrics = otel.mbeans("kafka.consumer:client-id=*,type=c
|
|||
otel.instrument(consumerFetchManagerMetrics, "kafka.consumer.fetch-rate",
|
||||
"The number of fetch requests for all topics per second", "1",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") }],
|
||||
"fetch-rate", otel.&doubleValueObserver)
|
||||
"fetch-rate", otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(consumerFetchManagerMetrics, "kafka.consumer.records-lag-max",
|
||||
"Number of messages the consumer lags behind the producer", "1",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") }],
|
||||
"records-lag-max", otel.&doubleValueObserver)
|
||||
"records-lag-max", otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(consumerFetchManagerMetrics, "kafka.consumer.total.bytes-consumed-rate",
|
||||
"The average number of bytes consumed for all topics per second", "by",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") }],
|
||||
"bytes-consumed-rate", otel.&doubleValueObserver)
|
||||
"bytes-consumed-rate", otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(consumerFetchManagerMetrics, "kafka.consumer.total.fetch-size-avg",
|
||||
"The average number of bytes fetched per request for all topics", "by",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") }],
|
||||
"fetch-size-avg", otel.&doubleValueObserver)
|
||||
"fetch-size-avg", otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(consumerFetchManagerMetrics, "kafka.consumer.total.records-consumed-rate",
|
||||
"The average number of records consumed for all topics per second", "1",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") }],
|
||||
"records-consumed-rate", otel.&doubleValueObserver)
|
||||
"records-consumed-rate", otel.&doubleValueCallback)
|
||||
|
||||
def consumerFetchManagerMetricsByTopic = otel.mbeans("kafka.consumer:client-id=*,topic=*,type=consumer-fetch-manager-metrics")
|
||||
otel.instrument(consumerFetchManagerMetricsByTopic, "kafka.consumer.bytes-consumed-rate",
|
||||
"The average number of bytes consumed per second", "by",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") },
|
||||
"topic" : { mbean -> mbean.name().getKeyProperty("topic") }],
|
||||
"bytes-consumed-rate", otel.&doubleValueObserver)
|
||||
"bytes-consumed-rate", otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(consumerFetchManagerMetricsByTopic, "kafka.consumer.fetch-size-avg",
|
||||
"The average number of bytes fetched per request", "by",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") },
|
||||
"topic" : { mbean -> mbean.name().getKeyProperty("topic") }],
|
||||
"fetch-size-avg", otel.&doubleValueObserver)
|
||||
"fetch-size-avg", otel.&doubleValueCallback)
|
||||
|
||||
otel.instrument(consumerFetchManagerMetricsByTopic, "kafka.consumer.records-consumed-rate",
|
||||
"The average number of records consumed per second", "1",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") },
|
||||
"topic" : { mbean -> mbean.name().getKeyProperty("topic") }],
|
||||
"records-consumed-rate", otel.&doubleValueObserver)
|
||||
"records-consumed-rate", otel.&doubleValueCallback)
|
||||
|
|
|
|||
|
|
@ -18,47 +18,47 @@ def producerMetrics = otel.mbeans("kafka.producer:client-id=*,type=producer-metr
|
|||
otel.instrument(producerMetrics, "kafka.producer.io-wait-time-ns-avg",
|
||||
"The average length of time the I/O thread spent waiting for a socket ready for reads or writes", "ns",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") }],
|
||||
"io-wait-time-ns-avg", otel.&doubleValueObserver)
|
||||
"io-wait-time-ns-avg", otel.&doubleValueCallback)
|
||||
otel.instrument(producerMetrics, "kafka.producer.outgoing-byte-rate",
|
||||
"The average number of outgoing bytes sent per second to all servers", "by",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") }],
|
||||
"outgoing-byte-rate", otel.&doubleValueObserver)
|
||||
"outgoing-byte-rate", otel.&doubleValueCallback)
|
||||
otel.instrument(producerMetrics, "kafka.producer.request-latency-avg",
|
||||
"The average request latency", "ms",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") }],
|
||||
"request-latency-avg", otel.&doubleValueObserver)
|
||||
"request-latency-avg", otel.&doubleValueCallback)
|
||||
otel.instrument(producerMetrics, "kafka.producer.request-rate",
|
||||
"The average number of requests sent per second", "1",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") }],
|
||||
"request-rate", otel.&doubleValueObserver)
|
||||
"request-rate", otel.&doubleValueCallback)
|
||||
otel.instrument(producerMetrics, "kafka.producer.response-rate",
|
||||
"Responses received per second", "1",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") }],
|
||||
"response-rate", otel.&doubleValueObserver)
|
||||
"response-rate", otel.&doubleValueCallback)
|
||||
|
||||
def producerTopicMetrics = otel.mbeans("kafka.producer:client-id=*,topic=*,type=producer-topic-metrics")
|
||||
otel.instrument(producerTopicMetrics, "kafka.producer.byte-rate",
|
||||
"The average number of bytes sent per second for a topic", "by",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") },
|
||||
"topic" : { mbean -> mbean.name().getKeyProperty("topic") }],
|
||||
"byte-rate", otel.&doubleValueObserver)
|
||||
"byte-rate", otel.&doubleValueCallback)
|
||||
otel.instrument(producerTopicMetrics, "kafka.producer.compression-rate",
|
||||
"The average compression rate of record batches for a topic", "1",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") },
|
||||
"topic" : { mbean -> mbean.name().getKeyProperty("topic") }],
|
||||
"compression-rate", otel.&doubleValueObserver)
|
||||
"compression-rate", otel.&doubleValueCallback)
|
||||
otel.instrument(producerTopicMetrics, "kafka.producer.record-error-rate",
|
||||
"The average per-second number of record sends that resulted in errors for a topic", "1",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") },
|
||||
"topic" : { mbean -> mbean.name().getKeyProperty("topic") }],
|
||||
"record-error-rate", otel.&doubleValueObserver)
|
||||
"record-error-rate", otel.&doubleValueCallback)
|
||||
otel.instrument(producerTopicMetrics, "kafka.producer.record-retry-rate",
|
||||
"The average per-second number of retried record sends for a topic", "1",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") },
|
||||
"topic" : { mbean -> mbean.name().getKeyProperty("topic") }],
|
||||
"record-retry-rate", otel.&doubleValueObserver)
|
||||
"record-retry-rate", otel.&doubleValueCallback)
|
||||
otel.instrument(producerTopicMetrics, "kafka.producer.record-send-rate",
|
||||
"The average number of records sent per second for a topic", "1",
|
||||
["client-id" : { mbean -> mbean.name().getKeyProperty("client-id") },
|
||||
"topic" : { mbean -> mbean.name().getKeyProperty("topic") }],
|
||||
"record-send-rate", otel.&doubleValueObserver)
|
||||
"record-send-rate", otel.&doubleValueCallback)
|
||||
|
|
|
|||
|
|
@ -16,80 +16,80 @@
|
|||
|
||||
def messagesInPerSec = otel.mbean("kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec")
|
||||
otel.instrument(messagesInPerSec, "kafka.messages.in", "number of messages in per second",
|
||||
"1", "Count", otel.&longValueObserver)
|
||||
"1", "Count", otel.&longValueCallback)
|
||||
|
||||
def bytesInPerSec = otel.mbean("kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec")
|
||||
otel.instrument(bytesInPerSec, "kafka.bytes.in", "bytes in per second from clients",
|
||||
"by", "Count", otel.&longValueObserver)
|
||||
"by", "Count", otel.&longValueCallback)
|
||||
|
||||
def bytesOutPerSec = otel.mbean("kafka.server:type=BrokerTopicMetrics,name=BytesOutPerSec")
|
||||
otel.instrument(bytesOutPerSec, "kafka.bytes.out", "bytes out per second to clients",
|
||||
"by", "Count", otel.&longValueObserver)
|
||||
"by", "Count", otel.&longValueCallback)
|
||||
|
||||
def isrShrinksPerSec = otel.mbean("kafka.server:type=ReplicaManager,name=IsrShrinksPerSec")
|
||||
otel.instrument(isrShrinksPerSec, "kafka.isr.shrinks", "in-sync replica shrinks per second",
|
||||
"1", "Count", otel.&longValueObserver)
|
||||
"1", "Count", otel.&longValueCallback)
|
||||
|
||||
def isrExpandsPerSec = otel.mbean("kafka.server:type=ReplicaManager,name=IsrExpandsPerSec")
|
||||
otel.instrument(isrExpandsPerSec, "kafka.isr.expands", "in-sync replica expands per second",
|
||||
"1", "Count", otel.&longValueObserver)
|
||||
"1", "Count", otel.&longValueCallback)
|
||||
|
||||
def maxLag = otel.mbean("kafka.server:type=ReplicaFetcherManager,name=MaxLag,clientId=Replica")
|
||||
otel.instrument(maxLag, "kafka.max.lag", "max lag in messages between follower and leader replicas",
|
||||
"1", "Value", otel.&longValueObserver)
|
||||
"1", "Value", otel.&longValueCallback)
|
||||
|
||||
def activeControllerCount = otel.mbean("kafka.controller:type=KafkaController,name=ActiveControllerCount")
|
||||
otel.instrument(activeControllerCount, "kafka.controller.active.count", "controller is active on broker",
|
||||
"1", "Value", otel.&longValueObserver)
|
||||
"1", "Value", otel.&longValueCallback)
|
||||
|
||||
def offlinePartitionsCount = otel.mbean("kafka.controller:type=KafkaController,name=OfflinePartitionsCount")
|
||||
otel.instrument(offlinePartitionsCount, "kafka.partitions.offline.count", "number of partitions without an active leader",
|
||||
"1", "Value", otel.&longValueObserver)
|
||||
"1", "Value", otel.&longValueCallback)
|
||||
|
||||
def underReplicatedPartitionsCount = otel.mbean("kafka.server:type=ReplicaManager,name=UnderReplicatedPartitions")
|
||||
otel.instrument(underReplicatedPartitionsCount, "kafka.partitions.underreplicated.count", "number of under replicated partitions",
|
||||
"1", "Value", otel.&longValueObserver)
|
||||
"1", "Value", otel.&longValueCallback)
|
||||
|
||||
def leaderElectionRate = otel.mbean("kafka.controller:type=ControllerStats,name=LeaderElectionRateAndTimeMs")
|
||||
otel.instrument(leaderElectionRate, "kafka.leader.election.rate", "leader election rate - non-zero indicates broker failures",
|
||||
"1", "Count", otel.&longValueObserver)
|
||||
"1", "Count", otel.&longValueCallback)
|
||||
|
||||
def uncleanLeaderElections = otel.mbean("kafka.controller:type=ControllerStats,name=UncleanLeaderElectionsPerSec")
|
||||
otel.instrument(uncleanLeaderElections, "kafka.unclean.election.rate", "unclean leader election rate - non-zero indicates broker failures",
|
||||
"1", "Count", otel.&longValueObserver)
|
||||
"1", "Count", otel.&longValueCallback)
|
||||
|
||||
def requestQueueSize = otel.mbean("kafka.network:type=RequestChannel,name=RequestQueueSize")
|
||||
otel.instrument(requestQueueSize, "kafka.request.queue", "size of the request queue",
|
||||
"1", "Value", otel.&longValueObserver)
|
||||
"1", "Value", otel.&longValueCallback)
|
||||
|
||||
def fetchConsumer = otel.mbean("kafka.network:type=RequestMetrics,name=TotalTimeMs,request=FetchConsumer")
|
||||
otel.instrument(fetchConsumer, "kafka.fetch.consumer.total.time.count", "fetch consumer request count",
|
||||
"1", "Count", otel.&longSumObserver)
|
||||
"1", "Count", otel.&longCounterCallback)
|
||||
otel.instrument(fetchConsumer, "kafka.fetch.consumer.total.time.median", "fetch consumer request time - 50th percentile",
|
||||
"ms", "50thPercentile", otel.&doubleValueObserver)
|
||||
"ms", "50thPercentile", otel.&doubleValueCallback)
|
||||
otel.instrument(fetchConsumer, "kafka.fetch.consumer.total.time.99p", "fetch consumer request time - 99th percentile",
|
||||
"ms", "99thPercentile", otel.&doubleValueObserver)
|
||||
"ms", "99thPercentile", otel.&doubleValueCallback)
|
||||
|
||||
def fetchFollower = otel.mbean("kafka.network:type=RequestMetrics,name=TotalTimeMs,request=FetchFollower")
|
||||
otel.instrument(fetchFollower, "kafka.fetch.follower.total.time.count", "fetch follower request count",
|
||||
"1", "Count", otel.&longSumObserver)
|
||||
"1", "Count", otel.&longCounterCallback)
|
||||
otel.instrument(fetchFollower, "kafka.fetch.follower.total.time.median", "fetch follower request time - 50th percentile",
|
||||
"ms", "50thPercentile", otel.&doubleValueObserver)
|
||||
"ms", "50thPercentile", otel.&doubleValueCallback)
|
||||
otel.instrument(fetchFollower, "kafka.fetch.follower.total.time.99p", "fetch follower request time - 99th percentile",
|
||||
"ms", "99thPercentile", otel.&doubleValueObserver)
|
||||
"ms", "99thPercentile", otel.&doubleValueCallback)
|
||||
|
||||
def produce = otel.mbean("kafka.network:type=RequestMetrics,name=TotalTimeMs,request=Produce")
|
||||
otel.instrument(produce, "kafka.produce.total.time.count", "produce request count",
|
||||
"1", "Count", otel.&longSumObserver)
|
||||
"1", "Count", otel.&longCounterCallback)
|
||||
otel.instrument(produce, "kafka.produce.total.time.median", "produce request time - 50th percentile",
|
||||
"ms", "50thPercentile", otel.&doubleValueObserver)
|
||||
"ms", "50thPercentile", otel.&doubleValueCallback)
|
||||
otel.instrument(produce, "kafka.produce.total.time.99p", "produce request time - 99th percentile",
|
||||
"ms", "99thPercentile", otel.&doubleValueObserver)
|
||||
"ms", "99thPercentile", otel.&doubleValueCallback)
|
||||
|
||||
def logFlushRate = otel.mbean("kafka.log:type=LogFlushStats,name=LogFlushRateAndTimeMs")
|
||||
otel.instrument(logFlushRate, "kafka.logs.flush.time.count", "log flush count",
|
||||
"1", "Count", otel.&longSumObserver)
|
||||
"1", "Count", otel.&longCounterCallback)
|
||||
otel.instrument(logFlushRate, "kafka.logs.flush.time.median", "log flush time - 50th percentile",
|
||||
"ms", "50thPercentile", otel.&doubleValueObserver)
|
||||
"ms", "50thPercentile", otel.&doubleValueCallback)
|
||||
otel.instrument(logFlushRate, "kafka.logs.flush.time.99p", "log flush time - 99th percentile",
|
||||
"ms", "99thPercentile", otel.&doubleValueObserver)
|
||||
"ms", "99thPercentile", otel.&doubleValueCallback)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ import spock.lang.Unroll
|
|||
|
||||
class InstrumentHelperTest extends Specification {
|
||||
|
||||
@Rule public final TestRule name = new TestName()
|
||||
@Rule
|
||||
public final TestRule name = new TestName()
|
||||
|
||||
@Shared
|
||||
MBeanServer mBeanServer
|
||||
|
|
@ -68,6 +69,7 @@ class InstrumentHelperTest extends Specification {
|
|||
|
||||
interface ThingMBean {
|
||||
double getDouble()
|
||||
|
||||
long getLong()
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +86,7 @@ class InstrumentHelperTest extends Specification {
|
|||
}
|
||||
|
||||
def exportMetrics() {
|
||||
def provider = GlobalMeterProvider.get().get(name.methodName, '')
|
||||
def provider = GlobalMeterProvider.get().get(name.methodName, '', null)
|
||||
return provider.collectAll(0).sort { md1, md2 ->
|
||||
def p1 = md1.data.points[0]
|
||||
def p2 = md2.data.points[0]
|
||||
|
|
@ -102,7 +104,8 @@ class InstrumentHelperTest extends Specification {
|
|||
|
||||
@Unroll
|
||||
def "#instrumentMethod via #quantity MBeanHelper"() {
|
||||
setup: "Create and register four Things and create ${quantity} MBeanHelper"
|
||||
setup:
|
||||
"Create and register four Things and create ${quantity} MBeanHelper"
|
||||
def thingName = "${quantity}:type=${instrumentMethod}.Thing"
|
||||
def things = (0..3).collect { new Thing() }
|
||||
things.eachWithIndex { thing, i ->
|
||||
|
|
@ -119,7 +122,7 @@ class InstrumentHelperTest extends Specification {
|
|||
def instrument = otel.&"${instrumentMethod}"
|
||||
def instrumentHelper = new InstrumentHelper(
|
||||
mbeanHelper, instrumentName, description, "1",
|
||||
["labelOne" : { "labelOneValue"}, "labelTwo": { mbean -> mbean.name().getKeyProperty("thing") }],
|
||||
["labelOne": { "labelOneValue" }, "labelTwo": { mbean -> mbean.name().getKeyProperty("thing") }],
|
||||
attribute, instrument)
|
||||
instrumentHelper.update()
|
||||
|
||||
|
|
@ -133,6 +136,7 @@ class InstrumentHelperTest extends Specification {
|
|||
assert metric.unit == "1"
|
||||
assert metric.type == metricType
|
||||
assert metric.data.points.size() == isSingle ? 1 : 4
|
||||
metric.data.points.sort { a, b -> String.compare(a.attributes.get(stringKey("labelTwo")), b.attributes.get(stringKey("labelTwo"))) }
|
||||
metric.data.points.eachWithIndex { point, i ->
|
||||
assert point.attributes == Attributes.of(stringKey("labelOne"), "labelOneValue", stringKey("labelTwo"), "${i}".toString())
|
||||
|
||||
|
|
@ -150,36 +154,37 @@ class InstrumentHelperTest extends Specification {
|
|||
}
|
||||
|
||||
where:
|
||||
isSingle | quantity | attribute | instrumentMethod | metricType | value
|
||||
true | "single" | "Double" | "doubleCounter" | DOUBLE_SUM | 123.456
|
||||
false | "multiple" | "Double" | "doubleCounter" | DOUBLE_SUM | 123.456
|
||||
true | "single" | "Double" | "doubleUpDownCounter" | DOUBLE_SUM | 123.456
|
||||
false | "multiple" | "Double" | "doubleUpDownCounter" | DOUBLE_SUM | 123.456
|
||||
true | "single" | "Long" | "longCounter" | LONG_SUM | 234
|
||||
false | "multiple" | "Long" | "longCounter" | LONG_SUM | 234
|
||||
true | "single" | "Long" | "longUpDownCounter" | LONG_SUM | 234
|
||||
false | "multiple" | "Long" | "longUpDownCounter" | LONG_SUM | 234
|
||||
true | "single" | "Double" | "doubleValueRecorder" | SUMMARY | 123.456
|
||||
false | "multiple" | "Double" | "doubleValueRecorder" | SUMMARY | 123.456
|
||||
true | "single" | "Long" | "longValueRecorder" | SUMMARY | 234
|
||||
false | "multiple" | "Long" | "longValueRecorder" | SUMMARY | 234
|
||||
true | "single" | "Double" | "doubleSumObserver" | DOUBLE_SUM | 123.456
|
||||
false | "multiple" | "Double" | "doubleSumObserver" | DOUBLE_SUM | 123.456
|
||||
true | "single" | "Double" | "doubleUpDownSumObserver" | DOUBLE_SUM | 123.456
|
||||
false | "multiple" | "Double" | "doubleUpDownSumObserver" | DOUBLE_SUM | 123.456
|
||||
true | "single" | "Long" | "longSumObserver" | LONG_SUM | 234
|
||||
false | "multiple" | "Long" | "longSumObserver" | LONG_SUM | 234
|
||||
true | "single" | "Long" | "longUpDownSumObserver" | LONG_SUM | 234
|
||||
false | "multiple" | "Long" | "longUpDownSumObserver" | LONG_SUM | 234
|
||||
true | "single" | "Double" | "doubleValueObserver" | DOUBLE_GAUGE | 123.456
|
||||
false | "multiple" | "Double" | "doubleValueObserver" | DOUBLE_GAUGE | 123.456
|
||||
true | "single" | "Long" | "longValueObserver" | LONG_GAUGE | 234
|
||||
false | "multiple" | "Long" | "longValueObserver" | LONG_GAUGE | 234
|
||||
isSingle | quantity | attribute | instrumentMethod | metricType | value
|
||||
true | "single" | "Double" | "doubleCounter" | DOUBLE_SUM | 123.456
|
||||
false | "multiple" | "Double" | "doubleCounter" | DOUBLE_SUM | 123.456
|
||||
true | "single" | "Double" | "doubleUpDownCounter" | DOUBLE_SUM | 123.456
|
||||
false | "multiple" | "Double" | "doubleUpDownCounter" | DOUBLE_SUM | 123.456
|
||||
true | "single" | "Long" | "longCounter" | LONG_SUM | 234
|
||||
false | "multiple" | "Long" | "longCounter" | LONG_SUM | 234
|
||||
true | "single" | "Long" | "longUpDownCounter" | LONG_SUM | 234
|
||||
false | "multiple" | "Long" | "longUpDownCounter" | LONG_SUM | 234
|
||||
true | "single" | "Double" | "doubleHistogram" | SUMMARY | 123.456
|
||||
false | "multiple" | "Double" | "doubleHistogram" | SUMMARY | 123.456
|
||||
true | "single" | "Long" | "longHistogram" | SUMMARY | 234
|
||||
false | "multiple" | "Long" | "longHistogram" | SUMMARY | 234
|
||||
true | "single" | "Double" | "doubleCounterCallback" | DOUBLE_SUM | 123.456
|
||||
false | "multiple" | "Double" | "doubleCounterCallback" | DOUBLE_SUM | 123.456
|
||||
true | "single" | "Double" | "doubleUpDownCounterCallback" | DOUBLE_SUM | 123.456
|
||||
false | "multiple" | "Double" | "doubleUpDownCounterCallback" | DOUBLE_SUM | 123.456
|
||||
true | "single" | "Long" | "longCounterCallback" | LONG_SUM | 234
|
||||
false | "multiple" | "Long" | "longCounterCallback" | LONG_SUM | 234
|
||||
true | "single" | "Long" | "longUpDownCounterCallback" | LONG_SUM | 234
|
||||
false | "multiple" | "Long" | "longUpDownCounterCallback" | LONG_SUM | 234
|
||||
true | "single" | "Double" | "doubleValueCallback" | DOUBLE_GAUGE | 123.456
|
||||
false | "multiple" | "Double" | "doubleValueCallback" | DOUBLE_GAUGE | 123.456
|
||||
true | "single" | "Long" | "longValueCallback" | LONG_GAUGE | 234
|
||||
false | "multiple" | "Long" | "longValueCallback" | LONG_GAUGE | 234
|
||||
}
|
||||
|
||||
@Unroll
|
||||
def "handles nulls returned from MBeanHelper"() {
|
||||
setup: "Create and register four Things and create ${quantity} MBeanHelper"
|
||||
setup:
|
||||
"Create and register four Things and create ${quantity} MBeanHelper"
|
||||
def thingName = "${quantity}:type=${instrumentMethod}.${attribute}.Thing"
|
||||
def things = (0..3).collect { new Thing() }
|
||||
things.eachWithIndex { thing, i ->
|
||||
|
|
@ -196,7 +201,7 @@ class InstrumentHelperTest extends Specification {
|
|||
def instrument = otel.&"${instrumentMethod}"
|
||||
def instrumentHelper = new InstrumentHelper(
|
||||
mbeanHelper, instrumentName, description, "1",
|
||||
["labelOne" : { "labelOneValue"}, "labelTwo": { mbean -> mbean.name().getKeyProperty("thing") }],
|
||||
["labelOne": { "labelOneValue" }, "labelTwo": { mbean -> mbean.name().getKeyProperty("thing") }],
|
||||
attribute, instrument)
|
||||
instrumentHelper.update()
|
||||
|
||||
|
|
@ -205,9 +210,9 @@ class InstrumentHelperTest extends Specification {
|
|||
metrics.size() == 0
|
||||
|
||||
where:
|
||||
isSingle | quantity | attribute | instrumentMethod | metricType | value
|
||||
true | "single" | "Missing" | "longValueObserver" | LONG_GAUGE | null
|
||||
false | "multiple" | "Missing" | "longValueObserver" | LONG_GAUGE | null
|
||||
isSingle | quantity | attribute | instrumentMethod | metricType | value
|
||||
true | "single" | "Missing" | "longValueCallback" | LONG_GAUGE | null
|
||||
false | "multiple" | "Missing" | "longValueCallback" | LONG_GAUGE | null
|
||||
}
|
||||
|
||||
@Unroll
|
||||
|
|
@ -218,18 +223,18 @@ class InstrumentHelperTest extends Specification {
|
|||
assert InstrumentHelper.instrumentIsCounter(instrument) == isCounter
|
||||
|
||||
where:
|
||||
instrumentMethod | isObserver | isCounter
|
||||
"doubleCounter" | false | true
|
||||
"longCounter" | false | true
|
||||
"doubleSumObserver" | true | false
|
||||
"longSumObserver" | true | false
|
||||
"doubleUpDownCounter" | false | true
|
||||
"longUpDownCounter" | false | true
|
||||
"doubleUpDownSumObserver" | true | false
|
||||
"longUpDownSumObserver" | true | false
|
||||
"doubleValueObserver" | true | false
|
||||
"longValueObserver" | true | false
|
||||
"doubleValueRecorder" | false | false
|
||||
"longValueRecorder" | false | false
|
||||
instrumentMethod | isObserver | isCounter
|
||||
"doubleCounter" | false | true
|
||||
"longCounter" | false | true
|
||||
"doubleCounterCallback" | true | false
|
||||
"longCounterCallback" | true | false
|
||||
"doubleUpDownCounter" | false | true
|
||||
"longUpDownCounter" | false | true
|
||||
"doubleUpDownCounterCallback" | true | false
|
||||
"longUpDownCounterCallback" | true | false
|
||||
"doubleValueCallback" | true | false
|
||||
"longValueCallback" | true | false
|
||||
"doubleHistogram" | false | false
|
||||
"longHistogram" | false | false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import static io.opentelemetry.sdk.metrics.data.MetricDataType.SUMMARY
|
|||
|
||||
import io.opentelemetry.api.common.Attributes
|
||||
import io.opentelemetry.api.metrics.GlobalMeterProvider
|
||||
import io.opentelemetry.api.metrics.common.Labels
|
||||
import java.time.Clock
|
||||
import java.util.concurrent.TimeUnit
|
||||
import org.junit.Rule
|
||||
|
|
@ -48,7 +47,7 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
def now = Clock.systemUTC().instant();
|
||||
def nanos = TimeUnit.SECONDS.toNanos(now.epochSecond) + now.nano
|
||||
|
||||
def provider = GlobalMeterProvider.get().get(name.methodName, '')
|
||||
def provider = GlobalMeterProvider.get().get(name.methodName, '', null)
|
||||
def all = provider.collectAll(nanos)
|
||||
return all.sort { md1, md2 ->
|
||||
def p1 = md1.data.points[0]
|
||||
|
|
@ -67,22 +66,22 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
|
||||
def "double sum observer"() {
|
||||
when:
|
||||
def dso = otel.doubleSumObserver(
|
||||
otel.doubleCounterCallback(
|
||||
'double-sum', 'a double sum',
|
||||
'ms', {doubleResult ->
|
||||
doubleResult.observe(123.456, Labels.of('key', 'value'))
|
||||
doubleResult.observe(123.456, Attributes.builder().put('key', 'value').build())
|
||||
})
|
||||
|
||||
dso = otel.doubleSumObserver('my-double-sum', 'another double sum', 'µs', { doubleResult ->
|
||||
doubleResult.observe(234.567, Labels.of('myKey', 'myValue'))
|
||||
otel.doubleCounterCallback('my-double-sum', 'another double sum', 'µs', { doubleResult ->
|
||||
doubleResult.observe(234.567, Attributes.builder().put('myKey', 'myValue').build())
|
||||
} )
|
||||
|
||||
dso = otel.doubleSumObserver('another-double-sum', 'double sum', { doubleResult ->
|
||||
doubleResult.observe(345.678, Labels.of('anotherKey', 'anotherValue'))
|
||||
otel.doubleCounterCallback('another-double-sum', 'double sum', { doubleResult ->
|
||||
doubleResult.observe(345.678, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
})
|
||||
|
||||
dso = otel.doubleSumObserver('yet-another-double-sum', { doubleResult ->
|
||||
doubleResult.observe(456.789, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
otel.doubleCounterCallback('yet-another-double-sum', { doubleResult ->
|
||||
doubleResult.observe(456.789, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
})
|
||||
|
||||
def metrics = exportMetrics()
|
||||
|
|
@ -129,27 +128,23 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
|
||||
def "double sum observer memoization"() {
|
||||
when:
|
||||
def dcOne = otel.doubleSumObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(10.1, Labels.of('key1', 'value1'))
|
||||
otel.doubleCounterCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(10.1, Attributes.builder().put('key1', 'value1').build())
|
||||
})
|
||||
def dcTwo = otel.doubleSumObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(20.2, Labels.of('key2', 'value2'))
|
||||
otel.doubleCounterCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(20.2, Attributes.builder().put('key2', 'value2').build())
|
||||
})
|
||||
def firstMetrics = exportMetrics()
|
||||
|
||||
def dcThree = otel.doubleSumObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(30.3, Labels.of('key3', 'value3'))
|
||||
otel.doubleCounterCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(30.3, Attributes.builder().put('key3', 'value3').build())
|
||||
})
|
||||
def dcFour = otel.doubleSumObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(40.4, Labels.of('key4', 'value4'))
|
||||
otel.doubleCounterCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(40.4, Attributes.builder().put('key4', 'value4').build())
|
||||
})
|
||||
def secondMetrics = exportMetrics()
|
||||
|
||||
then:
|
||||
assert dcOne.is(dcTwo)
|
||||
assert dcTwo.is(dcThree)
|
||||
assert dcTwo.is(dcFour)
|
||||
|
||||
assert firstMetrics.size() == 1
|
||||
assert secondMetrics.size() == 1
|
||||
|
||||
|
|
@ -174,22 +169,22 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
|
||||
def "long sum observer"() {
|
||||
when:
|
||||
def dso = otel.longSumObserver(
|
||||
otel.longCounterCallback(
|
||||
'long-sum', 'a long sum',
|
||||
'ms', {longResult ->
|
||||
longResult.observe(123, Labels.of('key', 'value'))
|
||||
longResult.observe(123, Attributes.builder().put('key', 'value').build())
|
||||
})
|
||||
|
||||
dso = otel.longSumObserver('my-long-sum', 'another long sum', 'µs', { longResult ->
|
||||
longResult.observe(234, Labels.of('myKey', 'myValue'))
|
||||
otel.longCounterCallback('my-long-sum', 'another long sum', 'µs', { longResult ->
|
||||
longResult.observe(234, Attributes.builder().put('myKey', 'myValue').build())
|
||||
} )
|
||||
|
||||
dso = otel.longSumObserver('another-long-sum', 'long sum', { longResult ->
|
||||
longResult.observe(345, Labels.of('anotherKey', 'anotherValue'))
|
||||
otel.longCounterCallback('another-long-sum', 'long sum', { longResult ->
|
||||
longResult.observe(345, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
})
|
||||
|
||||
dso = otel.longSumObserver('yet-another-long-sum', { longResult ->
|
||||
longResult.observe(456, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
otel.longCounterCallback('yet-another-long-sum', { longResult ->
|
||||
longResult.observe(456, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
})
|
||||
|
||||
def metrics = exportMetrics()
|
||||
|
|
@ -236,27 +231,23 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
|
||||
def "long sum observer memoization"() {
|
||||
when:
|
||||
def dcOne = otel.longSumObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(10, Labels.of('key1', 'value1'))
|
||||
otel.longCounterCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(10, Attributes.builder().put('key1', 'value1').build())
|
||||
})
|
||||
def dcTwo = otel.longSumObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(20, Labels.of('key2', 'value2'))
|
||||
otel.longCounterCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(20, Attributes.builder().put('key2', 'value2').build())
|
||||
})
|
||||
def firstMetrics = exportMetrics()
|
||||
|
||||
def dcThree = otel.longSumObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(30, Labels.of('key3', 'value3'))
|
||||
otel.longCounterCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(30, Attributes.builder().put('key3', 'value3').build())
|
||||
})
|
||||
def dcFour = otel.longSumObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(40, Labels.of('key4', 'value4'))
|
||||
otel.longCounterCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(40, Attributes.builder().put('key4', 'value4').build())
|
||||
})
|
||||
def secondMetrics = exportMetrics()
|
||||
|
||||
then:
|
||||
assert dcOne.is(dcTwo)
|
||||
assert dcTwo.is(dcThree)
|
||||
assert dcTwo.is(dcFour)
|
||||
|
||||
assert firstMetrics.size() == 1
|
||||
assert secondMetrics.size() == 1
|
||||
|
||||
|
|
@ -281,22 +272,22 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
|
||||
def "double up down sum observer"() {
|
||||
when:
|
||||
def dso = otel.doubleUpDownSumObserver(
|
||||
otel.doubleUpDownCounterCallback(
|
||||
'double-up-down-sum', 'a double up down sum',
|
||||
'ms', {doubleResult ->
|
||||
doubleResult.observe(123.456, Labels.of('key', 'value'))
|
||||
doubleResult.observe(123.456, Attributes.builder().put('key', 'value').build())
|
||||
})
|
||||
|
||||
dso = otel.doubleUpDownSumObserver('my-double-up-down-sum', 'another double up down sum', 'µs', { doubleResult ->
|
||||
doubleResult.observe(234.567, Labels.of('myKey', 'myValue'))
|
||||
otel.doubleUpDownCounterCallback('my-double-up-down-sum', 'another double up down sum', 'µs', { doubleResult ->
|
||||
doubleResult.observe(234.567, Attributes.builder().put('myKey', 'myValue').build())
|
||||
} )
|
||||
|
||||
dso = otel.doubleUpDownSumObserver('another-double-up-down-sum', 'double up down sum', { doubleResult ->
|
||||
doubleResult.observe(345.678, Labels.of('anotherKey', 'anotherValue'))
|
||||
otel.doubleUpDownCounterCallback('another-double-up-down-sum', 'double up down sum', { doubleResult ->
|
||||
doubleResult.observe(345.678, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
})
|
||||
|
||||
dso = otel.doubleUpDownSumObserver('yet-another-double-up-down-sum', { doubleResult ->
|
||||
doubleResult.observe(456.789, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
otel.doubleUpDownCounterCallback('yet-another-double-up-down-sum', { doubleResult ->
|
||||
doubleResult.observe(456.789, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
})
|
||||
|
||||
def metrics = exportMetrics()
|
||||
|
|
@ -343,27 +334,23 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
|
||||
def "double up down sum observer memoization"() {
|
||||
when:
|
||||
def dcOne = otel.doubleUpDownSumObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(10.1, Labels.of('key1', 'value1'))
|
||||
otel.doubleUpDownCounterCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(10.1, Attributes.builder().put('key1', 'value1').build())
|
||||
})
|
||||
def dcTwo = otel.doubleUpDownSumObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(20.2, Labels.of('key2', 'value2'))
|
||||
otel.doubleUpDownCounterCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(20.2, Attributes.builder().put('key2', 'value2').build())
|
||||
})
|
||||
def firstMetrics = exportMetrics()
|
||||
|
||||
def dcThree = otel.doubleUpDownSumObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(30.3, Labels.of('key3', 'value3'))
|
||||
otel.doubleUpDownCounterCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(30.3, Attributes.builder().put('key3', 'value3').build())
|
||||
})
|
||||
def dcFour = otel.doubleUpDownSumObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(40.4, Labels.of('key4', 'value4'))
|
||||
otel.doubleUpDownCounterCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(40.4, Attributes.builder().put('key4', 'value4').build())
|
||||
})
|
||||
def secondMetrics = exportMetrics()
|
||||
|
||||
then:
|
||||
assert dcOne.is(dcTwo)
|
||||
assert dcTwo.is(dcThree)
|
||||
assert dcTwo.is(dcFour)
|
||||
|
||||
assert firstMetrics.size() == 1
|
||||
assert secondMetrics.size() == 1
|
||||
|
||||
|
|
@ -388,22 +375,22 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
|
||||
def "long up down sum observer"() {
|
||||
when:
|
||||
def dso = otel.longUpDownSumObserver(
|
||||
otel.longUpDownCounterCallback(
|
||||
'long-up-down-sum', 'a long up down sum',
|
||||
'ms', {longResult ->
|
||||
longResult.observe(123, Labels.of('key', 'value'))
|
||||
longResult.observe(123, Attributes.builder().put('key', 'value').build())
|
||||
})
|
||||
|
||||
dso = otel.longUpDownSumObserver('my-long-up-down-sum', 'another long up down sum', 'µs', { longResult ->
|
||||
longResult.observe(234, Labels.of('myKey', 'myValue'))
|
||||
otel.longUpDownCounterCallback('my-long-up-down-sum', 'another long up down sum', 'µs', { longResult ->
|
||||
longResult.observe(234, Attributes.builder().put('myKey', 'myValue').build())
|
||||
} )
|
||||
|
||||
dso = otel.longUpDownSumObserver('another-long-up-down-sum', 'long up down sum', { longResult ->
|
||||
longResult.observe(345, Labels.of('anotherKey', 'anotherValue'))
|
||||
otel.longUpDownCounterCallback('another-long-up-down-sum', 'long up down sum', { longResult ->
|
||||
longResult.observe(345, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
})
|
||||
|
||||
dso = otel.longUpDownSumObserver('yet-another-long-up-down-sum', { longResult ->
|
||||
longResult.observe(456, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
otel.longUpDownCounterCallback('yet-another-long-up-down-sum', { longResult ->
|
||||
longResult.observe(456, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
})
|
||||
|
||||
def metrics = exportMetrics()
|
||||
|
|
@ -450,27 +437,23 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
|
||||
def "long up down sum observer memoization"() {
|
||||
when:
|
||||
def dcOne = otel.longUpDownSumObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(10, Labels.of('key1', 'value1'))
|
||||
otel.longUpDownCounterCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(10, Attributes.builder().put('key1', 'value1').build())
|
||||
})
|
||||
def dcTwo = otel.longUpDownSumObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(20, Labels.of('key2', 'value2'))
|
||||
otel.longUpDownCounterCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(20, Attributes.builder().put('key2', 'value2').build())
|
||||
})
|
||||
def firstMetrics = exportMetrics()
|
||||
|
||||
def dcThree = otel.longUpDownSumObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(30, Labels.of('key3', 'value3'))
|
||||
otel.longUpDownCounterCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(30, Attributes.builder().put('key3', 'value3').build())
|
||||
})
|
||||
def dcFour = otel.longUpDownSumObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(40, Labels.of('key4', 'value4'))
|
||||
otel.longUpDownCounterCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(40, Attributes.builder().put('key4', 'value4').build())
|
||||
})
|
||||
def secondMetrics = exportMetrics()
|
||||
|
||||
then:
|
||||
assert dcOne.is(dcTwo)
|
||||
assert dcTwo.is(dcThree)
|
||||
assert dcTwo.is(dcFour)
|
||||
|
||||
assert firstMetrics.size() == 1
|
||||
assert secondMetrics.size() == 1
|
||||
|
||||
|
|
@ -495,22 +478,22 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
|
||||
def "double value observer"() {
|
||||
when:
|
||||
def dso = otel.doubleValueObserver(
|
||||
otel.doubleValueCallback(
|
||||
'double-value', 'a double value',
|
||||
'ms', {doubleResult ->
|
||||
doubleResult.observe(123.456, Labels.of('key', 'value'))
|
||||
doubleResult.observe(123.456, Attributes.builder().put('key', 'value').build())
|
||||
})
|
||||
|
||||
dso = otel.doubleValueObserver('my-double-value', 'another double value', 'µs', { doubleResult ->
|
||||
doubleResult.observe(234.567, Labels.of('myKey', 'myValue'))
|
||||
otel.doubleValueCallback('my-double-value', 'another double value', 'µs', { doubleResult ->
|
||||
doubleResult.observe(234.567, Attributes.builder().put('myKey', 'myValue').build())
|
||||
} )
|
||||
|
||||
dso = otel.doubleValueObserver('another-double-value', 'double value', { doubleResult ->
|
||||
doubleResult.observe(345.678, Labels.of('anotherKey', 'anotherValue'))
|
||||
otel.doubleValueCallback('another-double-value', 'double value', { doubleResult ->
|
||||
doubleResult.observe(345.678, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
})
|
||||
|
||||
dso = otel.doubleValueObserver('yet-another-double-value', { doubleResult ->
|
||||
doubleResult.observe(456.789, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
otel.doubleValueCallback('yet-another-double-value', { doubleResult ->
|
||||
doubleResult.observe(456.789, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
})
|
||||
|
||||
def metrics = exportMetrics()
|
||||
|
|
@ -556,28 +539,24 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
|
||||
def "double value observer memoization"() {
|
||||
when:
|
||||
def dcOne = otel.doubleValueObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(10.1, Labels.of('key1', 'value1'))
|
||||
otel.doubleValueCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(10.1, Attributes.builder().put('key1', 'value1').build())
|
||||
})
|
||||
def dcTwo = otel.doubleValueObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(20.2, Labels.of('key2', 'value2'))
|
||||
otel.doubleValueCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(20.2, Attributes.builder().put('key2', 'value2').build())
|
||||
})
|
||||
def firstMetrics = exportMetrics()
|
||||
|
||||
def dcThree = otel.doubleValueObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(30.3, Labels.of('key3', 'value3'))
|
||||
otel.doubleValueCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(30.3, Attributes.builder().put('key3', 'value3').build())
|
||||
})
|
||||
def dcFour = otel.doubleValueObserver('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(40.4, Labels.of('key4', 'value4'))
|
||||
doubleResult.observe(50.5, Labels.of('key2', 'value2'))
|
||||
otel.doubleValueCallback('dc', 'double', { doubleResult ->
|
||||
doubleResult.observe(40.4, Attributes.builder().put('key4', 'value4').build())
|
||||
doubleResult.observe(50.5, Attributes.builder().put('key2', 'value2').build())
|
||||
})
|
||||
def secondMetrics = exportMetrics()
|
||||
|
||||
then:
|
||||
assert dcOne.is(dcTwo)
|
||||
assert dcTwo.is(dcThree)
|
||||
assert dcTwo.is(dcFour)
|
||||
|
||||
assert firstMetrics.size() == 1
|
||||
assert secondMetrics.size() == 1
|
||||
|
||||
|
|
@ -596,30 +575,32 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
assert secondMetric.unit == '1'
|
||||
assert secondMetric.type == DOUBLE_GAUGE
|
||||
assert secondMetric.data.points.size() == 2
|
||||
assert secondMetric.data.points[1].value == 40.4
|
||||
assert secondMetric.data.points[1].attributes == Attributes.of(stringKey('key4'), 'value4')
|
||||
assert secondMetric.data.points[0].value == 50.5
|
||||
assert secondMetric.data.points[0].attributes == Attributes.of(stringKey('key2'), 'value2')
|
||||
// Same epochNanos, order not defined
|
||||
secondMetric.data.points.sort { a, b -> Double.compare(a.value, b.value) }
|
||||
assert secondMetric.data.points[0].value == 40.4
|
||||
assert secondMetric.data.points[0].attributes == Attributes.of(stringKey('key4'), 'value4')
|
||||
assert secondMetric.data.points[1].value == 50.5
|
||||
assert secondMetric.data.points[1].attributes == Attributes.of(stringKey('key2'), 'value2')
|
||||
}
|
||||
|
||||
def "long value observer"() {
|
||||
when:
|
||||
def dso = otel.longValueObserver(
|
||||
otel.longValueCallback(
|
||||
'long-value', 'a long value',
|
||||
'ms', {longResult ->
|
||||
longResult.observe(123, Labels.of('key', 'value'))
|
||||
longResult.observe(123, Attributes.builder().put('key', 'value').build())
|
||||
})
|
||||
|
||||
dso = otel.longValueObserver('my-long-value', 'another long value', 'µs', { longResult ->
|
||||
longResult.observe(234, Labels.of('myKey', 'myValue'))
|
||||
otel.longValueCallback('my-long-value', 'another long value', 'µs', { longResult ->
|
||||
longResult.observe(234, Attributes.builder().put('myKey', 'myValue').build())
|
||||
} )
|
||||
|
||||
dso = otel.longValueObserver('another-long-value', 'long value', { longResult ->
|
||||
longResult.observe(345, Labels.of('anotherKey', 'anotherValue'))
|
||||
otel.longValueCallback('another-long-value', 'long value', { longResult ->
|
||||
longResult.observe(345, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
})
|
||||
|
||||
dso = otel.longValueObserver('yet-another-long-value', { longResult ->
|
||||
longResult.observe(456, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
otel.longValueCallback('yet-another-long-value', { longResult ->
|
||||
longResult.observe(456, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
})
|
||||
|
||||
def metrics = exportMetrics()
|
||||
|
|
@ -666,28 +647,24 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
|
||||
def "long value observer memoization"() {
|
||||
when:
|
||||
def dcOne = otel.longValueObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(10, Labels.of('key1', 'value1'))
|
||||
otel.longValueCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(10, Attributes.builder().put('key1', 'value1').build())
|
||||
})
|
||||
def dcTwo = otel.longValueObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(20, Labels.of('key2', 'value2'))
|
||||
otel.longValueCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(20, Attributes.builder().put('key2', 'value2').build())
|
||||
})
|
||||
def firstMetrics = exportMetrics()
|
||||
|
||||
def dcThree = otel.longValueObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(30, Labels.of('key3', 'value3'))
|
||||
otel.longValueCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(30, Attributes.builder().put('key3', 'value3').build())
|
||||
})
|
||||
def dcFour = otel.longValueObserver('dc', 'long', { longResult ->
|
||||
longResult.observe(40, Labels.of('key4', 'value4'))
|
||||
longResult.observe(50, Labels.of('key2', 'value2'))
|
||||
otel.longValueCallback('dc', 'long', { longResult ->
|
||||
longResult.observe(40, Attributes.builder().put('key4', 'value4').build())
|
||||
longResult.observe(50, Attributes.builder().put('key2', 'value2').build())
|
||||
})
|
||||
def secondMetrics = exportMetrics()
|
||||
|
||||
then:
|
||||
assert dcOne.is(dcTwo)
|
||||
assert dcTwo.is(dcThree)
|
||||
assert dcTwo.is(dcFour)
|
||||
|
||||
assert firstMetrics.size() == 1
|
||||
assert secondMetrics.size() == 1
|
||||
|
||||
|
|
@ -706,6 +683,8 @@ class OtelHelperAsynchronousMetricTest extends Specification{
|
|||
assert secondMetric.unit == '1'
|
||||
assert secondMetric.type == LONG_GAUGE
|
||||
assert secondMetric.data.points.size() == 2
|
||||
// Same epochNanos, order not defined
|
||||
secondMetric.data.points.sort { a, b -> Long.compare(a.value, b.value) }
|
||||
assert secondMetric.data.points[0].value == 40
|
||||
assert secondMetric.data.points[0].attributes == Attributes.of(stringKey('key4'), 'value4')
|
||||
assert secondMetric.data.points[1].value == 50
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import static io.opentelemetry.sdk.metrics.data.MetricDataType.SUMMARY
|
|||
|
||||
import io.opentelemetry.api.common.Attributes
|
||||
import io.opentelemetry.api.metrics.GlobalMeterProvider
|
||||
import io.opentelemetry.api.metrics.common.Labels
|
||||
import org.junit.Rule
|
||||
import org.junit.rules.TestName
|
||||
import org.junit.rules.TestRule
|
||||
|
|
@ -40,7 +39,7 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
}
|
||||
|
||||
def exportMetrics() {
|
||||
def provider = GlobalMeterProvider.get().get(name.methodName, '')
|
||||
def provider = GlobalMeterProvider.get().get(name.methodName, '', null)
|
||||
return provider.collectAll(0).sort { md1, md2 ->
|
||||
def p1 = md1.data.points[0]
|
||||
def p2 = md2.data.points[0]
|
||||
|
|
@ -61,16 +60,16 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
def dc = otel.doubleCounter(
|
||||
'double-counter', 'a double counter',
|
||||
'ms')
|
||||
dc.add(123.456, Labels.of('key', 'value'))
|
||||
dc.add(123.456, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
dc = otel.doubleCounter('my-double-counter', 'another double counter', 'µs')
|
||||
dc.add(234.567, Labels.of('myKey', 'myValue'))
|
||||
dc.add(234.567, Attributes.builder().put('myKey', 'myValue').build())
|
||||
|
||||
dc = otel.doubleCounter('another-double-counter', 'double counter')
|
||||
dc.add(345.678, Labels.of('anotherKey', 'anotherValue'))
|
||||
dc.add(345.678, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
|
||||
dc = otel.doubleCounter('yet-another-double-counter')
|
||||
dc.add(456.789, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
dc.add(456.789, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
|
||||
def metrics = exportMetrics()
|
||||
then:
|
||||
|
|
@ -117,12 +116,12 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
def "double counter memoization"() {
|
||||
when:
|
||||
def dcOne = otel.doubleCounter('dc', 'double')
|
||||
dcOne.add(10.1, Labels.of('key', 'value'))
|
||||
dcOne.add(10.1, Attributes.builder().put('key', 'value').build())
|
||||
def dcTwo = otel.doubleCounter('dc', 'double')
|
||||
dcTwo.add(10.1, Labels.of('key', 'value'))
|
||||
dcTwo.add(10.1, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
then:
|
||||
assert dcOne.is(dcTwo)
|
||||
assert dcOne == dcTwo
|
||||
|
||||
def metrics = exportMetrics()
|
||||
assert metrics.size() == 1
|
||||
|
|
@ -142,16 +141,16 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
def lc = otel.longCounter(
|
||||
'long-counter', 'a long counter',
|
||||
'ms')
|
||||
lc.add(123, Labels.of('key', 'value'))
|
||||
lc.add(123, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
lc = otel.longCounter('my-long-counter', 'another long counter', 'µs')
|
||||
lc.add(234, Labels.of('myKey', 'myValue'))
|
||||
lc.add(234, Attributes.builder().put('myKey', 'myValue').build())
|
||||
|
||||
lc = otel.longCounter('another-long-counter', 'long counter')
|
||||
lc.add(345, Labels.of('anotherKey', 'anotherValue'))
|
||||
lc.add(345, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
|
||||
lc = otel.longCounter('yet-another-long-counter')
|
||||
lc.add(456, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
lc.add(456, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
|
||||
def metrics = exportMetrics()
|
||||
then:
|
||||
|
|
@ -198,12 +197,12 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
def "long counter memoization"() {
|
||||
when:
|
||||
def lcOne = otel.longCounter('lc', 'long')
|
||||
lcOne.add(10, Labels.of('key', 'value'))
|
||||
lcOne.add(10, Attributes.builder().put('key', 'value').build())
|
||||
def lcTwo = otel.longCounter('lc', 'long')
|
||||
lcTwo.add(10, Labels.of('key', 'value'))
|
||||
lcTwo.add(10, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
then:
|
||||
assert lcOne.is(lcTwo)
|
||||
assert lcOne == lcTwo
|
||||
|
||||
def metrics = exportMetrics()
|
||||
assert metrics.size() == 1
|
||||
|
|
@ -223,16 +222,16 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
def dudc = otel.doubleUpDownCounter(
|
||||
'double-up-down-counter', 'a double up-down-counter',
|
||||
'ms')
|
||||
dudc.add(-234.567, Labels.of('key', 'value'))
|
||||
dudc.add(-234.567, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
dudc = otel.doubleUpDownCounter('my-double-up-down-counter', 'another double up-down-counter', 'µs')
|
||||
dudc.add(-123.456, Labels.of('myKey', 'myValue'))
|
||||
dudc.add(-123.456, Attributes.builder().put('myKey', 'myValue').build())
|
||||
|
||||
dudc = otel.doubleUpDownCounter('another-double-up-down-counter', 'double up-down-counter')
|
||||
dudc.add(345.678, Labels.of('anotherKey', 'anotherValue'))
|
||||
dudc.add(345.678, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
|
||||
dudc = otel.doubleUpDownCounter('yet-another-double-up-down-counter')
|
||||
dudc.add(456.789, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
dudc.add(456.789, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
|
||||
def metrics = exportMetrics()
|
||||
then:
|
||||
|
|
@ -279,12 +278,12 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
def "double up down counter memoization"() {
|
||||
when:
|
||||
def dudcOne = otel.doubleUpDownCounter('dudc', 'double up down')
|
||||
dudcOne.add(10.1, Labels.of('key', 'value'))
|
||||
dudcOne.add(10.1, Attributes.builder().put('key', 'value').build())
|
||||
def dudcTwo = otel.doubleUpDownCounter('dudc', 'double up down')
|
||||
dudcTwo.add(-10.1, Labels.of('key', 'value'))
|
||||
dudcTwo.add(-10.1, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
then:
|
||||
assert dudcOne.is(dudcTwo)
|
||||
assert dudcOne == dudcTwo
|
||||
|
||||
def metrics = exportMetrics()
|
||||
assert metrics.size() == 1
|
||||
|
|
@ -304,16 +303,16 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
def ludc = otel.longUpDownCounter(
|
||||
'long-up-down-counter', 'a long up-down-counter',
|
||||
'ms')
|
||||
ludc.add(-234, Labels.of('key', 'value'))
|
||||
ludc.add(-234, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
ludc = otel.longUpDownCounter('my-long-up-down-counter', 'another long up-down-counter', 'µs')
|
||||
ludc.add(-123, Labels.of('myKey', 'myValue'))
|
||||
ludc.add(-123, Attributes.builder().put('myKey', 'myValue').build())
|
||||
|
||||
ludc = otel.longUpDownCounter('another-long-up-down-counter', 'long up-down-counter')
|
||||
ludc.add(345, Labels.of('anotherKey', 'anotherValue'))
|
||||
ludc.add(345, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
|
||||
ludc = otel.longUpDownCounter('yet-another-long-up-down-counter')
|
||||
ludc.add(456, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
ludc.add(456, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
|
||||
def metrics = exportMetrics()
|
||||
then:
|
||||
|
|
@ -360,12 +359,12 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
def "long up down counter memoization"() {
|
||||
when:
|
||||
def ludcOne = otel.longUpDownCounter('ludc', 'long up down')
|
||||
ludcOne.add(10, Labels.of('key', 'value'))
|
||||
ludcOne.add(10, Attributes.builder().put('key', 'value').build())
|
||||
def ludcTwo = otel.longUpDownCounter('ludc', 'long up down')
|
||||
ludcTwo.add(-10, Labels.of('key', 'value'))
|
||||
ludcTwo.add(-10, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
then:
|
||||
assert ludcOne.is(ludcTwo)
|
||||
assert ludcOne == ludcTwo
|
||||
|
||||
def metrics = exportMetrics()
|
||||
assert metrics.size() == 1
|
||||
|
|
@ -382,19 +381,19 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
|
||||
def "double value recorder"() {
|
||||
when:
|
||||
def dvr = otel.doubleValueRecorder(
|
||||
def dvr = otel.doubleHistogram(
|
||||
'double-value-recorder', 'a double value-recorder',
|
||||
'ms')
|
||||
dvr.record(-234.567, Labels.of('key', 'value'))
|
||||
dvr.record(-234.567, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
dvr = otel.doubleValueRecorder('my-double-value-recorder', 'another double value-recorder', 'µs')
|
||||
dvr.record(-123.456, Labels.of('myKey', 'myValue'))
|
||||
dvr = otel.doubleHistogram('my-double-value-recorder', 'another double value-recorder', 'µs')
|
||||
dvr.record(-123.456, Attributes.builder().put('myKey', 'myValue').build())
|
||||
|
||||
dvr = otel.doubleValueRecorder('another-double-value-recorder', 'double value-recorder')
|
||||
dvr.record(345.678, Labels.of('anotherKey', 'anotherValue'))
|
||||
dvr = otel.doubleHistogram('another-double-value-recorder', 'double value-recorder')
|
||||
dvr.record(345.678, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
|
||||
dvr = otel.doubleValueRecorder('yet-another-double-value-recorder')
|
||||
dvr.record(456.789, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
dvr = otel.doubleHistogram('yet-another-double-value-recorder')
|
||||
dvr.record(456.789, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
|
||||
def metrics = exportMetrics()
|
||||
then:
|
||||
|
|
@ -460,13 +459,13 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
|
||||
def "double value recorder memoization"() {
|
||||
when:
|
||||
def dvrOne = otel.doubleValueRecorder('dvr', 'double value')
|
||||
dvrOne.record(10.1, Labels.of('key', 'value'))
|
||||
def dvrTwo = otel.doubleValueRecorder('dvr', 'double value')
|
||||
dvrTwo.record(-10.1, Labels.of('key', 'value'))
|
||||
def dvrOne = otel.doubleHistogram('dvr', 'double value')
|
||||
dvrOne.record(10.1, Attributes.builder().put('key', 'value').build())
|
||||
def dvrTwo = otel.doubleHistogram('dvr', 'double value')
|
||||
dvrTwo.record(-10.1, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
then:
|
||||
assert dvrOne.is(dvrTwo)
|
||||
assert dvrOne == dvrTwo
|
||||
|
||||
def metrics = exportMetrics()
|
||||
assert metrics.size() == 1
|
||||
|
|
@ -488,19 +487,19 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
|
||||
def "long value recorder"() {
|
||||
when:
|
||||
def lvr = otel.longValueRecorder(
|
||||
def lvr = otel.longHistogram(
|
||||
'long-value-recorder', 'a long value-recorder',
|
||||
'ms')
|
||||
lvr.record(-234, Labels.of('key', 'value'))
|
||||
lvr.record(-234, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
lvr = otel.longValueRecorder('my-long-value-recorder', 'another long value-recorder', 'µs')
|
||||
lvr.record(-123, Labels.of('myKey', 'myValue'))
|
||||
lvr = otel.longHistogram('my-long-value-recorder', 'another long value-recorder', 'µs')
|
||||
lvr.record(-123, Attributes.builder().put('myKey', 'myValue').build())
|
||||
|
||||
lvr = otel.longValueRecorder('another-long-value-recorder', 'long value-recorder')
|
||||
lvr.record(345, Labels.of('anotherKey', 'anotherValue'))
|
||||
lvr = otel.longHistogram('another-long-value-recorder', 'long value-recorder')
|
||||
lvr.record(345, Attributes.builder().put('anotherKey', 'anotherValue').build())
|
||||
|
||||
lvr = otel.longValueRecorder('yet-another-long-value-recorder')
|
||||
lvr.record(456, Labels.of('yetAnotherKey', 'yetAnotherValue'))
|
||||
lvr = otel.longHistogram('yet-another-long-value-recorder')
|
||||
lvr.record(456, Attributes.builder().put('yetAnotherKey', 'yetAnotherValue').build())
|
||||
|
||||
def metrics = exportMetrics()
|
||||
then:
|
||||
|
|
@ -566,13 +565,13 @@ class OtelHelperSynchronousMetricTest extends Specification{
|
|||
|
||||
def "long value recorder memoization"() {
|
||||
when:
|
||||
def lvrOne = otel.longValueRecorder('lvr', 'long value')
|
||||
lvrOne.record(10, Labels.of('key', 'value'))
|
||||
def lvrTwo = otel.longValueRecorder('lvr', 'long value')
|
||||
lvrTwo.record(-10, Labels.of('key', 'value'))
|
||||
def lvrOne = otel.longHistogram('lvr', 'long value')
|
||||
lvrOne.record(10, Attributes.builder().put('key', 'value').build())
|
||||
def lvrTwo = otel.longHistogram('lvr', 'long value')
|
||||
lvrTwo.record(-10, Attributes.builder().put('key', 'value').build())
|
||||
|
||||
then:
|
||||
assert lvrOne.is(lvrTwo)
|
||||
assert lvrOne == lvrTwo
|
||||
|
||||
def metrics = exportMetrics()
|
||||
assert metrics.size() == 1
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import io.opentelemetry.api.metrics.common.Labels
|
||||
import io.opentelemetry.api.common.Attributes
|
||||
|
||||
def loadMatches = otel.queryJmx("org.apache.cassandra.metrics:type=Storage,name=Load")
|
||||
def load = loadMatches.first()
|
||||
|
||||
def lvr = otel.longValueRecorder(
|
||||
def lvr = otel.longHistogram(
|
||||
"cassandra.storage.load",
|
||||
"Size, in bytes, of the on disk data size this node manages",
|
||||
"By"
|
||||
)
|
||||
lvr.record(load.Count, Labels.of("myKey", "myVal"))
|
||||
lvr.record(load.Count, Attributes.builder().put("myKey", "myVal").build())
|
||||
|
|
|
|||
Loading…
Reference in New Issue