diff --git a/sdk/src/main/java/io/opentelemetry/sdk/common/InstrumentationLibraryInfo.java b/sdk/src/main/java/io/opentelemetry/sdk/common/InstrumentationLibraryInfo.java index 89f4f039a6b..329ba8e7e99 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/common/InstrumentationLibraryInfo.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/common/InstrumentationLibraryInfo.java @@ -29,7 +29,7 @@ @AutoValue @Immutable public abstract class InstrumentationLibraryInfo { - public static final InstrumentationLibraryInfo EMPTY = create("", null); + private static final InstrumentationLibraryInfo EMPTY = create("", null); /** * Creates a new instance of {@link InstrumentationLibraryInfo}. @@ -43,8 +43,27 @@ public static InstrumentationLibraryInfo create(String name, @Nullable String ve return new AutoValue_InstrumentationLibraryInfo(name, version); } + /** + * Returns an "empty" {@code InstrumentationLibraryInfo}. + * + * @return an "empty" {@code InstrumentationLibraryInfo}. + */ + public static InstrumentationLibraryInfo getEmpty() { + return EMPTY; + } + + /** + * Returns the name of the instrumentation library. + * + * @return the name of the instrumentation library. + */ public abstract String getName(); + /** + * Returns the version of the instrumentation library, or {@code null} if not available. + * + * @return the version of the instrumentation library, or {@code null} if not available. + */ @Nullable public abstract String getVersion(); diff --git a/sdk/src/main/java/io/opentelemetry/sdk/trace/data/SpanData.java b/sdk/src/main/java/io/opentelemetry/sdk/trace/data/SpanData.java index 1bf0ed434f3..f27abf5abc4 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/trace/data/SpanData.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/trace/data/SpanData.java @@ -292,7 +292,7 @@ public static TimedEvent create( public static Builder newBuilder() { return new AutoValue_SpanData.Builder() .setParentSpanId(SpanId.getInvalid()) - .setInstrumentationLibraryInfo(InstrumentationLibraryInfo.EMPTY) + .setInstrumentationLibraryInfo(InstrumentationLibraryInfo.getEmpty()) .setLinks(Collections.emptyList()) .setTotalRecordedLinks(0) .setAttributes(Collections.emptyMap()) diff --git a/sdk/src/test/java/io/opentelemetry/sdk/common/InstrumentationLibraryInfoTest.java b/sdk/src/test/java/io/opentelemetry/sdk/common/InstrumentationLibraryInfoTest.java index 1bbf218bcc7..75d09ea7a1d 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/common/InstrumentationLibraryInfoTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/common/InstrumentationLibraryInfoTest.java @@ -31,8 +31,8 @@ public class InstrumentationLibraryInfoTest { @Test public void emptyLibraryInfo() { - assertThat(InstrumentationLibraryInfo.EMPTY.getName()).isEmpty(); - assertThat(InstrumentationLibraryInfo.EMPTY.getVersion()).isNull(); + assertThat(InstrumentationLibraryInfo.getEmpty().getName()).isEmpty(); + assertThat(InstrumentationLibraryInfo.getEmpty().getVersion()).isNull(); } @Test 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 654789e988f..41268071369 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractCounterBuilderTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractCounterBuilderTest.java @@ -41,7 +41,7 @@ public class AbstractCounterBuilderTest { private static final MeterProviderSharedState METER_SHARED_STATE = MeterProviderSharedState.create(TestClock.create(), Resource.getEmpty()); private static final InstrumentationLibraryInfo INSTRUMENTATION_LIBRARY_INFO = - InstrumentationLibraryInfo.EMPTY; + InstrumentationLibraryInfo.getEmpty(); @Test public void defaultValue() { diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractInstrumentBuilderTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractInstrumentBuilderTest.java index d280cfa9b35..430a50a657e 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractInstrumentBuilderTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractInstrumentBuilderTest.java @@ -46,7 +46,7 @@ public class AbstractInstrumentBuilderTest { private static final MeterProviderSharedState METER_SHARED_STATE = MeterProviderSharedState.create(TestClock.create(), Resource.getEmpty()); private static final InstrumentationLibraryInfo INSTRUMENTATION_LIBRARY_INFO = - InstrumentationLibraryInfo.EMPTY; + InstrumentationLibraryInfo.getEmpty(); @Test public void preventNull_Name() { 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 3b89b311fe6..b75e7c3bbdb 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractMeasureBuilderTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractMeasureBuilderTest.java @@ -41,7 +41,7 @@ public class AbstractMeasureBuilderTest { private static final MeterProviderSharedState METER_SHARED_STATE = MeterProviderSharedState.create(TestClock.create(), Resource.getEmpty()); private static final InstrumentationLibraryInfo INSTRUMENTATION_LIBRARY_INFO = - InstrumentationLibraryInfo.EMPTY; + InstrumentationLibraryInfo.getEmpty(); @Test public void defaultValue() { diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractObserverBuilderTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractObserverBuilderTest.java index 3522a3c3b47..9046a65b190 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractObserverBuilderTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/AbstractObserverBuilderTest.java @@ -38,7 +38,7 @@ public class AbstractObserverBuilderTest { private static final MeterProviderSharedState METER_SHARED_STATE = MeterProviderSharedState.create(TestClock.create(), Resource.getEmpty()); private static final InstrumentationLibraryInfo INSTRUMENTATION_LIBRARY_INFO = - InstrumentationLibraryInfo.EMPTY; + InstrumentationLibraryInfo.getEmpty(); @Test public void defaultValue() { diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/data/MetricDataTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/data/MetricDataTest.java index 12fbe32ba5c..a6ed4e96e59 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/data/MetricDataTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/data/MetricDataTest.java @@ -69,7 +69,7 @@ public void metricData_NullDescriptor() { MetricData.create( null, Resource.getEmpty(), - InstrumentationLibraryInfo.EMPTY, + InstrumentationLibraryInfo.getEmpty(), Collections.singletonList(DOUBLE_POINT)); } @@ -80,7 +80,7 @@ public void metricData_NullResource() { MetricData.create( LONG_METRIC_DESCRIPTOR, null, - InstrumentationLibraryInfo.EMPTY, + InstrumentationLibraryInfo.getEmpty(), Collections.singletonList(DOUBLE_POINT)); } @@ -100,7 +100,7 @@ public void metricData_NullPoints() { thrown.expect(NullPointerException.class); thrown.expectMessage("points"); MetricData.create( - LONG_METRIC_DESCRIPTOR, Resource.getEmpty(), InstrumentationLibraryInfo.EMPTY, null); + LONG_METRIC_DESCRIPTOR, Resource.getEmpty(), InstrumentationLibraryInfo.getEmpty(), null); } @Test @@ -109,12 +109,12 @@ public void metricData_Getters() { MetricData.create( LONG_METRIC_DESCRIPTOR, Resource.getEmpty(), - InstrumentationLibraryInfo.EMPTY, + InstrumentationLibraryInfo.getEmpty(), Collections.emptyList()); assertThat(metricData.getDescriptor()).isEqualTo(LONG_METRIC_DESCRIPTOR); assertThat(metricData.getResource()).isEqualTo(Resource.getEmpty()); assertThat(metricData.getInstrumentationLibraryInfo()) - .isEqualTo(InstrumentationLibraryInfo.EMPTY); + .isEqualTo(InstrumentationLibraryInfo.getEmpty()); assertThat(metricData.getPoints()).isEmpty(); } @@ -128,7 +128,7 @@ public void metricData_LongPoints() { MetricData.create( LONG_METRIC_DESCRIPTOR, Resource.getEmpty(), - InstrumentationLibraryInfo.EMPTY, + InstrumentationLibraryInfo.getEmpty(), Collections.singletonList(LONG_POINT)); assertThat(metricData.getPoints()).containsExactly(LONG_POINT); } @@ -143,7 +143,7 @@ public void metricData_DoublePoints() { MetricData.create( DOUBLE_METRIC_DESCRIPTOR, Resource.getEmpty(), - InstrumentationLibraryInfo.EMPTY, + InstrumentationLibraryInfo.getEmpty(), Collections.singletonList(DOUBLE_POINT)); assertThat(metricData.getPoints()).containsExactly(DOUBLE_POINT); } diff --git a/sdk/src/test/java/io/opentelemetry/sdk/trace/data/SpanDataTest.java b/sdk/src/test/java/io/opentelemetry/sdk/trace/data/SpanDataTest.java index eef5ac5c9d1..869741e14df 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/trace/data/SpanDataTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/trace/data/SpanDataTest.java @@ -57,7 +57,7 @@ public void defaultValues() { assertThat(spanData.getTimedEvents()).isEqualTo(emptyList()); assertThat(spanData.getLinks()).isEqualTo(emptyList()); assertThat(spanData.getInstrumentationLibraryInfo()) - .isSameInstanceAs(InstrumentationLibraryInfo.EMPTY); + .isSameInstanceAs(InstrumentationLibraryInfo.getEmpty()); assertThat(spanData.getHasRemoteParent()).isFalse(); }