From 9105765b55ceb3b024b85c0abe64f2bffdcfd7a8 Mon Sep 17 00:00:00 2001 From: Bogdan Cristian Drutu Date: Fri, 7 Feb 2020 11:12:24 -0800 Subject: [PATCH 1/2] Move unbind to the Bound to simplify usage Signed-off-by: Bogdan Cristian Drutu --- .../io/opentelemetry/metrics/Counter.java | 2 +- .../opentelemetry/metrics/DefaultMeter.java | 32 +++++++------------ .../opentelemetry/metrics/DoubleCounter.java | 8 ++--- .../opentelemetry/metrics/DoubleMeasure.java | 8 ++--- ...thBinding.java => InstrumentWithBind.java} | 23 +++++++------ .../io/opentelemetry/metrics/LongCounter.java | 8 ++--- .../io/opentelemetry/metrics/LongMeasure.java | 8 ++--- .../io/opentelemetry/metrics/Measure.java | 2 +- .../metrics/DoubleCounterTest.java | 14 -------- .../metrics/LongCounterTest.java | 14 -------- .../sdk/metrics/AbstractBoundInstrument.java | 6 +++- .../sdk/metrics/DoubleCounterSdk.java | 5 --- .../sdk/metrics/DoubleMeasureSdk.java | 5 --- .../sdk/metrics/LongCounterSdk.java | 5 --- .../sdk/metrics/LongMeasureSdk.java | 5 --- .../metrics/AbstractCounterBuilderTest.java | 6 ++-- .../metrics/AbstractMeasureBuilderTest.java | 6 ++-- .../sdk/metrics/DoubleCounterSdkTest.java | 2 +- .../sdk/metrics/DoubleMeasureSdkTest.java | 2 +- .../sdk/metrics/LongCounterSdkTest.java | 2 +- .../sdk/metrics/LongMeasureSdkTest.java | 2 +- 21 files changed, 58 insertions(+), 107 deletions(-) rename api/src/main/java/io/opentelemetry/metrics/{InstrumentWithBinding.java => InstrumentWithBind.java} (77%) diff --git a/api/src/main/java/io/opentelemetry/metrics/Counter.java b/api/src/main/java/io/opentelemetry/metrics/Counter.java index 5fd895f2ee7..1cb4c725aed 100644 --- a/api/src/main/java/io/opentelemetry/metrics/Counter.java +++ b/api/src/main/java/io/opentelemetry/metrics/Counter.java @@ -22,7 +22,7 @@ * @param the Bound Counter type. * @since 0.1.0 */ -public interface Counter extends InstrumentWithBinding { +public interface Counter extends InstrumentWithBind { /** Builder class for {@link Counter}. */ interface Builder, V> extends Instrument.Builder { diff --git a/api/src/main/java/io/opentelemetry/metrics/DefaultMeter.java b/api/src/main/java/io/opentelemetry/metrics/DefaultMeter.java index 70fc486e882..549e8955ade 100644 --- a/api/src/main/java/io/opentelemetry/metrics/DefaultMeter.java +++ b/api/src/main/java/io/opentelemetry/metrics/DefaultMeter.java @@ -141,11 +141,6 @@ public NoopBoundDoubleCounter bind(LabelSet labelSet) { return NoopBoundDoubleCounter.INSTANCE; } - @Override - public void unbind(BoundDoubleCounter boundInstrument) { - Utils.checkNotNull(boundInstrument, "boundDoubleCounter"); - } - /** No-op implementation of BoundDoubleCounter interface. */ @Immutable private enum NoopBoundDoubleCounter implements BoundDoubleCounter { @@ -153,6 +148,9 @@ private enum NoopBoundDoubleCounter implements BoundDoubleCounter { @Override public void add(double delta) {} + + @Override + public void unbind() {} } private static final class NoopBuilder @@ -186,11 +184,6 @@ public NoopBoundLongCounter bind(LabelSet labelSet) { return NoopBoundLongCounter.INSTANCE; } - @Override - public void unbind(BoundLongCounter boundInstrument) { - Utils.checkNotNull(boundInstrument, "boundLongCounter"); - } - /** No-op implementation of BoundLongCounter interface. */ @Immutable private enum NoopBoundLongCounter implements BoundLongCounter { @@ -198,6 +191,9 @@ private enum NoopBoundLongCounter implements BoundLongCounter { @Override public void add(long delta) {} + + @Override + public void unbind() {} } private static final class NoopBuilder extends NoopAbstractCounterBuilder @@ -232,11 +228,6 @@ public NoopBoundDoubleMeasure bind(LabelSet labelSet) { return NoopBoundDoubleMeasure.INSTANCE; } - @Override - public void unbind(BoundDoubleMeasure boundInstrument) { - Utils.checkNotNull(boundInstrument, "boundDoubleMeasure"); - } - /** No-op implementation of BoundDoubleMeasure interface. */ @Immutable private enum NoopBoundDoubleMeasure implements BoundDoubleMeasure { @@ -246,6 +237,9 @@ private enum NoopBoundDoubleMeasure implements BoundDoubleMeasure { public void record(double value) { Utils.checkArgument(value >= 0.0, "Unsupported negative values."); } + + @Override + public void unbind() {} } private static final class NoopBuilder @@ -284,11 +278,6 @@ public NoopBoundLongMeasure bind(LabelSet labelSet) { return NoopBoundLongMeasure.INSTANCE; } - @Override - public void unbind(BoundLongMeasure boundInstrument) { - Utils.checkNotNull(boundInstrument, "boundLongMeasure"); - } - /** No-op implementations of BoundLongMeasure interface. */ @Immutable private enum NoopBoundLongMeasure implements BoundLongMeasure { @@ -298,6 +287,9 @@ private enum NoopBoundLongMeasure implements BoundLongMeasure { public void record(long value) { Utils.checkArgument(value >= 0, "Unsupported negative values."); } + + @Override + public void unbind() {} } private static final class NoopBuilder diff --git a/api/src/main/java/io/opentelemetry/metrics/DoubleCounter.java b/api/src/main/java/io/opentelemetry/metrics/DoubleCounter.java index 5a031a82098..f8000059033 100644 --- a/api/src/main/java/io/opentelemetry/metrics/DoubleCounter.java +++ b/api/src/main/java/io/opentelemetry/metrics/DoubleCounter.java @@ -67,16 +67,13 @@ public interface DoubleCounter extends Counter { @Override BoundDoubleCounter bind(LabelSet labelSet); - @Override - void unbind(BoundDoubleCounter boundInstrument); - /** * A {@code Bound Instrument} for a {@code CounterDouble}. * * @since 0.1.0 */ @ThreadSafe - interface BoundDoubleCounter { + interface BoundDoubleCounter extends Counter.Bound { /** * Adds the given {@code delta} to the current value. The values can be negative iff monotonic * was set to {@code false}. @@ -87,6 +84,9 @@ interface BoundDoubleCounter { * @since 0.1.0 */ void add(double delta); + + @Override + void unbind(); } /** Builder class for {@link DoubleCounter}. */ diff --git a/api/src/main/java/io/opentelemetry/metrics/DoubleMeasure.java b/api/src/main/java/io/opentelemetry/metrics/DoubleMeasure.java index 6ef7f31e0a1..45ae8041b45 100644 --- a/api/src/main/java/io/opentelemetry/metrics/DoubleMeasure.java +++ b/api/src/main/java/io/opentelemetry/metrics/DoubleMeasure.java @@ -63,16 +63,13 @@ public interface DoubleMeasure extends Measure { @Override BoundDoubleMeasure bind(LabelSet labelSet); - @Override - void unbind(BoundDoubleMeasure boundInstrument); - /** * A {@code Bound Instrument} for a {@code LongMeasure}. * * @since 0.1.0 */ @ThreadSafe - interface BoundDoubleMeasure { + interface BoundDoubleMeasure extends Measure.Bound { /** * Records the given measurement, associated with the current {@code Context}. * @@ -81,6 +78,9 @@ interface BoundDoubleMeasure { * @since 0.1.0 */ void record(double value); + + @Override + void unbind(); } /** Builder class for {@link DoubleMeasure}. */ diff --git a/api/src/main/java/io/opentelemetry/metrics/InstrumentWithBinding.java b/api/src/main/java/io/opentelemetry/metrics/InstrumentWithBind.java similarity index 77% rename from api/src/main/java/io/opentelemetry/metrics/InstrumentWithBinding.java rename to api/src/main/java/io/opentelemetry/metrics/InstrumentWithBind.java index e016da1c7d6..2e36fe4eb8d 100644 --- a/api/src/main/java/io/opentelemetry/metrics/InstrumentWithBinding.java +++ b/api/src/main/java/io/opentelemetry/metrics/InstrumentWithBind.java @@ -20,9 +20,9 @@ * Base interface for all metrics with bounds defined in this package. * * @param the specific type of Bound Instrument this instrument can provide. - * @since 0.1.0 + * @since 0.3.0 */ -public interface InstrumentWithBinding extends Instrument { +public interface InstrumentWithBind extends Instrument { /** * Returns a {@code Bound Instrument} associated with the specified {@code labelSet}. Multiples * requests with the same {@code labelSet} may return the same {@code Bound Instrument} instance. @@ -37,12 +37,15 @@ public interface InstrumentWithBinding extends Instrument { */ B bind(LabelSet labelSet); - /** - * Removes the {@code Bound Instrument} from the Instrument. i.e. references to previous {@code - * Bound Instrument} are invalid (not being managed by the instrument). - * - * @param boundInstrument the {@code Bound Instrument} to be removed. - * @since 0.1.0 - */ - void unbind(B boundInstrument); + interface Bound { + /** + * Unbinds the current {@code Bound} from the Instrument. + * + *

After this method returns the current instance {@code Bound} is considered invalid (not + * being managed by the instrument). + * + * @since 0.3.0 + */ + void unbind(); + } } diff --git a/api/src/main/java/io/opentelemetry/metrics/LongCounter.java b/api/src/main/java/io/opentelemetry/metrics/LongCounter.java index f7a596a4a4c..edbf21339ba 100644 --- a/api/src/main/java/io/opentelemetry/metrics/LongCounter.java +++ b/api/src/main/java/io/opentelemetry/metrics/LongCounter.java @@ -67,16 +67,13 @@ public interface LongCounter extends Counter { @Override BoundLongCounter bind(LabelSet labelSet); - @Override - void unbind(BoundLongCounter boundInstrument); - /** * A {@code Bound Instrument} for a {@code LongCounter}. * * @since 0.1.0 */ @ThreadSafe - interface BoundLongCounter { + interface BoundLongCounter extends Counter.Bound { /** * Adds the given {@code delta} to the current value. The values can be negative iff monotonic @@ -88,6 +85,9 @@ interface BoundLongCounter { * @since 0.1.0 */ void add(long delta); + + @Override + void unbind(); } /** Builder class for {@link LongCounter}. */ diff --git a/api/src/main/java/io/opentelemetry/metrics/LongMeasure.java b/api/src/main/java/io/opentelemetry/metrics/LongMeasure.java index 1227ad2f739..e1f144d5cdc 100644 --- a/api/src/main/java/io/opentelemetry/metrics/LongMeasure.java +++ b/api/src/main/java/io/opentelemetry/metrics/LongMeasure.java @@ -63,16 +63,13 @@ public interface LongMeasure extends Measure { @Override BoundLongMeasure bind(LabelSet labelSet); - @Override - void unbind(BoundLongMeasure boundInstrument); - /** * A {@code Bound Instrument} for a {@code LongMeasure}. * * @since 0.1.0 */ @ThreadSafe - interface BoundLongMeasure { + interface BoundLongMeasure extends Measure.Bound { /** * Records the given measurement, associated with the current {@code Context}. * @@ -81,6 +78,9 @@ interface BoundLongMeasure { * @since 0.1.0 */ void record(long value); + + @Override + void unbind(); } /** Builder class for {@link LongMeasure}. */ diff --git a/api/src/main/java/io/opentelemetry/metrics/Measure.java b/api/src/main/java/io/opentelemetry/metrics/Measure.java index 936817dad63..c5c31905f89 100644 --- a/api/src/main/java/io/opentelemetry/metrics/Measure.java +++ b/api/src/main/java/io/opentelemetry/metrics/Measure.java @@ -22,7 +22,7 @@ * @param the Bound Instrument type. * @since 0.1.0 */ -public interface Measure extends InstrumentWithBinding { +public interface Measure extends InstrumentWithBind { /** Builder class for {@link Measure}. */ interface Builder, V> extends Instrument.Builder { diff --git a/api/src/test/java/io/opentelemetry/metrics/DoubleCounterTest.java b/api/src/test/java/io/opentelemetry/metrics/DoubleCounterTest.java index d813f25f200..58842f2e660 100644 --- a/api/src/test/java/io/opentelemetry/metrics/DoubleCounterTest.java +++ b/api/src/test/java/io/opentelemetry/metrics/DoubleCounterTest.java @@ -107,20 +107,6 @@ public void noopBind_WithNullLabelSet() { doubleCounter.bind(null); } - @Test - public void noopUnbind_WithNullInstrument() { - DoubleCounter doubleCounter = - meter - .doubleCounterBuilder(NAME) - .setDescription(DESCRIPTION) - .setLabelKeys(LABEL_KEY) - .setUnit(UNIT) - .build(); - thrown.expect(NullPointerException.class); - thrown.expectMessage("boundDoubleCounter"); - doubleCounter.unbind(null); - } - @Test public void doesNotThrow() { DoubleCounter doubleCounter = diff --git a/api/src/test/java/io/opentelemetry/metrics/LongCounterTest.java b/api/src/test/java/io/opentelemetry/metrics/LongCounterTest.java index fc9d4f02716..dc4d9528b69 100644 --- a/api/src/test/java/io/opentelemetry/metrics/LongCounterTest.java +++ b/api/src/test/java/io/opentelemetry/metrics/LongCounterTest.java @@ -106,20 +106,6 @@ public void noopBind_WithNullLabelSet() { longCounter.bind(null); } - @Test - public void noopUnbind_WithNullInstrument() { - LongCounter longCounter = - meter - .longCounterBuilder(NAME) - .setDescription(DESCRIPTION) - .setLabelKeys(LABEL_KEY) - .setUnit(UNIT) - .build(); - thrown.expect(NullPointerException.class); - thrown.expectMessage("boundLongCounter"); - longCounter.unbind(null); - } - @Test public void doesNotThrow() { LongCounter longCounter = diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/AbstractBoundInstrument.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/AbstractBoundInstrument.java index d907c5e7b97..4706dbb64fb 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/AbstractBoundInstrument.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/AbstractBoundInstrument.java @@ -16,9 +16,10 @@ package io.opentelemetry.sdk.metrics; +import io.opentelemetry.metrics.InstrumentWithBind.Bound; import io.opentelemetry.metrics.LabelSet; -class AbstractBoundInstrument { +abstract class AbstractBoundInstrument implements Bound { private final LabelSet labels; AbstractBoundInstrument(LabelSet labels) { @@ -26,6 +27,9 @@ class AbstractBoundInstrument { // todo: associate with an aggregator/accumulator } + @Override + public void unbind() {} + @Override public boolean equals(Object o) { if (this == o) { diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java index 984c214fd6d..1ec6c2c2ee8 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java @@ -46,11 +46,6 @@ public BoundDoubleCounter bind(LabelSet labelSet) { return new Bound(labelSet, monotonic); } - @Override - public void unbind(BoundDoubleCounter boundInstrument) { - // TODO: Implement this. - } - @Override public boolean equals(Object o) { if (this == o) { diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java index b1693715fc1..4bc6b5c4c3e 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java @@ -46,11 +46,6 @@ public BoundDoubleMeasure bind(LabelSet labelSet) { return new Bound(labelSet, this.absolute); } - @Override - public void unbind(BoundDoubleMeasure boundInstrument) { - // TODO: Implement this. - } - @Override public boolean equals(Object o) { if (this == o) { diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java index c2227f8a5f4..30aca7565fc 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java @@ -46,11 +46,6 @@ public BoundLongCounter bind(LabelSet labelSet) { return new Bound(labelSet, monotonic); } - @Override - public void unbind(BoundLongCounter boundInstrument) { - // TODO: Implement this. - } - @Override public boolean equals(Object o) { if (this == o) { diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java index 2f018609d3f..bde870804e5 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java @@ -46,11 +46,6 @@ public BoundLongMeasure bind(LabelSet labelSet) { return new Bound(labelSet, this.absolute); } - @Override - public void unbind(BoundLongMeasure boundInstrument) { - // TODO: Implement this. - } - @Override public boolean equals(Object o) { if (this == o) { diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractCounterBuilderTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractCounterBuilderTest.java index 3d178f4cad3..4f1b7bb7dbd 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractCounterBuilderTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractCounterBuilderTest.java @@ -82,10 +82,10 @@ private static final class TestInstrument implements Counter { public TestBound bind(LabelSet labelSet) { return HANDLE; } + } + private static final class TestBound implements Counter.Bound { @Override - public void unbind(TestBound boundInstrument) {} + public void unbind() {} } - - private static final class TestBound {} } diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractMeasureBuilderTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractMeasureBuilderTest.java index 09199670904..341dd04f819 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractMeasureBuilderTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractMeasureBuilderTest.java @@ -82,10 +82,10 @@ private static final class TestInstrument implements Measure { public TestBoundMeasure bind(LabelSet labelSet) { return HANDLE; } + } + private static final class TestBoundMeasure implements Measure.Bound { @Override - public void unbind(TestBoundMeasure boundInstrument) {} + public void unbind() {} } - - private static final class TestBoundMeasure {} } diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/DoubleCounterSdkTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/DoubleCounterSdkTest.java index 0fd537cb9d2..8b01930df3b 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/DoubleCounterSdkTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/DoubleCounterSdkTest.java @@ -58,7 +58,7 @@ public void testDoubleCounter() { assertThat(duplicateBoundCounter).isEqualTo(boundDoubleCounter); // todo: verify that this has done something, when it has been done. - doubleCounter.unbind(boundDoubleCounter); + boundDoubleCounter.unbind(); } @Test diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdkTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdkTest.java index a49c8a100e8..1ba47cf959d 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdkTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdkTest.java @@ -58,7 +58,7 @@ public void testDoubleMeasure() { assertThat(duplicateBoundMeasure).isEqualTo(boundDoubleMeasure); // todo: verify that this has done something, when it has been done. - doubleMeasure.unbind(boundDoubleMeasure); + boundDoubleMeasure.unbind(); } @Test diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/LongCounterSdkTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/LongCounterSdkTest.java index b37444f89b0..0db33f3a5ed 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/LongCounterSdkTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/LongCounterSdkTest.java @@ -58,7 +58,7 @@ public void testLongCounter() { assertThat(duplicateBoundCounter).isEqualTo(boundLongCounter); // todo: verify that this has done something, when it has been done. - longCounter.unbind(boundLongCounter); + boundLongCounter.unbind(); } @Test diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/LongMeasureSdkTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/LongMeasureSdkTest.java index 2cd88723349..b8635948f99 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/LongMeasureSdkTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/LongMeasureSdkTest.java @@ -58,7 +58,7 @@ public void testLongMeasure() { assertThat(duplicateBoundMeasure).isEqualTo(boundLongMeasure); // todo: verify that this has done something, when it has been done. - longMeasure.unbind(boundLongMeasure); + boundLongMeasure.unbind(); } @Test From aea04c965bc255d1805963b88bb82ff9c706f500 Mon Sep 17 00:00:00 2001 From: Bogdan Cristian Drutu Date: Fri, 7 Feb 2020 12:53:26 -0800 Subject: [PATCH 2/2] Change names to be English friendly Signed-off-by: Bogdan Cristian Drutu --- api/src/main/java/io/opentelemetry/metrics/Counter.java | 4 +++- .../java/io/opentelemetry/metrics/DoubleCounter.java | 2 +- .../java/io/opentelemetry/metrics/DoubleMeasure.java | 2 +- ...nstrumentWithBind.java => InstrumentWithBinding.java} | 6 ++++-- .../main/java/io/opentelemetry/metrics/LongCounter.java | 2 +- .../main/java/io/opentelemetry/metrics/LongMeasure.java | 2 +- api/src/main/java/io/opentelemetry/metrics/Measure.java | 4 +++- .../sdk/metrics/AbstractBoundInstrument.java | 4 ++-- .../io/opentelemetry/sdk/metrics/DoubleCounterSdk.java | 7 ++++--- .../io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java | 7 ++++--- .../io/opentelemetry/sdk/metrics/LongCounterSdk.java | 7 ++++--- .../io/opentelemetry/sdk/metrics/LongMeasureSdk.java | 7 ++++--- .../sdk/metrics/AbstractCounterBuilderTest.java | 9 +++++---- .../sdk/metrics/AbstractMeasureBuilderTest.java | 3 ++- 14 files changed, 39 insertions(+), 27 deletions(-) rename api/src/main/java/io/opentelemetry/metrics/{InstrumentWithBind.java => InstrumentWithBinding.java} (89%) diff --git a/api/src/main/java/io/opentelemetry/metrics/Counter.java b/api/src/main/java/io/opentelemetry/metrics/Counter.java index 1cb4c725aed..aeac50a1d03 100644 --- a/api/src/main/java/io/opentelemetry/metrics/Counter.java +++ b/api/src/main/java/io/opentelemetry/metrics/Counter.java @@ -16,13 +16,15 @@ package io.opentelemetry.metrics; +import io.opentelemetry.metrics.InstrumentWithBinding.BoundInstrument; + /** * Base interface for all the Counter metrics. * * @param the Bound Counter type. * @since 0.1.0 */ -public interface Counter extends InstrumentWithBind { +public interface Counter extends InstrumentWithBinding { /** Builder class for {@link Counter}. */ interface Builder, V> extends Instrument.Builder { diff --git a/api/src/main/java/io/opentelemetry/metrics/DoubleCounter.java b/api/src/main/java/io/opentelemetry/metrics/DoubleCounter.java index f8000059033..8bcd19d42a5 100644 --- a/api/src/main/java/io/opentelemetry/metrics/DoubleCounter.java +++ b/api/src/main/java/io/opentelemetry/metrics/DoubleCounter.java @@ -73,7 +73,7 @@ public interface DoubleCounter extends Counter { * @since 0.1.0 */ @ThreadSafe - interface BoundDoubleCounter extends Counter.Bound { + interface BoundDoubleCounter extends BoundInstrument { /** * Adds the given {@code delta} to the current value. The values can be negative iff monotonic * was set to {@code false}. diff --git a/api/src/main/java/io/opentelemetry/metrics/DoubleMeasure.java b/api/src/main/java/io/opentelemetry/metrics/DoubleMeasure.java index 45ae8041b45..e3045ea6cf3 100644 --- a/api/src/main/java/io/opentelemetry/metrics/DoubleMeasure.java +++ b/api/src/main/java/io/opentelemetry/metrics/DoubleMeasure.java @@ -69,7 +69,7 @@ public interface DoubleMeasure extends Measure { * @since 0.1.0 */ @ThreadSafe - interface BoundDoubleMeasure extends Measure.Bound { + interface BoundDoubleMeasure extends BoundInstrument { /** * Records the given measurement, associated with the current {@code Context}. * diff --git a/api/src/main/java/io/opentelemetry/metrics/InstrumentWithBind.java b/api/src/main/java/io/opentelemetry/metrics/InstrumentWithBinding.java similarity index 89% rename from api/src/main/java/io/opentelemetry/metrics/InstrumentWithBind.java rename to api/src/main/java/io/opentelemetry/metrics/InstrumentWithBinding.java index 2e36fe4eb8d..65a623b8f28 100644 --- a/api/src/main/java/io/opentelemetry/metrics/InstrumentWithBind.java +++ b/api/src/main/java/io/opentelemetry/metrics/InstrumentWithBinding.java @@ -16,13 +16,15 @@ package io.opentelemetry.metrics; +import io.opentelemetry.metrics.InstrumentWithBinding.BoundInstrument; + /** * Base interface for all metrics with bounds defined in this package. * * @param the specific type of Bound Instrument this instrument can provide. * @since 0.3.0 */ -public interface InstrumentWithBind extends Instrument { +public interface InstrumentWithBinding extends Instrument { /** * Returns a {@code Bound Instrument} associated with the specified {@code labelSet}. Multiples * requests with the same {@code labelSet} may return the same {@code Bound Instrument} instance. @@ -37,7 +39,7 @@ public interface InstrumentWithBind extends */ B bind(LabelSet labelSet); - interface Bound { + interface BoundInstrument { /** * Unbinds the current {@code Bound} from the Instrument. * diff --git a/api/src/main/java/io/opentelemetry/metrics/LongCounter.java b/api/src/main/java/io/opentelemetry/metrics/LongCounter.java index edbf21339ba..49bbe82144f 100644 --- a/api/src/main/java/io/opentelemetry/metrics/LongCounter.java +++ b/api/src/main/java/io/opentelemetry/metrics/LongCounter.java @@ -73,7 +73,7 @@ public interface LongCounter extends Counter { * @since 0.1.0 */ @ThreadSafe - interface BoundLongCounter extends Counter.Bound { + interface BoundLongCounter extends BoundInstrument { /** * Adds the given {@code delta} to the current value. The values can be negative iff monotonic diff --git a/api/src/main/java/io/opentelemetry/metrics/LongMeasure.java b/api/src/main/java/io/opentelemetry/metrics/LongMeasure.java index e1f144d5cdc..73bf85b643f 100644 --- a/api/src/main/java/io/opentelemetry/metrics/LongMeasure.java +++ b/api/src/main/java/io/opentelemetry/metrics/LongMeasure.java @@ -69,7 +69,7 @@ public interface LongMeasure extends Measure { * @since 0.1.0 */ @ThreadSafe - interface BoundLongMeasure extends Measure.Bound { + interface BoundLongMeasure extends BoundInstrument { /** * Records the given measurement, associated with the current {@code Context}. * diff --git a/api/src/main/java/io/opentelemetry/metrics/Measure.java b/api/src/main/java/io/opentelemetry/metrics/Measure.java index c5c31905f89..656abbb8da9 100644 --- a/api/src/main/java/io/opentelemetry/metrics/Measure.java +++ b/api/src/main/java/io/opentelemetry/metrics/Measure.java @@ -16,13 +16,15 @@ package io.opentelemetry.metrics; +import io.opentelemetry.metrics.InstrumentWithBinding.BoundInstrument; + /** * Base interface for all the Measure instruments. * * @param the Bound Instrument type. * @since 0.1.0 */ -public interface Measure extends InstrumentWithBind { +public interface Measure extends InstrumentWithBinding { /** Builder class for {@link Measure}. */ interface Builder, V> extends Instrument.Builder { diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/AbstractBoundInstrument.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/AbstractBoundInstrument.java index 4706dbb64fb..44cf11dc21b 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/AbstractBoundInstrument.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/AbstractBoundInstrument.java @@ -16,10 +16,10 @@ package io.opentelemetry.sdk.metrics; -import io.opentelemetry.metrics.InstrumentWithBind.Bound; +import io.opentelemetry.metrics.InstrumentWithBinding.BoundInstrument; import io.opentelemetry.metrics.LabelSet; -abstract class AbstractBoundInstrument implements Bound { +abstract class AbstractBoundInstrument implements BoundInstrument { private final LabelSet labels; AbstractBoundInstrument(LabelSet labels) { diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java index 1ec6c2c2ee8..2c4e5aac19a 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java @@ -43,7 +43,7 @@ public void add(double delta, LabelSet labelSet) { @Override public BoundDoubleCounter bind(LabelSet labelSet) { - return new Bound(labelSet, monotonic); + return new BoundInstrument(labelSet, monotonic); } @Override @@ -70,11 +70,12 @@ public int hashCode() { return result; } - private static final class Bound extends AbstractBoundInstrument implements BoundDoubleCounter { + private static final class BoundInstrument extends AbstractBoundInstrument + implements BoundDoubleCounter { private final boolean monotonic; - Bound(LabelSet labels, boolean monotonic) { + BoundInstrument(LabelSet labels, boolean monotonic) { super(labels); this.monotonic = monotonic; } diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java index 4bc6b5c4c3e..e3241385384 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java @@ -43,7 +43,7 @@ public void record(double value, LabelSet labelSet) { @Override public BoundDoubleMeasure bind(LabelSet labelSet) { - return new Bound(labelSet, this.absolute); + return new BoundInstrument(labelSet, this.absolute); } @Override @@ -70,11 +70,12 @@ public int hashCode() { return result; } - private static final class Bound extends AbstractBoundInstrument implements BoundDoubleMeasure { + private static final class BoundInstrument extends AbstractBoundInstrument + implements BoundDoubleMeasure { private final boolean absolute; - Bound(LabelSet labels, boolean absolute) { + BoundInstrument(LabelSet labels, boolean absolute) { super(labels); this.absolute = absolute; } diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java index 30aca7565fc..d9197f9e078 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java @@ -43,7 +43,7 @@ public void add(long delta, LabelSet labelSet) { @Override public BoundLongCounter bind(LabelSet labelSet) { - return new Bound(labelSet, monotonic); + return new BoundInstrument(labelSet, monotonic); } @Override @@ -70,11 +70,12 @@ public int hashCode() { return result; } - private static final class Bound extends AbstractBoundInstrument implements BoundLongCounter { + private static final class BoundInstrument extends AbstractBoundInstrument + implements BoundLongCounter { private final boolean monotonic; - Bound(LabelSet labels, boolean monotonic) { + BoundInstrument(LabelSet labels, boolean monotonic) { super(labels); this.monotonic = monotonic; } diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java index bde870804e5..1f26a5bf287 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java @@ -43,7 +43,7 @@ public void record(long value, LabelSet labelSet) { @Override public BoundLongMeasure bind(LabelSet labelSet) { - return new Bound(labelSet, this.absolute); + return new BoundInstrument(labelSet, this.absolute); } @Override @@ -70,11 +70,12 @@ public int hashCode() { return result; } - private static final class Bound extends AbstractBoundInstrument implements BoundLongMeasure { + private static final class BoundInstrument extends AbstractBoundInstrument + implements BoundLongMeasure { private final boolean absolute; - Bound(LabelSet labels, boolean absolute) { + BoundInstrument(LabelSet labels, boolean absolute) { super(labels); this.absolute = absolute; } diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractCounterBuilderTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractCounterBuilderTest.java index 4f1b7bb7dbd..ffa5e249424 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractCounterBuilderTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractCounterBuilderTest.java @@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat; import io.opentelemetry.metrics.Counter; +import io.opentelemetry.metrics.InstrumentWithBinding.BoundInstrument; import io.opentelemetry.metrics.LabelSet; import org.junit.Rule; import org.junit.Test; @@ -75,16 +76,16 @@ public TestInstrument build() { } } - private static final class TestInstrument implements Counter { - private static final TestBound HANDLE = new TestBound(); + private static final class TestInstrument implements Counter { + private static final TestBoundInstrument HANDLE = new TestBoundInstrument(); @Override - public TestBound bind(LabelSet labelSet) { + public TestBoundInstrument bind(LabelSet labelSet) { return HANDLE; } } - private static final class TestBound implements Counter.Bound { + private static final class TestBoundInstrument implements BoundInstrument { @Override public void unbind() {} } diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractMeasureBuilderTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractMeasureBuilderTest.java index 341dd04f819..fa26877a55b 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractMeasureBuilderTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractMeasureBuilderTest.java @@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat; +import io.opentelemetry.metrics.InstrumentWithBinding.BoundInstrument; import io.opentelemetry.metrics.LabelSet; import io.opentelemetry.metrics.Measure; import org.junit.Rule; @@ -84,7 +85,7 @@ public TestBoundMeasure bind(LabelSet labelSet) { } } - private static final class TestBoundMeasure implements Measure.Bound { + private static final class TestBoundMeasure implements BoundInstrument { @Override public void unbind() {} }