Remove constant labels from instruments and MetricData (#1692)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
This commit is contained in:
parent
0b8a2dadbd
commit
2d146bbbb9
|
|
@ -652,12 +652,6 @@ public final class DefaultMeter implements Meter {
|
|||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public B setConstantLabels(Labels constantLabels) {
|
||||
Utils.checkNotNull(constantLabels, "constantLabels");
|
||||
return getThis();
|
||||
}
|
||||
|
||||
protected abstract B getThis();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,9 +106,6 @@ public interface DoubleCounter extends SynchronousInstrument<BoundDoubleCounter>
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
DoubleCounter build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package io.opentelemetry.metrics;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.metrics.AsynchronousInstrument.DoubleResult;
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
|
|
@ -73,9 +72,6 @@ public interface DoubleSumObserver extends AsynchronousInstrument<DoubleResult>
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
DoubleSumObserver build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,9 +109,6 @@ public interface DoubleUpDownCounter extends SynchronousInstrument<BoundDoubleUp
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
DoubleUpDownCounter build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package io.opentelemetry.metrics;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.metrics.AsynchronousInstrument.DoubleResult;
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
|
|
@ -73,9 +72,6 @@ public interface DoubleUpDownSumObserver extends AsynchronousInstrument<DoubleRe
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
DoubleUpDownSumObserver build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package io.opentelemetry.metrics;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.metrics.AsynchronousInstrument.DoubleResult;
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
|
|
@ -69,9 +68,6 @@ public interface DoubleValueObserver extends AsynchronousInstrument<DoubleResult
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
DoubleValueObserver build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,9 +116,6 @@ public interface DoubleValueRecorder extends SynchronousInstrument<BoundDoubleVa
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
DoubleValueRecorder build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package io.opentelemetry.metrics;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import java.util.Collections;
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
/**
|
||||
|
|
@ -50,17 +48,6 @@ public interface Instrument {
|
|||
*/
|
||||
Builder setUnit(String unit);
|
||||
|
||||
/**
|
||||
* Sets the map of constant labels (they will be added to all the Bound Instruments) for the
|
||||
* Instrument.
|
||||
*
|
||||
* <p>Default value is {@link Collections#emptyMap()}.
|
||||
*
|
||||
* @param constantLabels the map of constant labels for the Instrument.
|
||||
* @return this.
|
||||
*/
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
/**
|
||||
* Builds and returns a {@code Instrument} with the desired options.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -107,9 +107,6 @@ public interface LongCounter extends SynchronousInstrument<BoundLongCounter> {
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
LongCounter build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package io.opentelemetry.metrics;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.metrics.AsynchronousInstrument.LongResult;
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
|
|
@ -73,9 +72,6 @@ public interface LongSumObserver extends AsynchronousInstrument<LongResult> {
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
LongSumObserver build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,9 +110,6 @@ public interface LongUpDownCounter extends SynchronousInstrument<BoundLongUpDown
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
LongUpDownCounter build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package io.opentelemetry.metrics;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.metrics.AsynchronousInstrument.LongResult;
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
|
|
@ -73,9 +72,6 @@ public interface LongUpDownSumObserver extends AsynchronousInstrument<LongResult
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
LongUpDownSumObserver build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package io.opentelemetry.metrics;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.metrics.AsynchronousInstrument.LongResult;
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
|
|
@ -69,9 +68,6 @@ public interface LongValueObserver extends AsynchronousInstrument<LongResult> {
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
LongValueObserver build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,9 +116,6 @@ public interface LongValueRecorder extends SynchronousInstrument<BoundLongValueR
|
|||
@Override
|
||||
Builder setUnit(String unit);
|
||||
|
||||
@Override
|
||||
Builder setConstantLabels(Labels constantLabels);
|
||||
|
||||
@Override
|
||||
LongValueRecorder build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ class DoubleCounterTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("DoubleCounterTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("DoubleCounterTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -82,14 +80,6 @@ class DoubleCounterTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.doubleCounterBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void add_preventNullLabels() {
|
||||
assertThrows(
|
||||
|
|
@ -127,12 +117,7 @@ class DoubleCounterTest {
|
|||
@Test
|
||||
void bound_DoesNotThrow() {
|
||||
DoubleCounter doubleCounter =
|
||||
meter
|
||||
.doubleCounterBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.doubleCounterBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
BoundDoubleCounter bound = doubleCounter.bind(Labels.empty());
|
||||
bound.add(1.0);
|
||||
bound.unbind();
|
||||
|
|
@ -141,12 +126,7 @@ class DoubleCounterTest {
|
|||
@Test
|
||||
void bound_PreventNegativeValue() {
|
||||
DoubleCounter doubleCounter =
|
||||
meter
|
||||
.doubleCounterBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.doubleCounterBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
BoundDoubleCounter bound = doubleCounter.bind(Labels.empty());
|
||||
try {
|
||||
assertThrows(
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package io.opentelemetry.metrics;
|
|||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.internal.StringUtils;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -28,9 +27,7 @@ class DoubleSumObserverTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("DoubleSumObserverTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("DoubleSumObserverTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -78,14 +75,6 @@ class DoubleSumObserverTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.doubleSumObserverBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_Callback() {
|
||||
DoubleSumObserver doubleSumObserver = meter.doubleSumObserverBuilder("metric").build();
|
||||
|
|
@ -95,12 +84,7 @@ class DoubleSumObserverTest {
|
|||
@Test
|
||||
void doesNotThrow() {
|
||||
DoubleSumObserver doubleSumObserver =
|
||||
meter
|
||||
.doubleSumObserverBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.doubleSumObserverBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
doubleSumObserver.setCallback(result -> {});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ class DoubleUpDownCounterTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("DoubleUpDownCounterTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("DoubleUpDownCounterTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -82,14 +80,6 @@ class DoubleUpDownCounterTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.doubleUpDownCounterBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void add_preventNullLabels() {
|
||||
assertThrows(
|
||||
|
|
@ -101,12 +91,7 @@ class DoubleUpDownCounterTest {
|
|||
@Test
|
||||
void add_DoesNotThrow() {
|
||||
DoubleUpDownCounter doubleUpDownCounter =
|
||||
meter
|
||||
.doubleUpDownCounterBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.doubleUpDownCounterBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
doubleUpDownCounter.add(1.0, Labels.empty());
|
||||
doubleUpDownCounter.add(-1.0, Labels.empty());
|
||||
doubleUpDownCounter.add(1.0);
|
||||
|
|
@ -124,12 +109,7 @@ class DoubleUpDownCounterTest {
|
|||
@Test
|
||||
void bound_DoesNotThrow() {
|
||||
DoubleUpDownCounter doubleUpDownCounter =
|
||||
meter
|
||||
.doubleUpDownCounterBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.doubleUpDownCounterBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
BoundDoubleUpDownCounter bound = doubleUpDownCounter.bind(Labels.empty());
|
||||
bound.add(1.0);
|
||||
bound.add(-1.0);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package io.opentelemetry.metrics;
|
|||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.internal.StringUtils;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -29,9 +28,7 @@ class DoubleUpDownSumObserverTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("DoubleUpDownSumObserverTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("DoubleUpDownSumObserverTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -80,14 +77,6 @@ class DoubleUpDownSumObserverTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.doubleUpDownSumObserverBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_Callback() {
|
||||
DoubleUpDownSumObserver doubleUpDownSumObserver =
|
||||
|
|
@ -103,7 +92,6 @@ class DoubleUpDownSumObserverTest {
|
|||
.doubleUpDownSumObserverBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
doubleUpDownSumObserver.setCallback(result -> {});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package io.opentelemetry.metrics;
|
|||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.internal.StringUtils;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -29,9 +28,7 @@ class DoubleValueObserverTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("DoubleSumObserverTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("DoubleSumObserverTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -79,14 +76,6 @@ class DoubleValueObserverTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.doubleValueObserverBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_Callback() {
|
||||
DoubleValueObserver doubleValueObserver = meter.doubleValueObserverBuilder("metric").build();
|
||||
|
|
@ -97,12 +86,7 @@ class DoubleValueObserverTest {
|
|||
@Test
|
||||
void doesNotThrow() {
|
||||
DoubleValueObserver doubleValueObserver =
|
||||
meter
|
||||
.doubleValueObserverBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.doubleValueObserverBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
doubleValueObserver.setCallback(result -> {});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ class DoubleValueRecorderTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("DoubleValueRecorderTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("DoubleValueRecorderTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -81,14 +79,6 @@ class DoubleValueRecorderTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.doubleValueRecorderBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void record_PreventNullLabels() {
|
||||
assertThrows(
|
||||
|
|
@ -100,12 +90,7 @@ class DoubleValueRecorderTest {
|
|||
@Test
|
||||
void record_DoesNotThrow() {
|
||||
DoubleValueRecorder doubleValueRecorder =
|
||||
meter
|
||||
.doubleValueRecorderBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.doubleValueRecorderBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
doubleValueRecorder.record(5.0, Labels.empty());
|
||||
doubleValueRecorder.record(-5.0, Labels.empty());
|
||||
doubleValueRecorder.record(5.0);
|
||||
|
|
@ -123,12 +108,7 @@ class DoubleValueRecorderTest {
|
|||
@Test
|
||||
void bound_DoesNotThrow() {
|
||||
DoubleValueRecorder doubleValueRecorder =
|
||||
meter
|
||||
.doubleValueRecorderBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.doubleValueRecorderBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
BoundDoubleValueRecorder bound = doubleValueRecorder.bind(Labels.empty());
|
||||
bound.record(5.0);
|
||||
bound.record(-5.0);
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ class LongCounterTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("LongCounterTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("LongCounterTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -82,14 +80,6 @@ class LongCounterTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.longCounterBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void add_PreventNullLabels() {
|
||||
assertThrows(
|
||||
|
|
@ -127,12 +117,7 @@ class LongCounterTest {
|
|||
@Test
|
||||
void bound_DoesNotThrow() {
|
||||
LongCounter longCounter =
|
||||
meter
|
||||
.longCounterBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.longCounterBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
BoundLongCounter bound = longCounter.bind(Labels.empty());
|
||||
bound.add(1);
|
||||
bound.unbind();
|
||||
|
|
@ -141,12 +126,7 @@ class LongCounterTest {
|
|||
@Test
|
||||
void bound_PreventNegativeValue() {
|
||||
LongCounter longCounter =
|
||||
meter
|
||||
.longCounterBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.longCounterBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
BoundLongCounter bound = longCounter.bind(Labels.empty());
|
||||
try {
|
||||
assertThrows(
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package io.opentelemetry.metrics;
|
|||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.internal.StringUtils;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -29,9 +28,7 @@ class LongSumObserverTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("LongSumObserverTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("LongSumObserverTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -81,14 +78,6 @@ class LongSumObserverTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.longSumObserverBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_Callback() {
|
||||
LongSumObserver longSumObserver = meter.longSumObserverBuilder("metric").build();
|
||||
|
|
@ -98,12 +87,7 @@ class LongSumObserverTest {
|
|||
@Test
|
||||
void doesNotThrow() {
|
||||
LongSumObserver longSumObserver =
|
||||
meter
|
||||
.longSumObserverBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.longSumObserverBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
longSumObserver.setCallback(result -> {});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ class LongUpDownCounterTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("LongUpDownCounterTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("LongUpDownCounterTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -82,14 +80,6 @@ class LongUpDownCounterTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.longUpDownCounterBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void add_PreventNullLabels() {
|
||||
assertThrows(
|
||||
|
|
@ -101,12 +91,7 @@ class LongUpDownCounterTest {
|
|||
@Test
|
||||
void add_DoesNotThrow() {
|
||||
LongUpDownCounter longUpDownCounter =
|
||||
meter
|
||||
.longUpDownCounterBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.longUpDownCounterBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
longUpDownCounter.add(1, Labels.empty());
|
||||
longUpDownCounter.add(-1, Labels.empty());
|
||||
longUpDownCounter.add(1);
|
||||
|
|
@ -124,12 +109,7 @@ class LongUpDownCounterTest {
|
|||
@Test
|
||||
void bound_DoesNotThrow() {
|
||||
LongUpDownCounter longUpDownCounter =
|
||||
meter
|
||||
.longUpDownCounterBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.longUpDownCounterBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
BoundLongUpDownCounter bound = longUpDownCounter.bind(Labels.empty());
|
||||
bound.add(1);
|
||||
bound.add(-1);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package io.opentelemetry.metrics;
|
|||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.internal.StringUtils;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -29,9 +28,7 @@ class LongUpDownSumObserverTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("LongUpDownSumObserverTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("LongUpDownSumObserverTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -82,14 +79,6 @@ class LongUpDownSumObserverTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.longUpDownSumObserverBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_Callback() {
|
||||
LongUpDownSumObserver longUpDownSumObserver =
|
||||
|
|
@ -101,12 +90,7 @@ class LongUpDownSumObserverTest {
|
|||
@Test
|
||||
void doesNotThrow() {
|
||||
LongUpDownSumObserver longUpDownSumObserver =
|
||||
meter
|
||||
.longUpDownSumObserverBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.longUpDownSumObserverBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
longUpDownSumObserver.setCallback(result -> {});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import static java.util.Arrays.fill;
|
|||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.common.Labels;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link LongValueObserver}. */
|
||||
|
|
@ -31,9 +30,7 @@ class LongValueObserverTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("LongValueObserverTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("LongValueObserverTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -83,14 +80,6 @@ class LongValueObserverTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.longValueObserverBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_Callback() {
|
||||
LongValueObserver longValueObserver = meter.longValueObserverBuilder("metric").build();
|
||||
|
|
@ -100,12 +89,7 @@ class LongValueObserverTest {
|
|||
@Test
|
||||
void doesNotThrow() {
|
||||
LongValueObserver longValueObserver =
|
||||
meter
|
||||
.longValueObserverBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.longValueObserverBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
longValueObserver.setCallback(result -> {});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ public final class LongValueRecorderTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key", "value");
|
||||
|
||||
private final Meter meter = OpenTelemetry.getMeter("LongValueRecorderTest");
|
||||
private static final Meter meter = OpenTelemetry.getMeter("LongValueRecorderTest");
|
||||
|
||||
@Test
|
||||
void preventNull_Name() {
|
||||
|
|
@ -83,14 +81,6 @@ public final class LongValueRecorderTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> meter.longValueRecorderBuilder("metric").setConstantLabels(null).build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void record_PreventNullLabels() {
|
||||
assertThrows(
|
||||
|
|
@ -102,12 +92,7 @@ public final class LongValueRecorderTest {
|
|||
@Test
|
||||
void record_DoesNotThrow() {
|
||||
LongValueRecorder longValueRecorder =
|
||||
meter
|
||||
.longValueRecorderBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.longValueRecorderBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
longValueRecorder.record(5, Labels.empty());
|
||||
longValueRecorder.record(-5, Labels.empty());
|
||||
longValueRecorder.record(5);
|
||||
|
|
@ -125,12 +110,7 @@ public final class LongValueRecorderTest {
|
|||
@Test
|
||||
void bound_DoesNotThrow() {
|
||||
LongValueRecorder longValueRecorder =
|
||||
meter
|
||||
.longValueRecorderBuilder(NAME)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS)
|
||||
.build();
|
||||
meter.longValueRecorderBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
|
||||
BoundLongValueRecorder bound = longValueRecorder.bind(Labels.empty());
|
||||
bound.record(5);
|
||||
bound.record(-5);
|
||||
|
|
|
|||
|
|
@ -62,11 +62,7 @@ public class OtlpExporterExample {
|
|||
|
||||
Tracer tracer = OpenTelemetry.getTracer("io.opentelemetry.example");
|
||||
Meter meter = OpenTelemetry.getMeter("io.opentelemetry.example");
|
||||
LongCounter counter =
|
||||
meter
|
||||
.longCounterBuilder("example_counter")
|
||||
.setConstantLabels(Labels.of("good", "true"))
|
||||
.build();
|
||||
LongCounter counter = meter.longCounterBuilder("example_counter").build();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Span exampleSpan = tracer.spanBuilder("exampleSpan").startSpan();
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ class InMemoryMetricExporterTest {
|
|||
long startNs = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
|
||||
long endNs = startNs + TimeUnit.MILLISECONDS.toNanos(900);
|
||||
return MetricData.create(
|
||||
Descriptor.create(
|
||||
"name", "description", "1", Descriptor.Type.MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
Resource.getEmpty(),
|
||||
InstrumentationLibraryInfo.getEmpty(),
|
||||
Collections.singletonList(LongPoint.create(startNs, endNs, Labels.of("k", "v"), 5)));
|
||||
|
|
|
|||
|
|
@ -65,11 +65,7 @@ class LoggingMetricExporterTest {
|
|||
Arrays.asList(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"measureOne",
|
||||
"A summarized test measure",
|
||||
"ms",
|
||||
Descriptor.Type.SUMMARY,
|
||||
Labels.of("foo", "bar", "baz", "zoom")),
|
||||
"measureOne", "A summarized test measure", "ms", Descriptor.Type.SUMMARY),
|
||||
resource,
|
||||
instrumentationLibraryInfo,
|
||||
Collections.singletonList(
|
||||
|
|
@ -84,11 +80,7 @@ class LoggingMetricExporterTest {
|
|||
ValueAtPercentile.create(100.0, 433))))),
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"counterOne",
|
||||
"A simple counter",
|
||||
"one",
|
||||
Descriptor.Type.MONOTONIC_LONG,
|
||||
Labels.of("alpha", "aleph", "beta", "bet")),
|
||||
"counterOne", "A simple counter", "one", Descriptor.Type.MONOTONIC_LONG),
|
||||
resource,
|
||||
instrumentationLibraryInfo,
|
||||
Collections.singletonList(
|
||||
|
|
@ -99,8 +91,7 @@ class LoggingMetricExporterTest {
|
|||
"observedValue",
|
||||
"an observer gauge",
|
||||
"kb",
|
||||
Descriptor.Type.NON_MONOTONIC_DOUBLE,
|
||||
Labels.of("uno", "eins", "dos", "zwei")),
|
||||
Descriptor.Type.NON_MONOTONIC_DOUBLE),
|
||||
resource,
|
||||
instrumentationLibraryInfo,
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -172,10 +172,6 @@ final class MetricAdapter {
|
|||
.setStartTimeUnixNano(longPoint.getStartEpochNanos())
|
||||
.setTimeUnixNano(longPoint.getEpochNanos())
|
||||
.setValue(longPoint.getValue());
|
||||
// Avoid calling addAllLabels when not needed to save a couple allocations.
|
||||
if (descriptor.getConstantLabels() != null && !descriptor.getConstantLabels().isEmpty()) {
|
||||
builder.addAllLabels(toProtoLabels(descriptor.getConstantLabels()));
|
||||
}
|
||||
Collection<StringKeyValue> labels = toProtoLabels(longPoint.getLabels());
|
||||
if (!labels.isEmpty()) {
|
||||
builder.addAllLabels(labels);
|
||||
|
|
@ -195,10 +191,6 @@ final class MetricAdapter {
|
|||
.setStartTimeUnixNano(doublePoint.getStartEpochNanos())
|
||||
.setTimeUnixNano(doublePoint.getEpochNanos())
|
||||
.setValue(doublePoint.getValue());
|
||||
// Avoid calling addAllLabels when not needed to save a couple allocations.
|
||||
if (descriptor.getConstantLabels() != null && !descriptor.getConstantLabels().isEmpty()) {
|
||||
builder.addAllLabels(toProtoLabels(descriptor.getConstantLabels()));
|
||||
}
|
||||
Collection<StringKeyValue> labels = toProtoLabels(doublePoint.getLabels());
|
||||
if (!labels.isEmpty()) {
|
||||
builder.addAllLabels(labels);
|
||||
|
|
@ -219,10 +211,6 @@ final class MetricAdapter {
|
|||
.setTimeUnixNano(summaryPoint.getEpochNanos())
|
||||
.setCount(summaryPoint.getCount())
|
||||
.setSum(summaryPoint.getSum());
|
||||
// Avoid calling addAllLabels when not needed to save a couple allocations.
|
||||
if (descriptor.getConstantLabels() != null && !descriptor.getConstantLabels().isEmpty()) {
|
||||
builder.addAllLabels(toProtoLabels(descriptor.getConstantLabels()));
|
||||
}
|
||||
List<StringKeyValue> labels = toProtoLabels(summaryPoint.getLabels());
|
||||
if (!labels.isEmpty()) {
|
||||
builder.addAllLabels(labels);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
|
|||
import io.opentelemetry.sdk.metrics.data.MetricData;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData.Descriptor;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
@ -83,12 +82,7 @@ class MetricAdapterTest {
|
|||
@Test
|
||||
void toInt64DataPoints() {
|
||||
Descriptor descriptor =
|
||||
Descriptor.create(
|
||||
"test",
|
||||
"testDescription",
|
||||
"unit",
|
||||
Descriptor.Type.MONOTONIC_LONG,
|
||||
Labels.of("ck", "cv"));
|
||||
Descriptor.create("test", "testDescription", "unit", Descriptor.Type.MONOTONIC_LONG);
|
||||
assertThat(MetricAdapter.toIntDataPoints(Collections.emptyList(), descriptor)).isEmpty();
|
||||
assertThat(
|
||||
MetricAdapter.toIntDataPoints(
|
||||
|
|
@ -99,9 +93,7 @@ class MetricAdapterTest {
|
|||
.setStartTimeUnixNano(123)
|
||||
.setTimeUnixNano(456)
|
||||
.addAllLabels(
|
||||
Arrays.asList(
|
||||
StringKeyValue.newBuilder().setKey("ck").setValue("cv").build(),
|
||||
StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
singletonList(StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
.setValue(5)
|
||||
.build());
|
||||
assertThat(
|
||||
|
|
@ -114,17 +106,13 @@ class MetricAdapterTest {
|
|||
IntDataPoint.newBuilder()
|
||||
.setStartTimeUnixNano(123)
|
||||
.setTimeUnixNano(456)
|
||||
.addAllLabels(
|
||||
singletonList(StringKeyValue.newBuilder().setKey("ck").setValue("cv").build()))
|
||||
.setValue(5)
|
||||
.build(),
|
||||
IntDataPoint.newBuilder()
|
||||
.setStartTimeUnixNano(321)
|
||||
.setTimeUnixNano(654)
|
||||
.addAllLabels(
|
||||
Arrays.asList(
|
||||
StringKeyValue.newBuilder().setKey("ck").setValue("cv").build(),
|
||||
StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
singletonList(StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
.setValue(7)
|
||||
.build());
|
||||
}
|
||||
|
|
@ -132,12 +120,7 @@ class MetricAdapterTest {
|
|||
@Test
|
||||
void toDoubleDataPoints() {
|
||||
Descriptor descriptor =
|
||||
Descriptor.create(
|
||||
"test",
|
||||
"testDescription",
|
||||
"unit",
|
||||
Descriptor.Type.MONOTONIC_DOUBLE,
|
||||
Labels.of("ck", "cv"));
|
||||
Descriptor.create("test", "testDescription", "unit", Descriptor.Type.MONOTONIC_DOUBLE);
|
||||
assertThat(MetricAdapter.toDoubleDataPoints(Collections.emptyList(), descriptor)).isEmpty();
|
||||
assertThat(
|
||||
MetricAdapter.toDoubleDataPoints(
|
||||
|
|
@ -148,9 +131,7 @@ class MetricAdapterTest {
|
|||
.setStartTimeUnixNano(123)
|
||||
.setTimeUnixNano(456)
|
||||
.addAllLabels(
|
||||
Arrays.asList(
|
||||
StringKeyValue.newBuilder().setKey("ck").setValue("cv").build(),
|
||||
StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
singletonList(StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
.setValue(5.1)
|
||||
.build());
|
||||
assertThat(
|
||||
|
|
@ -163,17 +144,13 @@ class MetricAdapterTest {
|
|||
DoubleDataPoint.newBuilder()
|
||||
.setStartTimeUnixNano(123)
|
||||
.setTimeUnixNano(456)
|
||||
.addAllLabels(
|
||||
singletonList(StringKeyValue.newBuilder().setKey("ck").setValue("cv").build()))
|
||||
.setValue(5.1)
|
||||
.build(),
|
||||
DoubleDataPoint.newBuilder()
|
||||
.setStartTimeUnixNano(321)
|
||||
.setTimeUnixNano(654)
|
||||
.addAllLabels(
|
||||
Arrays.asList(
|
||||
StringKeyValue.newBuilder().setKey("ck").setValue("cv").build(),
|
||||
StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
singletonList(StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
.setValue(7.1)
|
||||
.build());
|
||||
}
|
||||
|
|
@ -181,8 +158,7 @@ class MetricAdapterTest {
|
|||
@Test
|
||||
void toSummaryDataPoints() {
|
||||
Descriptor descriptor =
|
||||
Descriptor.create(
|
||||
"test", "testDescription", "unit", Descriptor.Type.SUMMARY, Labels.of("ck", "cv"));
|
||||
Descriptor.create("test", "testDescription", "unit", Descriptor.Type.SUMMARY);
|
||||
assertThat(
|
||||
MetricAdapter.toSummaryDataPoints(
|
||||
singletonList(
|
||||
|
|
@ -199,9 +175,7 @@ class MetricAdapterTest {
|
|||
.setStartTimeUnixNano(123)
|
||||
.setTimeUnixNano(456)
|
||||
.addAllLabels(
|
||||
Arrays.asList(
|
||||
StringKeyValue.newBuilder().setKey("ck").setValue("cv").build(),
|
||||
StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
singletonList(StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
.setCount(5)
|
||||
.setSum(14.2)
|
||||
.addBucketCounts(1)
|
||||
|
|
@ -227,8 +201,6 @@ class MetricAdapterTest {
|
|||
DoubleHistogramDataPoint.newBuilder()
|
||||
.setStartTimeUnixNano(123)
|
||||
.setTimeUnixNano(456)
|
||||
.addAllLabels(
|
||||
singletonList(StringKeyValue.newBuilder().setKey("ck").setValue("cv").build()))
|
||||
.setCount(7)
|
||||
.setSum(15.3)
|
||||
.build(),
|
||||
|
|
@ -236,9 +208,7 @@ class MetricAdapterTest {
|
|||
.setStartTimeUnixNano(321)
|
||||
.setTimeUnixNano(654)
|
||||
.addAllLabels(
|
||||
Arrays.asList(
|
||||
StringKeyValue.newBuilder().setKey("ck").setValue("cv").build(),
|
||||
StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
singletonList(StringKeyValue.newBuilder().setKey("k").setValue("v").build()))
|
||||
.setCount(9)
|
||||
.setSum(18.3)
|
||||
.addBucketCounts(1)
|
||||
|
|
@ -254,12 +224,7 @@ class MetricAdapterTest {
|
|||
assertThat(
|
||||
MetricAdapter.toProtoMetric(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"name",
|
||||
"description",
|
||||
"1",
|
||||
Descriptor.Type.MONOTONIC_LONG,
|
||||
Labels.of("ck", "cv")),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
Resource.getEmpty(),
|
||||
InstrumentationLibraryInfo.getEmpty(),
|
||||
singletonList(MetricData.LongPoint.create(123, 456, Labels.of("k", "v"), 5)))))
|
||||
|
|
@ -277,11 +242,7 @@ class MetricAdapterTest {
|
|||
.setStartTimeUnixNano(123)
|
||||
.setTimeUnixNano(456)
|
||||
.addAllLabels(
|
||||
Arrays.asList(
|
||||
StringKeyValue.newBuilder()
|
||||
.setKey("ck")
|
||||
.setValue("cv")
|
||||
.build(),
|
||||
singletonList(
|
||||
StringKeyValue.newBuilder()
|
||||
.setKey("k")
|
||||
.setValue("v")
|
||||
|
|
@ -293,12 +254,7 @@ class MetricAdapterTest {
|
|||
assertThat(
|
||||
MetricAdapter.toProtoMetric(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"name",
|
||||
"description",
|
||||
"1",
|
||||
Descriptor.Type.MONOTONIC_DOUBLE,
|
||||
Labels.of("ck", "cv")),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.MONOTONIC_DOUBLE),
|
||||
Resource.getEmpty(),
|
||||
InstrumentationLibraryInfo.getEmpty(),
|
||||
singletonList(
|
||||
|
|
@ -317,11 +273,7 @@ class MetricAdapterTest {
|
|||
.setStartTimeUnixNano(123)
|
||||
.setTimeUnixNano(456)
|
||||
.addAllLabels(
|
||||
Arrays.asList(
|
||||
StringKeyValue.newBuilder()
|
||||
.setKey("ck")
|
||||
.setValue("cv")
|
||||
.build(),
|
||||
singletonList(
|
||||
StringKeyValue.newBuilder()
|
||||
.setKey("k")
|
||||
.setValue("v")
|
||||
|
|
@ -335,8 +287,7 @@ class MetricAdapterTest {
|
|||
@Test
|
||||
void toProtoResourceMetrics() {
|
||||
Descriptor descriptor =
|
||||
Descriptor.create(
|
||||
"name", "description", "1", Descriptor.Type.MONOTONIC_DOUBLE, Labels.of("k", "v"));
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.MONOTONIC_DOUBLE);
|
||||
Resource resource = Resource.create(Attributes.of(stringKey("ka"), "va"));
|
||||
io.opentelemetry.proto.resource.v1.Resource resourceProto =
|
||||
io.opentelemetry.proto.resource.v1.Resource.newBuilder()
|
||||
|
|
|
|||
|
|
@ -259,8 +259,7 @@ class OtlpGrpcMetricExporterTest {
|
|||
long startNs = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
|
||||
long endNs = startNs + TimeUnit.MILLISECONDS.toNanos(900);
|
||||
return MetricData.create(
|
||||
Descriptor.create(
|
||||
"name", "description", "1", Descriptor.Type.MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
Resource.getEmpty(),
|
||||
InstrumentationLibraryInfo.getEmpty(),
|
||||
Collections.singletonList(LongPoint.create(startNs, endNs, Labels.of("k", "v"), 5)));
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package io.opentelemetry.exporters.prometheus;
|
|||
import static io.prometheus.client.Collector.doubleToGoString;
|
||||
|
||||
import io.opentelemetry.common.LabelConsumer;
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData.Descriptor;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData.DoublePoint;
|
||||
|
|
@ -90,27 +91,16 @@ final class MetricAdapter {
|
|||
final List<Sample> samples =
|
||||
new ArrayList<>(estimateNumSamples(points.size(), descriptor.getType()));
|
||||
|
||||
List<String> constLabelNames = Collections.emptyList();
|
||||
List<String> constLabelValues = Collections.emptyList();
|
||||
if (descriptor.getConstantLabels().size() != 0) {
|
||||
constLabelNames = new ArrayList<>(descriptor.getConstantLabels().size());
|
||||
constLabelValues = new ArrayList<>(descriptor.getConstantLabels().size());
|
||||
descriptor.getConstantLabels().forEach(new Consumer(constLabelNames, constLabelValues));
|
||||
}
|
||||
|
||||
for (Point point : points) {
|
||||
List<String> labelNames = Collections.emptyList();
|
||||
List<String> labelValues = Collections.emptyList();
|
||||
if (constLabelNames.size() + point.getLabels().size() != 0) {
|
||||
labelNames =
|
||||
new ArrayList<>(descriptor.getConstantLabels().size() + point.getLabels().size());
|
||||
labelNames.addAll(constLabelNames);
|
||||
labelValues =
|
||||
new ArrayList<>(descriptor.getConstantLabels().size() + point.getLabels().size());
|
||||
labelValues.addAll(constLabelValues);
|
||||
Labels labels = point.getLabels();
|
||||
if (labels.size() != 0) {
|
||||
labelNames = new ArrayList<>(labels.size());
|
||||
labelValues = new ArrayList<>(labels.size());
|
||||
|
||||
// TODO: Use a cache(map) of converted label names to avoid sanitization multiple times
|
||||
point.getLabels().forEach(new Consumer(labelNames, labelValues));
|
||||
labels.forEach(new Consumer(labelNames, labelValues));
|
||||
}
|
||||
|
||||
switch (descriptor.getType()) {
|
||||
|
|
|
|||
|
|
@ -54,16 +54,14 @@ class MetricAdapterTest {
|
|||
assertThat(
|
||||
MetricAdapter.toSamples(
|
||||
"full_name",
|
||||
Descriptor.create(
|
||||
"name", "description", "1", Descriptor.Type.MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
Collections.emptyList()))
|
||||
.isEmpty();
|
||||
|
||||
assertThat(
|
||||
MetricAdapter.toSamples(
|
||||
"full_name",
|
||||
Descriptor.create(
|
||||
"name", "description", "1", Descriptor.Type.NON_MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.NON_MONOTONIC_LONG),
|
||||
Collections.singletonList(
|
||||
MetricData.LongPoint.create(123, 456, Labels.of("kp", "vp"), 5))))
|
||||
.containsExactly(
|
||||
|
|
@ -72,32 +70,22 @@ class MetricAdapterTest {
|
|||
assertThat(
|
||||
MetricAdapter.toSamples(
|
||||
"full_name",
|
||||
Descriptor.create(
|
||||
"name",
|
||||
"description",
|
||||
"1",
|
||||
Descriptor.Type.NON_MONOTONIC_LONG,
|
||||
Labels.of("kc", "vc")),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.NON_MONOTONIC_LONG),
|
||||
Collections.singletonList(
|
||||
MetricData.LongPoint.create(123, 456, Labels.of("kp", "vp"), 5))))
|
||||
.containsExactly(
|
||||
new Sample("full_name", ImmutableList.of("kc", "kp"), ImmutableList.of("vc", "vp"), 5));
|
||||
new Sample("full_name", ImmutableList.of("kp"), ImmutableList.of("vp"), 5));
|
||||
|
||||
assertThat(
|
||||
MetricAdapter.toSamples(
|
||||
"full_name",
|
||||
Descriptor.create(
|
||||
"name",
|
||||
"description",
|
||||
"1",
|
||||
Descriptor.Type.MONOTONIC_LONG,
|
||||
Labels.of("kc", "vc")),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
ImmutableList.of(
|
||||
MetricData.LongPoint.create(123, 456, Labels.empty(), 5),
|
||||
MetricData.LongPoint.create(321, 654, Labels.of("kp", "vp"), 7))))
|
||||
.containsExactly(
|
||||
new Sample("full_name", ImmutableList.of("kc"), ImmutableList.of("vc"), 5),
|
||||
new Sample("full_name", ImmutableList.of("kc", "kp"), ImmutableList.of("vc", "vp"), 7));
|
||||
new Sample("full_name", Collections.emptyList(), Collections.emptyList(), 5),
|
||||
new Sample("full_name", ImmutableList.of("kp"), ImmutableList.of("vp"), 7));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -105,20 +93,14 @@ class MetricAdapterTest {
|
|||
assertThat(
|
||||
MetricAdapter.toSamples(
|
||||
"full_name",
|
||||
Descriptor.create(
|
||||
"name",
|
||||
"description",
|
||||
"1",
|
||||
Descriptor.Type.NON_MONOTONIC_DOUBLE,
|
||||
Labels.empty()),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.NON_MONOTONIC_DOUBLE),
|
||||
Collections.emptyList()))
|
||||
.isEmpty();
|
||||
|
||||
assertThat(
|
||||
MetricAdapter.toSamples(
|
||||
"full_name",
|
||||
Descriptor.create(
|
||||
"name", "description", "1", Descriptor.Type.MONOTONIC_DOUBLE, Labels.empty()),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.MONOTONIC_DOUBLE),
|
||||
Collections.singletonList(
|
||||
MetricData.DoublePoint.create(123, 456, Labels.of("kp", "vp"), 5))))
|
||||
.containsExactly(
|
||||
|
|
@ -127,18 +109,13 @@ class MetricAdapterTest {
|
|||
assertThat(
|
||||
MetricAdapter.toSamples(
|
||||
"full_name",
|
||||
Descriptor.create(
|
||||
"name",
|
||||
"description",
|
||||
"1",
|
||||
Descriptor.Type.NON_MONOTONIC_DOUBLE,
|
||||
Labels.of("kc", "vc")),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.NON_MONOTONIC_DOUBLE),
|
||||
ImmutableList.of(
|
||||
MetricData.DoublePoint.create(123, 456, Labels.empty(), 5),
|
||||
MetricData.DoublePoint.create(321, 654, Labels.of("kp", "vp"), 7))))
|
||||
.containsExactly(
|
||||
new Sample("full_name", ImmutableList.of("kc"), ImmutableList.of("vc"), 5),
|
||||
new Sample("full_name", ImmutableList.of("kc", "kp"), ImmutableList.of("vc", "vp"), 7));
|
||||
new Sample("full_name", Collections.emptyList(), Collections.emptyList(), 5),
|
||||
new Sample("full_name", ImmutableList.of("kp"), ImmutableList.of("vp"), 7));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -146,16 +123,14 @@ class MetricAdapterTest {
|
|||
assertThat(
|
||||
MetricAdapter.toSamples(
|
||||
"full_name",
|
||||
Descriptor.create(
|
||||
"name", "description", "1", Descriptor.Type.SUMMARY, Labels.empty()),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.SUMMARY),
|
||||
Collections.emptyList()))
|
||||
.isEmpty();
|
||||
|
||||
assertThat(
|
||||
MetricAdapter.toSamples(
|
||||
"full_name",
|
||||
Descriptor.create(
|
||||
"name", "description", "1", Descriptor.Type.SUMMARY, Labels.empty()),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.SUMMARY),
|
||||
ImmutableList.of(
|
||||
MetricData.SummaryPoint.create(
|
||||
321,
|
||||
|
|
@ -176,8 +151,7 @@ class MetricAdapterTest {
|
|||
assertThat(
|
||||
MetricAdapter.toSamples(
|
||||
"full_name",
|
||||
Descriptor.create(
|
||||
"name", "description", "1", Descriptor.Type.SUMMARY, Labels.of("kc", "vc")),
|
||||
Descriptor.create("name", "description", "1", Descriptor.Type.SUMMARY),
|
||||
ImmutableList.of(
|
||||
MetricData.SummaryPoint.create(
|
||||
123, 456, Labels.empty(), 7, 15.3, Collections.emptyList()),
|
||||
|
|
@ -191,33 +165,26 @@ class MetricAdapterTest {
|
|||
MetricData.ValueAtPercentile.create(0.9, 1.1),
|
||||
MetricData.ValueAtPercentile.create(0.99, 12.3))))))
|
||||
.containsExactly(
|
||||
new Sample("full_name_count", ImmutableList.of("kc"), ImmutableList.of("vc"), 7),
|
||||
new Sample("full_name_sum", ImmutableList.of("kc"), ImmutableList.of("vc"), 15.3),
|
||||
new Sample(
|
||||
"full_name_count", ImmutableList.of("kc", "kp"), ImmutableList.of("vc", "vp"), 9),
|
||||
new Sample(
|
||||
"full_name_sum", ImmutableList.of("kc", "kp"), ImmutableList.of("vc", "vp"), 18.3),
|
||||
new Sample("full_name_count", Collections.emptyList(), Collections.emptyList(), 7),
|
||||
new Sample("full_name_sum", Collections.emptyList(), Collections.emptyList(), 15.3),
|
||||
new Sample("full_name_count", ImmutableList.of("kp"), ImmutableList.of("vp"), 9),
|
||||
new Sample("full_name_sum", ImmutableList.of("kp"), ImmutableList.of("vp"), 18.3),
|
||||
new Sample(
|
||||
"full_name",
|
||||
ImmutableList.of("kc", "kp", "quantile"),
|
||||
ImmutableList.of("vc", "vp", "0.9"),
|
||||
ImmutableList.of("kp", "quantile"),
|
||||
ImmutableList.of("vp", "0.9"),
|
||||
1.1),
|
||||
new Sample(
|
||||
"full_name",
|
||||
ImmutableList.of("kc", "kp", "quantile"),
|
||||
ImmutableList.of("vc", "vp", "0.99"),
|
||||
ImmutableList.of("kp", "quantile"),
|
||||
ImmutableList.of("vp", "0.99"),
|
||||
12.3));
|
||||
}
|
||||
|
||||
@Test
|
||||
void toMetricFamilySamples() {
|
||||
Descriptor descriptor =
|
||||
Descriptor.create(
|
||||
"instrument.name",
|
||||
"description",
|
||||
"1",
|
||||
Descriptor.Type.MONOTONIC_DOUBLE,
|
||||
Labels.of("kc", "vc"));
|
||||
Descriptor.create("instrument.name", "description", "1", Descriptor.Type.MONOTONIC_DOUBLE);
|
||||
|
||||
MetricData metricData =
|
||||
MetricData.create(
|
||||
|
|
@ -235,9 +202,6 @@ class MetricAdapterTest {
|
|||
descriptor.getDescription(),
|
||||
ImmutableList.of(
|
||||
new Sample(
|
||||
"instrument_name",
|
||||
ImmutableList.of("kc", "kp"),
|
||||
ImmutableList.of("vc", "vp"),
|
||||
5))));
|
||||
"instrument_name", ImmutableList.of("kp"), ImmutableList.of("vp"), 5))));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,32 +58,23 @@ class PrometheusCollectorTest {
|
|||
.isEqualTo(
|
||||
"# HELP grpc_name long_description\n"
|
||||
+ "# TYPE grpc_name counter\n"
|
||||
+ "grpc_name{kc=\"vc\",kp=\"vp\",} 5.0\n"
|
||||
+ "grpc_name{kp=\"vp\",} 5.0\n"
|
||||
+ "# HELP http_name double_description\n"
|
||||
+ "# TYPE http_name counter\n"
|
||||
+ "http_name{kc=\"vc\",kp=\"vp\",} 3.5\n");
|
||||
+ "http_name{kp=\"vp\",} 3.5\n");
|
||||
}
|
||||
|
||||
private static ImmutableList<MetricData> generateTestData() {
|
||||
return ImmutableList.of(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"grpc.name",
|
||||
"long_description",
|
||||
"1",
|
||||
Descriptor.Type.MONOTONIC_LONG,
|
||||
Labels.of("kc", "vc")),
|
||||
Descriptor.create("grpc.name", "long_description", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
Resource.create(Attributes.of(stringKey("kr"), "vr")),
|
||||
InstrumentationLibraryInfo.create("grpc", "version"),
|
||||
Collections.singletonList(
|
||||
MetricData.LongPoint.create(123, 456, Labels.of("kp", "vp"), 5))),
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"http.name",
|
||||
"double_description",
|
||||
"1",
|
||||
Descriptor.Type.MONOTONIC_DOUBLE,
|
||||
Labels.of("kc", "vc")),
|
||||
"http.name", "double_description", "1", Descriptor.Type.MONOTONIC_DOUBLE),
|
||||
Resource.create(Attributes.of(stringKey("kr"), "vr")),
|
||||
InstrumentationLibraryInfo.create("http", "version"),
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package io.opentelemetry.sdk.metrics;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.internal.StringUtils;
|
||||
import io.opentelemetry.internal.Utils;
|
||||
import io.opentelemetry.metrics.Instrument;
|
||||
|
|
@ -99,7 +98,6 @@ abstract class AbstractInstrument implements Instrument {
|
|||
private final MeterSdk meterSdk;
|
||||
private String description = "";
|
||||
private String unit = "1";
|
||||
private Labels constantLabels = Labels.empty();
|
||||
|
||||
Builder(
|
||||
String name,
|
||||
|
|
@ -126,12 +124,6 @@ abstract class AbstractInstrument implements Instrument {
|
|||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final B setConstantLabels(Labels constantLabels) {
|
||||
this.constantLabels = constantLabels;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
final MeterProviderSharedState getMeterProviderSharedState() {
|
||||
return meterProviderSharedState;
|
||||
}
|
||||
|
|
@ -142,7 +134,7 @@ abstract class AbstractInstrument implements Instrument {
|
|||
|
||||
final InstrumentDescriptor getInstrumentDescriptor(
|
||||
InstrumentType type, InstrumentValueType valueType) {
|
||||
return InstrumentDescriptor.create(name, description, unit, constantLabels, type, valueType);
|
||||
return InstrumentDescriptor.create(name, description, unit, type, valueType);
|
||||
}
|
||||
|
||||
abstract B getThis();
|
||||
|
|
|
|||
|
|
@ -166,8 +166,7 @@ final class Batchers {
|
|||
descriptor.getName(),
|
||||
descriptor.getDescription(),
|
||||
aggregation.getUnit(descriptor.getUnit()),
|
||||
aggregation.getDescriptorType(descriptor.getType(), descriptor.getValueType()),
|
||||
descriptor.getConstantLabels());
|
||||
aggregation.getDescriptorType(descriptor.getType(), descriptor.getValueType()));
|
||||
}
|
||||
|
||||
private Batchers() {}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package io.opentelemetry.sdk.metrics;
|
|||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.auto.value.extension.memoized.Memoized;
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.sdk.metrics.common.InstrumentType;
|
||||
import io.opentelemetry.sdk.metrics.common.InstrumentValueType;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
|
@ -30,11 +29,9 @@ abstract class InstrumentDescriptor {
|
|||
String name,
|
||||
String description,
|
||||
String unit,
|
||||
Labels constantLabels,
|
||||
InstrumentType type,
|
||||
InstrumentValueType valueType) {
|
||||
return new AutoValue_InstrumentDescriptor(
|
||||
name, description, unit, constantLabels, type, valueType);
|
||||
return new AutoValue_InstrumentDescriptor(name, description, unit, type, valueType);
|
||||
}
|
||||
|
||||
abstract String getName();
|
||||
|
|
@ -43,8 +40,6 @@ abstract class InstrumentDescriptor {
|
|||
|
||||
abstract String getUnit();
|
||||
|
||||
abstract Labels getConstantLabels();
|
||||
|
||||
abstract InstrumentType getType();
|
||||
|
||||
abstract InstrumentValueType getValueType();
|
||||
|
|
|
|||
|
|
@ -272,16 +272,8 @@ public abstract class MetricData {
|
|||
*/
|
||||
public abstract Type getType();
|
||||
|
||||
/**
|
||||
* Returns the constant labels associated with this metric descriptor.
|
||||
*
|
||||
* @return the constant labels associated with this metric descriptor.
|
||||
*/
|
||||
public abstract Labels getConstantLabels();
|
||||
|
||||
public static Descriptor create(
|
||||
String name, String description, String unit, Type type, Labels constantLabels) {
|
||||
return new AutoValue_MetricData_Descriptor(name, description, unit, type, constantLabels);
|
||||
public static Descriptor create(String name, String description, String unit, Type type) {
|
||||
return new AutoValue_MetricData_Descriptor(name, description, unit, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import static io.opentelemetry.sdk.metrics.AbstractInstrument.Builder.ERROR_MESS
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.internal.StringUtils;
|
||||
import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
|
||||
import io.opentelemetry.sdk.internal.TestClock;
|
||||
|
|
@ -39,7 +38,6 @@ class AbstractInstrumentBuilderTest {
|
|||
private static final String NAME = "name";
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String UNIT = "1";
|
||||
private static final Labels CONSTANT_LABELS = Labels.of("key_2", "value_2");
|
||||
private static final MeterProviderSharedState METER_PROVIDER_SHARED_STATE =
|
||||
MeterProviderSharedState.create(TestClock.create(), Resource.getEmpty());
|
||||
private static final MeterSharedState METER_SHARED_STATE =
|
||||
|
|
@ -121,17 +119,6 @@ class AbstractInstrumentBuilderTest {
|
|||
"unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preventNull_ConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() ->
|
||||
new TestInstrumentBuilder(NAME, METER_PROVIDER_SHARED_STATE, METER_SHARED_STATE)
|
||||
.setConstantLabels(null)
|
||||
.build(),
|
||||
"constantLabels");
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultValue() {
|
||||
TestInstrumentBuilder testInstrumentBuilder =
|
||||
|
|
@ -141,7 +128,6 @@ class AbstractInstrumentBuilderTest {
|
|||
assertThat(testInstrument.getDescriptor().getName()).isEqualTo(NAME);
|
||||
assertThat(testInstrument.getDescriptor().getDescription()).isEmpty();
|
||||
assertThat(testInstrument.getDescriptor().getUnit()).isEqualTo("1");
|
||||
assertThat(testInstrument.getDescriptor().getConstantLabels().isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -149,8 +135,7 @@ class AbstractInstrumentBuilderTest {
|
|||
TestInstrumentBuilder testInstrumentBuilder =
|
||||
new TestInstrumentBuilder(NAME, METER_PROVIDER_SHARED_STATE, METER_SHARED_STATE)
|
||||
.setDescription(DESCRIPTION)
|
||||
.setUnit(UNIT)
|
||||
.setConstantLabels(CONSTANT_LABELS);
|
||||
.setUnit(UNIT);
|
||||
assertThat(testInstrumentBuilder.getMeterProviderSharedState())
|
||||
.isSameAs(METER_PROVIDER_SHARED_STATE);
|
||||
assertThat(testInstrumentBuilder.getMeterSharedState()).isSameAs(METER_SHARED_STATE);
|
||||
|
|
@ -160,7 +145,6 @@ class AbstractInstrumentBuilderTest {
|
|||
assertThat(testInstrument.getDescriptor().getName()).isEqualTo(NAME);
|
||||
assertThat(testInstrument.getDescriptor().getDescription()).isEqualTo(DESCRIPTION);
|
||||
assertThat(testInstrument.getDescriptor().getUnit()).isEqualTo(UNIT);
|
||||
assertThat(testInstrument.getDescriptor().getConstantLabels()).isEqualTo(CONSTANT_LABELS);
|
||||
assertThat(testInstrument.getDescriptor().getType()).isEqualTo(InstrumentType.UP_DOWN_COUNTER);
|
||||
assertThat(testInstrument.getDescriptor().getValueType()).isEqualTo(InstrumentValueType.LONG);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package io.opentelemetry.sdk.metrics;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
|
||||
import io.opentelemetry.sdk.internal.TestClock;
|
||||
import io.opentelemetry.sdk.metrics.common.InstrumentType;
|
||||
|
|
@ -33,12 +32,7 @@ import org.junit.jupiter.api.Test;
|
|||
class AbstractInstrumentTest {
|
||||
private static final InstrumentDescriptor INSTRUMENT_DESCRIPTOR =
|
||||
InstrumentDescriptor.create(
|
||||
"name",
|
||||
"description",
|
||||
"1",
|
||||
Labels.of("key_2", "value_2"),
|
||||
InstrumentType.COUNTER,
|
||||
InstrumentValueType.LONG);
|
||||
"name", "description", "1", InstrumentType.COUNTER, InstrumentValueType.LONG);
|
||||
private static final MeterProviderSharedState METER_PROVIDER_SHARED_STATE =
|
||||
MeterProviderSharedState.create(TestClock.create(), Resource.getEmpty());
|
||||
private static final InstrumentationLibraryInfo INSTRUMENTATION_LIBRARY_INFO =
|
||||
|
|
|
|||
|
|
@ -79,8 +79,7 @@ class BatchRecorderSdkTest {
|
|||
assertThat(doubleCounter.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testDoubleCounter", "", "1", Descriptor.Type.MONOTONIC_DOUBLE, Labels.empty()),
|
||||
Descriptor.create("testDoubleCounter", "", "1", Descriptor.Type.MONOTONIC_DOUBLE),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
@ -88,8 +87,7 @@ class BatchRecorderSdkTest {
|
|||
assertThat(longCounter.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testLongCounter", "", "1", Descriptor.Type.MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("testLongCounter", "", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
@ -98,11 +96,7 @@ class BatchRecorderSdkTest {
|
|||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testDoubleUpDownCounter",
|
||||
"",
|
||||
"1",
|
||||
Descriptor.Type.NON_MONOTONIC_DOUBLE,
|
||||
Labels.empty()),
|
||||
"testDoubleUpDownCounter", "", "1", Descriptor.Type.NON_MONOTONIC_DOUBLE),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
@ -111,11 +105,7 @@ class BatchRecorderSdkTest {
|
|||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testLongUpDownCounter",
|
||||
"",
|
||||
"1",
|
||||
Descriptor.Type.NON_MONOTONIC_LONG,
|
||||
Labels.empty()),
|
||||
"testLongUpDownCounter", "", "1", Descriptor.Type.NON_MONOTONIC_LONG),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ class DoubleCounterSdkTest {
|
|||
DoubleCounterSdk doubleCounter =
|
||||
testSdk
|
||||
.doubleCounterBuilder("testCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -78,11 +77,7 @@ class DoubleCounterSdkTest {
|
|||
assertThat(metricData.getDescriptor())
|
||||
.isEqualTo(
|
||||
Descriptor.create(
|
||||
"testCounter",
|
||||
"My very own counter",
|
||||
"ms",
|
||||
Descriptor.Type.MONOTONIC_DOUBLE,
|
||||
Labels.of("sk1", "sv1")));
|
||||
"testCounter", "My very own counter", "ms", Descriptor.Type.MONOTONIC_DOUBLE));
|
||||
assertThat(metricData.getResource()).isEqualTo(RESOURCE);
|
||||
assertThat(metricData.getInstrumentationLibraryInfo()).isEqualTo(INSTRUMENTATION_LIBRARY_INFO);
|
||||
assertThat(metricData.getPoints()).isEmpty();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ class DoubleSumObserverSdkTest {
|
|||
DoubleSumObserverSdk doubleSumObserver =
|
||||
testSdk
|
||||
.doubleSumObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My own DoubleSumObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -61,7 +60,6 @@ class DoubleSumObserverSdkTest {
|
|||
DoubleSumObserverSdk doubleSumObserver =
|
||||
testSdk
|
||||
.doubleSumObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My own DoubleSumObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -76,8 +74,7 @@ class DoubleSumObserverSdkTest {
|
|||
"testObserver",
|
||||
"My own DoubleSumObserver",
|
||||
"ms",
|
||||
Descriptor.Type.MONOTONIC_DOUBLE,
|
||||
Labels.of("sk1", "sv1")),
|
||||
Descriptor.Type.MONOTONIC_DOUBLE),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.emptyList()));
|
||||
|
|
@ -92,8 +89,7 @@ class DoubleSumObserverSdkTest {
|
|||
assertThat(doubleSumObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testObserver", "", "1", Descriptor.Type.MONOTONIC_DOUBLE, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.MONOTONIC_DOUBLE),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
@ -106,8 +102,7 @@ class DoubleSumObserverSdkTest {
|
|||
assertThat(doubleSumObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testObserver", "", "1", Descriptor.Type.MONOTONIC_DOUBLE, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.MONOTONIC_DOUBLE),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ class DoubleUpDownCounterSdkTest {
|
|||
DoubleUpDownCounterSdk doubleUpDownCounter =
|
||||
testSdk
|
||||
.doubleUpDownCounterBuilder("testUpDownCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -82,8 +81,7 @@ class DoubleUpDownCounterSdkTest {
|
|||
"testUpDownCounter",
|
||||
"My very own counter",
|
||||
"ms",
|
||||
Descriptor.Type.NON_MONOTONIC_DOUBLE,
|
||||
Labels.of("sk1", "sv1")));
|
||||
Descriptor.Type.NON_MONOTONIC_DOUBLE));
|
||||
assertThat(metricData.getResource()).isEqualTo(RESOURCE);
|
||||
assertThat(metricData.getInstrumentationLibraryInfo()).isEqualTo(INSTRUMENTATION_LIBRARY_INFO);
|
||||
assertThat(metricData.getPoints()).isEmpty();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ class DoubleUpDownSumObserverSdkTest {
|
|||
DoubleUpDownSumObserverSdk doubleUpDownSumObserver =
|
||||
testSdk
|
||||
.doubleUpDownSumObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own DoubleUpDownSumObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -61,7 +60,6 @@ class DoubleUpDownSumObserverSdkTest {
|
|||
DoubleUpDownSumObserverSdk doubleUpDownSumObserver =
|
||||
testSdk
|
||||
.doubleUpDownSumObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My own DoubleUpDownSumObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -76,8 +74,7 @@ class DoubleUpDownSumObserverSdkTest {
|
|||
"testObserver",
|
||||
"My own DoubleUpDownSumObserver",
|
||||
"ms",
|
||||
Descriptor.Type.NON_MONOTONIC_DOUBLE,
|
||||
Labels.of("sk1", "sv1")),
|
||||
Descriptor.Type.NON_MONOTONIC_DOUBLE),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.emptyList()));
|
||||
|
|
@ -92,8 +89,7 @@ class DoubleUpDownSumObserverSdkTest {
|
|||
assertThat(doubleUpDownSumObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testObserver", "", "1", Descriptor.Type.NON_MONOTONIC_DOUBLE, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.NON_MONOTONIC_DOUBLE),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
@ -106,8 +102,7 @@ class DoubleUpDownSumObserverSdkTest {
|
|||
assertThat(doubleUpDownSumObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testObserver", "", "1", Descriptor.Type.NON_MONOTONIC_DOUBLE, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.NON_MONOTONIC_DOUBLE),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ class DoubleValueObserverSdkTest {
|
|||
DoubleValueObserverSdk doubleValueObserver =
|
||||
testSdk
|
||||
.doubleValueObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My own DoubleValueObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -64,7 +63,6 @@ class DoubleValueObserverSdkTest {
|
|||
DoubleValueObserverSdk doubleValueObserver =
|
||||
testSdk
|
||||
.doubleValueObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My own DoubleValueObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -76,11 +74,7 @@ class DoubleValueObserverSdkTest {
|
|||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testObserver",
|
||||
"My own DoubleValueObserver",
|
||||
"ms",
|
||||
Descriptor.Type.SUMMARY,
|
||||
Labels.of("sk1", "sv1")),
|
||||
"testObserver", "My own DoubleValueObserver", "ms", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.emptyList()));
|
||||
|
|
@ -95,7 +89,7 @@ class DoubleValueObserverSdkTest {
|
|||
assertThat(doubleValueObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.SUMMARY, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
@ -110,7 +104,7 @@ class DoubleValueObserverSdkTest {
|
|||
assertThat(doubleValueObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.SUMMARY, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ class DoubleValueRecorderSdkTest {
|
|||
DoubleValueRecorderSdk doubleMeasure =
|
||||
testSdk
|
||||
.doubleValueRecorderBuilder("testRecorder")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own measure")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -82,11 +81,7 @@ class DoubleValueRecorderSdkTest {
|
|||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testRecorder",
|
||||
"My very own measure",
|
||||
"ms",
|
||||
Descriptor.Type.SUMMARY,
|
||||
Labels.of("sk1", "sv1")),
|
||||
"testRecorder", "My very own measure", "ms", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.emptyList()));
|
||||
|
|
@ -97,7 +92,6 @@ class DoubleValueRecorderSdkTest {
|
|||
DoubleValueRecorderSdk doubleMeasure =
|
||||
testSdk
|
||||
.doubleValueRecorderBuilder("testRecorder")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own measure")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -109,11 +103,7 @@ class DoubleValueRecorderSdkTest {
|
|||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testRecorder",
|
||||
"My very own measure",
|
||||
"ms",
|
||||
Descriptor.Type.SUMMARY,
|
||||
Labels.of("sk1", "sv1")),
|
||||
"testRecorder", "My very own measure", "ms", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.emptyList()));
|
||||
|
|
@ -129,7 +119,7 @@ class DoubleValueRecorderSdkTest {
|
|||
assertThat(metricDataList)
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create("testRecorder", "", "1", Descriptor.Type.SUMMARY, Labels.empty()),
|
||||
Descriptor.create("testRecorder", "", "1", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import static io.opentelemetry.sdk.common.InstrumentationLibraryInfo.getEmpty;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
|
||||
import io.opentelemetry.sdk.internal.TestClock;
|
||||
import io.opentelemetry.sdk.metrics.common.InstrumentType;
|
||||
|
|
@ -35,20 +34,10 @@ import org.junit.jupiter.api.Test;
|
|||
class InstrumentRegistryTest {
|
||||
private static final InstrumentDescriptor INSTRUMENT_DESCRIPTOR =
|
||||
InstrumentDescriptor.create(
|
||||
"name",
|
||||
"description",
|
||||
"1",
|
||||
Labels.of("key_2", "value_2"),
|
||||
InstrumentType.COUNTER,
|
||||
InstrumentValueType.LONG);
|
||||
"name", "description", "1", InstrumentType.COUNTER, InstrumentValueType.LONG);
|
||||
private static final InstrumentDescriptor OTHER_INSTRUMENT_DESCRIPTOR =
|
||||
InstrumentDescriptor.create(
|
||||
"name",
|
||||
"other_description",
|
||||
"1",
|
||||
Labels.of("key_2", "value_2"),
|
||||
InstrumentType.COUNTER,
|
||||
InstrumentValueType.LONG);
|
||||
"name", "other_description", "1", InstrumentType.COUNTER, InstrumentValueType.LONG);
|
||||
private static final MeterProviderSharedState METER_PROVIDER_SHARED_STATE =
|
||||
MeterProviderSharedState.create(TestClock.create(), Resource.getEmpty());
|
||||
private static final ActiveBatcher ACTIVE_BATCHER = new ActiveBatcher(Batchers.getNoop());
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ class LongCounterSdkTest {
|
|||
LongCounterSdk longCounter =
|
||||
testSdk
|
||||
.longCounterBuilder("testCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -79,11 +78,7 @@ class LongCounterSdkTest {
|
|||
assertThat(metricData.getDescriptor())
|
||||
.isEqualTo(
|
||||
Descriptor.create(
|
||||
"testCounter",
|
||||
"My very own counter",
|
||||
"ms",
|
||||
Descriptor.Type.MONOTONIC_LONG,
|
||||
Labels.of("sk1", "sv1")));
|
||||
"testCounter", "My very own counter", "ms", Descriptor.Type.MONOTONIC_LONG));
|
||||
assertThat(metricData.getResource()).isEqualTo(RESOURCE);
|
||||
assertThat(metricData.getInstrumentationLibraryInfo()).isEqualTo(INSTRUMENTATION_LIBRARY_INFO);
|
||||
assertThat(metricData.getPoints()).isEmpty();
|
||||
|
|
@ -94,7 +89,6 @@ class LongCounterSdkTest {
|
|||
LongCounterSdk longCounter =
|
||||
testSdk
|
||||
.longCounterBuilder("testCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -106,11 +100,7 @@ class LongCounterSdkTest {
|
|||
assertThat(metricData.getDescriptor())
|
||||
.isEqualTo(
|
||||
Descriptor.create(
|
||||
"testCounter",
|
||||
"My very own counter",
|
||||
"ms",
|
||||
Descriptor.Type.MONOTONIC_LONG,
|
||||
Labels.of("sk1", "sv1")));
|
||||
"testCounter", "My very own counter", "ms", Descriptor.Type.MONOTONIC_LONG));
|
||||
assertThat(metricData.getResource()).isEqualTo(RESOURCE);
|
||||
assertThat(metricData.getInstrumentationLibraryInfo()).isEqualTo(INSTRUMENTATION_LIBRARY_INFO);
|
||||
assertThat(metricData.getPoints()).isEmpty();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ class LongSumObserverSdkTest {
|
|||
LongSumObserverSdk longSumObserver =
|
||||
testSdk
|
||||
.longSumObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My own LongSumObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -61,7 +60,6 @@ class LongSumObserverSdkTest {
|
|||
LongSumObserverSdk longSumObserver =
|
||||
testSdk
|
||||
.longSumObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My own LongSumObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -73,11 +71,7 @@ class LongSumObserverSdkTest {
|
|||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testObserver",
|
||||
"My own LongSumObserver",
|
||||
"ms",
|
||||
Descriptor.Type.MONOTONIC_LONG,
|
||||
Labels.of("sk1", "sv1")),
|
||||
"testObserver", "My own LongSumObserver", "ms", Descriptor.Type.MONOTONIC_LONG),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.emptyList()));
|
||||
|
|
@ -91,8 +85,7 @@ class LongSumObserverSdkTest {
|
|||
assertThat(longSumObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testObserver", "", "1", Descriptor.Type.MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
@ -105,8 +98,7 @@ class LongSumObserverSdkTest {
|
|||
assertThat(longSumObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testObserver", "", "1", Descriptor.Type.MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ class LongUpDownCounterSdkTest {
|
|||
LongUpDownCounterSdk longUpDownCounter =
|
||||
testSdk
|
||||
.longUpDownCounterBuilder("testUpDownCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -82,8 +81,7 @@ class LongUpDownCounterSdkTest {
|
|||
"testUpDownCounter",
|
||||
"My very own counter",
|
||||
"ms",
|
||||
Descriptor.Type.NON_MONOTONIC_LONG,
|
||||
Labels.of("sk1", "sv1")));
|
||||
Descriptor.Type.NON_MONOTONIC_LONG));
|
||||
assertThat(metricData.getResource()).isEqualTo(RESOURCE);
|
||||
assertThat(metricData.getInstrumentationLibraryInfo()).isEqualTo(INSTRUMENTATION_LIBRARY_INFO);
|
||||
assertThat(metricData.getPoints()).isEmpty();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ class LongUpDownSumObserverSdkTest {
|
|||
LongUpDownSumObserverSdk longUpDownSumObserver =
|
||||
testSdk
|
||||
.longUpDownSumObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My own LongUpDownSumObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -61,7 +60,6 @@ class LongUpDownSumObserverSdkTest {
|
|||
LongUpDownSumObserverSdk longUpDownSumObserver =
|
||||
testSdk
|
||||
.longUpDownSumObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My own LongUpDownSumObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -76,8 +74,7 @@ class LongUpDownSumObserverSdkTest {
|
|||
"testObserver",
|
||||
"My own LongUpDownSumObserver",
|
||||
"ms",
|
||||
Descriptor.Type.NON_MONOTONIC_LONG,
|
||||
Labels.of("sk1", "sv1")),
|
||||
Descriptor.Type.NON_MONOTONIC_LONG),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.emptyList()));
|
||||
|
|
@ -92,8 +89,7 @@ class LongUpDownSumObserverSdkTest {
|
|||
assertThat(longUpDownSumObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testObserver", "", "1", Descriptor.Type.NON_MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.NON_MONOTONIC_LONG),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
@ -106,8 +102,7 @@ class LongUpDownSumObserverSdkTest {
|
|||
assertThat(longUpDownSumObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testObserver", "", "1", Descriptor.Type.NON_MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.NON_MONOTONIC_LONG),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ class LongValueObserverSdkTest {
|
|||
LongValueObserverSdk longValueObserver =
|
||||
testSdk
|
||||
.longValueObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My own LongValueObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -64,7 +63,6 @@ class LongValueObserverSdkTest {
|
|||
LongValueObserverSdk longValueObserver =
|
||||
testSdk
|
||||
.longValueObserverBuilder("testObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My own LongValueObserver")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -76,11 +74,7 @@ class LongValueObserverSdkTest {
|
|||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testObserver",
|
||||
"My own LongValueObserver",
|
||||
"ms",
|
||||
Descriptor.Type.SUMMARY,
|
||||
Labels.of("sk1", "sv1")),
|
||||
"testObserver", "My own LongValueObserver", "ms", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.emptyList()));
|
||||
|
|
@ -95,7 +89,7 @@ class LongValueObserverSdkTest {
|
|||
assertThat(longValueObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.SUMMARY, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
@ -110,7 +104,7 @@ class LongValueObserverSdkTest {
|
|||
assertThat(longValueObserver.collectAll())
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.SUMMARY, Labels.empty()),
|
||||
Descriptor.create("testObserver", "", "1", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ class LongValueRecorderSdkTest {
|
|||
LongValueRecorderSdk longMeasure =
|
||||
testSdk
|
||||
.longValueRecorderBuilder("testRecorder")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -82,11 +81,7 @@ class LongValueRecorderSdkTest {
|
|||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testRecorder",
|
||||
"My very own counter",
|
||||
"ms",
|
||||
Descriptor.Type.SUMMARY,
|
||||
Labels.of("sk1", "sv1")),
|
||||
"testRecorder", "My very own counter", "ms", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.emptyList()));
|
||||
|
|
@ -97,7 +92,6 @@ class LongValueRecorderSdkTest {
|
|||
LongValueRecorderSdk longMeasure =
|
||||
testSdk
|
||||
.longValueRecorderBuilder("testRecorder")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("ms")
|
||||
.build();
|
||||
|
|
@ -110,11 +104,7 @@ class LongValueRecorderSdkTest {
|
|||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testRecorder",
|
||||
"My very own counter",
|
||||
"ms",
|
||||
Descriptor.Type.SUMMARY,
|
||||
Labels.of("sk1", "sv1")),
|
||||
"testRecorder", "My very own counter", "ms", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.emptyList()));
|
||||
|
|
@ -129,7 +119,7 @@ class LongValueRecorderSdkTest {
|
|||
assertThat(metricDataList)
|
||||
.containsExactly(
|
||||
MetricData.create(
|
||||
Descriptor.create("testRecorder", "", "1", Descriptor.Type.SUMMARY, Labels.empty()),
|
||||
Descriptor.create("testRecorder", "", "1", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -95,15 +95,13 @@ class MeterSdkRegistryTest {
|
|||
assertThat(meterProvider.getMetricProducer().collectAllMetrics())
|
||||
.containsExactlyInAnyOrder(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testLongCounter", "", "1", Descriptor.Type.MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("testLongCounter", "", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
Resource.getEmpty(),
|
||||
meterSdk1.getInstrumentationLibraryInfo(),
|
||||
Collections.singletonList(
|
||||
LongPoint.create(testClock.now(), testClock.now(), Labels.empty(), 10))),
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testLongCounter", "", "1", Descriptor.Type.MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("testLongCounter", "", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
Resource.getEmpty(),
|
||||
meterSdk2.getInstrumentationLibraryInfo(),
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ class MeterSdkTest {
|
|||
LongCounterSdk longCounter =
|
||||
testSdk
|
||||
.longCounterBuilder("testLongCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -64,7 +63,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.longCounterBuilder("testLongCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -85,7 +83,6 @@ class MeterSdkTest {
|
|||
LongUpDownCounterSdk longUpDownCounter =
|
||||
testSdk
|
||||
.longUpDownCounterBuilder("testLongUpDownCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -94,7 +91,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.longUpDownCounterBuilder("testLongUpDownCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -115,7 +111,6 @@ class MeterSdkTest {
|
|||
LongValueRecorderSdk longValueRecorder =
|
||||
testSdk
|
||||
.longValueRecorderBuilder("testLongValueRecorder")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -124,7 +119,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.longValueRecorderBuilder("testLongValueRecorder")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -145,7 +139,6 @@ class MeterSdkTest {
|
|||
LongValueObserver longValueObserver =
|
||||
testSdk
|
||||
.longValueObserverBuilder("longValueObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -154,7 +147,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.longValueObserverBuilder("longValueObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -175,7 +167,6 @@ class MeterSdkTest {
|
|||
LongSumObserverSdk longObserver =
|
||||
testSdk
|
||||
.longSumObserverBuilder("testLongSumObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -184,7 +175,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.longSumObserverBuilder("testLongSumObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -206,7 +196,6 @@ class MeterSdkTest {
|
|||
LongUpDownSumObserverSdk longObserver =
|
||||
testSdk
|
||||
.longUpDownSumObserverBuilder("testLongUpDownSumObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -215,7 +204,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.longUpDownSumObserverBuilder("testLongUpDownSumObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -238,7 +226,6 @@ class MeterSdkTest {
|
|||
DoubleCounterSdk doubleCounter =
|
||||
testSdk
|
||||
.doubleCounterBuilder("testDoubleCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -247,7 +234,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.doubleCounterBuilder("testDoubleCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -268,7 +254,6 @@ class MeterSdkTest {
|
|||
DoubleUpDownCounterSdk doubleUpDownCounter =
|
||||
testSdk
|
||||
.doubleUpDownCounterBuilder("testDoubleUpDownCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -277,7 +262,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.doubleUpDownCounterBuilder("testDoubleUpDownCounter")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -298,7 +282,6 @@ class MeterSdkTest {
|
|||
DoubleValueRecorderSdk doubleValueRecorder =
|
||||
testSdk
|
||||
.doubleValueRecorderBuilder("testDoubleValueRecorder")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own ValueRecorder")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -307,7 +290,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.doubleValueRecorderBuilder("testDoubleValueRecorder")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own ValueRecorder")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -328,7 +310,6 @@ class MeterSdkTest {
|
|||
DoubleSumObserverSdk doubleObserver =
|
||||
testSdk
|
||||
.doubleSumObserverBuilder("testDoubleSumObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -337,7 +318,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.doubleSumObserverBuilder("testDoubleSumObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -358,7 +338,6 @@ class MeterSdkTest {
|
|||
DoubleUpDownSumObserverSdk doubleObserver =
|
||||
testSdk
|
||||
.doubleUpDownSumObserverBuilder("testDoubleUpDownSumObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -367,7 +346,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.doubleUpDownSumObserverBuilder("testDoubleUpDownSumObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -391,7 +369,6 @@ class MeterSdkTest {
|
|||
DoubleValueObserver doubleValueObserver =
|
||||
testSdk
|
||||
.doubleValueObserverBuilder("doubleValueObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build();
|
||||
|
|
@ -400,7 +377,6 @@ class MeterSdkTest {
|
|||
assertThat(
|
||||
testSdk
|
||||
.doubleValueObserverBuilder("doubleValueObserver")
|
||||
.setConstantLabels(Labels.of("sk1", "sv1"))
|
||||
.setDescription("My very own counter")
|
||||
.setUnit("metric tonnes")
|
||||
.build())
|
||||
|
|
@ -442,22 +418,19 @@ class MeterSdkTest {
|
|||
assertThat(testSdk.collectAll())
|
||||
.containsExactlyInAnyOrder(
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testLongCounter", "", "1", Descriptor.Type.MONOTONIC_LONG, Labels.empty()),
|
||||
Descriptor.create("testLongCounter", "", "1", Descriptor.Type.MONOTONIC_LONG),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
LongPoint.create(testClock.now(), testClock.now(), Labels.empty(), 10))),
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testDoubleCounter", "", "1", Descriptor.Type.MONOTONIC_DOUBLE, Labels.empty()),
|
||||
Descriptor.create("testDoubleCounter", "", "1", Descriptor.Type.MONOTONIC_DOUBLE),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
DoublePoint.create(testClock.now(), testClock.now(), Labels.empty(), 10.1))),
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testLongValueRecorder", "", "1", Descriptor.Type.SUMMARY, Labels.empty()),
|
||||
Descriptor.create("testLongValueRecorder", "", "1", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
@ -470,8 +443,7 @@ class MeterSdkTest {
|
|||
Arrays.asList(
|
||||
ValueAtPercentile.create(0, 10), ValueAtPercentile.create(100, 10))))),
|
||||
MetricData.create(
|
||||
Descriptor.create(
|
||||
"testDoubleValueRecorder", "", "1", Descriptor.Type.SUMMARY, Labels.empty()),
|
||||
Descriptor.create("testDoubleValueRecorder", "", "1", Descriptor.Type.SUMMARY),
|
||||
RESOURCE,
|
||||
INSTRUMENTATION_LIBRARY_INFO,
|
||||
Collections.singletonList(
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package io.opentelemetry.sdk.metrics.data;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import io.opentelemetry.common.Labels;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData.Descriptor;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
@ -30,34 +29,27 @@ class MetricDataDescriptorTest {
|
|||
private static final String DESCRIPTION = "Instrument description.";
|
||||
private static final String UNIT = "kb/s";
|
||||
private static final Descriptor.Type TYPE = Descriptor.Type.MONOTONIC_LONG;
|
||||
private static final String KEY = "key1";
|
||||
private static final String VALUE = "value_1";
|
||||
|
||||
@Test
|
||||
void testGet() {
|
||||
Descriptor descriptor =
|
||||
Descriptor.create(METRIC_NAME, DESCRIPTION, UNIT, TYPE, Labels.of(KEY, VALUE));
|
||||
Descriptor descriptor = Descriptor.create(METRIC_NAME, DESCRIPTION, UNIT, TYPE);
|
||||
assertThat(descriptor.getName()).isEqualTo(METRIC_NAME);
|
||||
assertThat(descriptor.getDescription()).isEqualTo(DESCRIPTION);
|
||||
assertThat(descriptor.getUnit()).isEqualTo(UNIT);
|
||||
assertThat(descriptor.getType()).isEqualTo(TYPE);
|
||||
assertThat(descriptor.getConstantLabels().size()).isEqualTo(1);
|
||||
assertThat(descriptor.getConstantLabels().get(KEY)).isEqualTo(VALUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void create_NullName() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> Descriptor.create(null, DESCRIPTION, UNIT, TYPE, Labels.of(KEY, VALUE)),
|
||||
"name");
|
||||
NullPointerException.class, () -> Descriptor.create(null, DESCRIPTION, UNIT, TYPE), "name");
|
||||
}
|
||||
|
||||
@Test
|
||||
void create_NullDescription() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> Descriptor.create(METRIC_NAME, null, UNIT, TYPE, Labels.of(KEY, VALUE)),
|
||||
() -> Descriptor.create(METRIC_NAME, null, UNIT, TYPE),
|
||||
"description");
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +57,7 @@ class MetricDataDescriptorTest {
|
|||
void create_NullUnit() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> Descriptor.create(METRIC_NAME, DESCRIPTION, null, TYPE, Labels.of(KEY, VALUE)),
|
||||
() -> Descriptor.create(METRIC_NAME, DESCRIPTION, null, TYPE),
|
||||
"unit");
|
||||
}
|
||||
|
||||
|
|
@ -73,15 +65,7 @@ class MetricDataDescriptorTest {
|
|||
void create_NullType() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> Descriptor.create(METRIC_NAME, DESCRIPTION, UNIT, null, Labels.of(KEY, VALUE)),
|
||||
() -> Descriptor.create(METRIC_NAME, DESCRIPTION, UNIT, null),
|
||||
"type");
|
||||
}
|
||||
|
||||
@Test
|
||||
void create_NullConstantLabels() {
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> Descriptor.create(METRIC_NAME, DESCRIPTION, UNIT, TYPE, null),
|
||||
"constantLabels");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,19 +37,10 @@ import org.junit.jupiter.api.Test;
|
|||
class MetricDataTest {
|
||||
|
||||
private static final Descriptor LONG_METRIC_DESCRIPTOR =
|
||||
Descriptor.create(
|
||||
"metric_name",
|
||||
"metric_description",
|
||||
"ms",
|
||||
Descriptor.Type.MONOTONIC_LONG,
|
||||
Labels.of("key_const", "value_const"));
|
||||
Descriptor.create("metric_name", "metric_description", "ms", Descriptor.Type.MONOTONIC_LONG);
|
||||
private static final Descriptor DOUBLE_METRIC_DESCRIPTOR =
|
||||
Descriptor.create(
|
||||
"metric_name",
|
||||
"metric_description",
|
||||
"ms",
|
||||
Descriptor.Type.NON_MONOTONIC_DOUBLE,
|
||||
Labels.of("key_const", "value_const"));
|
||||
"metric_name", "metric_description", "ms", Descriptor.Type.NON_MONOTONIC_DOUBLE);
|
||||
private static final long START_EPOCH_NANOS = TimeUnit.MILLISECONDS.toNanos(1000);
|
||||
private static final long EPOCH_NANOS = TimeUnit.MILLISECONDS.toNanos(2000);
|
||||
private static final long LONG_VALUE = 10;
|
||||
|
|
|
|||
|
|
@ -48,11 +48,7 @@ import org.mockito.MockitoAnnotations;
|
|||
class IntervalMetricReaderTest {
|
||||
private static final MetricData.Descriptor METRIC_DESCRIPTOR =
|
||||
MetricData.Descriptor.create(
|
||||
"my metric",
|
||||
"my metric description",
|
||||
"us",
|
||||
Descriptor.Type.MONOTONIC_LONG,
|
||||
Labels.empty());
|
||||
"my metric", "my metric description", "us", Descriptor.Type.MONOTONIC_LONG);
|
||||
|
||||
private static final List<Point> LONG_POINT_LIST =
|
||||
Collections.singletonList(LongPoint.create(1000, 3000, Labels.empty(), 1234567));
|
||||
|
|
|
|||
|
|
@ -150,11 +150,21 @@ public final class BatchSpanProcessor implements SpanProcessor {
|
|||
.setDescription(
|
||||
"The number of spans processed by the BatchSpanProcessor. "
|
||||
+ "[dropped=true if they were dropped due to high throughput]")
|
||||
.setConstantLabels(
|
||||
Labels.of("spanProcessorType", BatchSpanProcessor.class.getSimpleName()))
|
||||
.build();
|
||||
droppedSpans = processedSpansCounter.bind(Labels.of("dropped", "true"));
|
||||
exportedSpans = processedSpansCounter.bind(Labels.of("dropped", "false"));
|
||||
droppedSpans =
|
||||
processedSpansCounter.bind(
|
||||
Labels.of(
|
||||
"spanProcessorType",
|
||||
BatchSpanProcessor.class.getSimpleName(),
|
||||
"dropped",
|
||||
"true"));
|
||||
exportedSpans =
|
||||
processedSpansCounter.bind(
|
||||
Labels.of(
|
||||
"spanProcessorType",
|
||||
BatchSpanProcessor.class.getSimpleName(),
|
||||
"dropped",
|
||||
"false"));
|
||||
}
|
||||
|
||||
private static final BoundLongCounter droppedSpans;
|
||||
|
|
|
|||
Loading…
Reference in New Issue