From 2bc88f45c6d1bbfab789544b8a839020bb869390 Mon Sep 17 00:00:00 2001 From: jack-berg <34418638+jack-berg@users.noreply.github.com> Date: Wed, 24 Aug 2022 13:35:31 -0500 Subject: [PATCH] Deprecate multi argument InstrumentationScopeInfo create method (#4710) * Deprecate multi argument InstrumentationScopeInfo create method * PR feedback --- .../opentelemetry-sdk-common.txt | 2 + .../thrift/JaegerThriftSpanExporterTest.java | 12 +++-- .../jaeger/JaegerGrpcSpanExporterTest.java | 12 +++-- .../otlp/OtlpJsonLoggingLogExporterTest.java | 2 +- .../OtlpJsonLoggingMetricExporterTest.java | 2 +- .../otlp/OtlpJsonLoggingSpanExporterTest.java | 2 +- .../logging/LoggingMetricExporterTest.java | 2 +- .../logging/LoggingSpanExporterTest.java | 3 +- .../logging/SystemOutLogExporterTest.java | 3 +- .../http/trace/OtlpHttpSpanExporterTest.java | 5 +- .../otlp/trace/OtlpGrpcSpanExporterTest.java | 5 +- .../trace/OtlpGrpcNettySpanExporterTest.java | 5 +- .../OtlpGrpcNettyShadedSpanExporterTest.java | 5 +- .../trace/OtlpGrpcOkHttpSpanExporterTest.java | 5 +- .../otlp/logs/LogsRequestMarshalerTest.java | 4 +- .../http/logs/OtlpHttpLogExporterTest.java | 5 +- .../otlp/logs/OtlpGrpcLogExporterTest.java | 3 +- .../logs/OtlpGrpcNettyLogExporterTest.java | 3 +- .../OtlpGrpcNettyShadedLogExporterTest.java | 3 +- .../OtlpGrpcNettyOkHttpLogExporterTest.java | 3 +- .../prometheus/MetricAdapterTest.java | 24 ++++----- .../prometheus/PrometheusCollectorTest.java | 4 +- .../prometheus/PrometheusHttpServerTest.java | 4 +- .../exporter/prometheus/SerializerTest.java | 30 +++++------ .../OtelToZipkinSpanTransformerTest.java | 4 +- .../micrometer1shim/CounterTest.java | 3 +- .../DistributionSummaryTest.java | 9 ++-- .../micrometer1shim/FunctionCounterTest.java | 3 +- .../FunctionTimerSecondsTest.java | 6 +-- .../micrometer1shim/FunctionTimerTest.java | 6 +-- .../micrometer1shim/GaugeTest.java | 3 +- .../LongTaskTimerHistogramTest.java | 15 ++---- .../LongTaskTimerSecondsTest.java | 6 +-- .../micrometer1shim/LongTaskTimerTest.java | 3 +- .../micrometer1shim/MeterTest.java | 3 +- .../micrometer1shim/NamingConventionTest.java | 3 +- .../micrometer1shim/PrometheusModeTest.java | 30 ++++------- .../micrometer1shim/TimerSecondsTest.java | 6 +-- .../micrometer1shim/TimerTest.java | 9 ++-- .../sdk/common/InstrumentationScopeInfo.java | 7 ++- .../internal/InstrumentationScopeUtil.java | 14 +++-- .../common/InstrumentationScopeInfoTest.java | 42 ++++++++++----- .../InstrumentationScopeUtilTest.java | 52 +++++++++++++++++++ .../sdk/logs/SdkLogEmitterProviderTest.java | 5 +- .../sdk/metrics/IdentityTest.java | 17 +++--- .../sdk/metrics/SdkMeterRegistryTest.java | 5 +- .../state/SynchronousMetricStorageTest.java | 2 +- .../internal/view/ViewRegistryTest.java | 5 +- .../testing/assertj/MetricAssertionsTest.java | 2 +- .../testing/assertj/TraceAssertionsTest.java | 2 +- .../sdk/trace/SdkTracerProviderTest.java | 5 +- .../sdk/trace/SdkTracerTest.java | 13 ++--- 52 files changed, 262 insertions(+), 166 deletions(-) create mode 100644 sdk/common/src/test/java/io/opentelemetry/sdk/internal/InstrumentationScopeUtilTest.java diff --git a/docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt b/docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt index d0b1c3e996..d074d37995 100644 --- a/docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt +++ b/docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt @@ -2,6 +2,8 @@ Comparing source compatibility of against **** MODIFIED CLASS: PUBLIC ABSTRACT io.opentelemetry.sdk.common.InstrumentationScopeInfo (not serializable) === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 +++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.InstrumentationScopeInfoBuilder builder(java.lang.String) + === UNCHANGED METHOD: PUBLIC STATIC io.opentelemetry.sdk.common.InstrumentationScopeInfo create(java.lang.String, java.lang.String, java.lang.String) + +++ NEW ANNOTATION: java.lang.Deprecated +++* NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.api.common.Attributes getAttributes() +++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.common.InstrumentationScopeInfoBuilder (not serializable) +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. diff --git a/exporters/jaeger-thrift/src/test/java/io/opentelemetry/exporter/jaeger/thrift/JaegerThriftSpanExporterTest.java b/exporters/jaeger-thrift/src/test/java/io/opentelemetry/exporter/jaeger/thrift/JaegerThriftSpanExporterTest.java index c4f77f539b..bf9a8152eb 100644 --- a/exporters/jaeger-thrift/src/test/java/io/opentelemetry/exporter/jaeger/thrift/JaegerThriftSpanExporterTest.java +++ b/exporters/jaeger-thrift/src/test/java/io/opentelemetry/exporter/jaeger/thrift/JaegerThriftSpanExporterTest.java @@ -83,7 +83,9 @@ class JaegerThriftSpanExporterTest { .setTotalRecordedLinks(0) .setTotalRecordedEvents(0) .setInstrumentationScopeInfo( - InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null)) + InstrumentationScopeInfo.builder("io.opentelemetry.auto") + .setVersion("1.0.0") + .build()) .setResource( Resource.create( Attributes.of( @@ -158,7 +160,9 @@ class JaegerThriftSpanExporterTest { .setTotalRecordedLinks(0) .setTotalRecordedEvents(0) .setInstrumentationScopeInfo( - InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null)) + InstrumentationScopeInfo.builder("io.opentelemetry.auto") + .setVersion("1.0.0") + .build()) .setResource( Resource.create( Attributes.of( @@ -181,7 +185,9 @@ class JaegerThriftSpanExporterTest { .setTotalRecordedLinks(0) .setTotalRecordedEvents(0) .setInstrumentationScopeInfo( - InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null)) + InstrumentationScopeInfo.builder("io.opentelemetry.auto") + .setVersion("1.0.0") + .build()) .setResource( Resource.create( Attributes.of( diff --git a/exporters/jaeger/src/test/java/io/opentelemetry/exporter/jaeger/JaegerGrpcSpanExporterTest.java b/exporters/jaeger/src/test/java/io/opentelemetry/exporter/jaeger/JaegerGrpcSpanExporterTest.java index 46d7b4cbb7..ceebf06900 100644 --- a/exporters/jaeger/src/test/java/io/opentelemetry/exporter/jaeger/JaegerGrpcSpanExporterTest.java +++ b/exporters/jaeger/src/test/java/io/opentelemetry/exporter/jaeger/JaegerGrpcSpanExporterTest.java @@ -126,7 +126,9 @@ class JaegerGrpcSpanExporterTest { .setTotalRecordedLinks(0) .setTotalRecordedEvents(0) .setInstrumentationScopeInfo( - InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null)) + InstrumentationScopeInfo.builder("io.opentelemetry.auto") + .setVersion("1.0.0") + .build()) .setResource( Resource.create( Attributes.of( @@ -177,7 +179,9 @@ class JaegerGrpcSpanExporterTest { .setTotalRecordedLinks(0) .setTotalRecordedEvents(0) .setInstrumentationScopeInfo( - InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null)) + InstrumentationScopeInfo.builder("io.opentelemetry.auto") + .setVersion("1.0.0") + .build()) .setResource( Resource.create( Attributes.of( @@ -202,7 +206,9 @@ class JaegerGrpcSpanExporterTest { .setTotalRecordedLinks(0) .setTotalRecordedEvents(0) .setInstrumentationScopeInfo( - InstrumentationScopeInfo.create("io.opentelemetry.auto", "1.0.0", null)) + InstrumentationScopeInfo.builder("io.opentelemetry.auto") + .setVersion("1.0.0") + .build()) .setResource( Resource.create( Attributes.of( diff --git a/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporterTest.java b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporterTest.java index 111f709619..21086cc858 100644 --- a/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporterTest.java +++ b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporterTest.java @@ -61,7 +61,7 @@ class OtlpJsonLoggingLogExporterTest { TestLogData.builder() .setResource(RESOURCE) .setInstrumentationScopeInfo( - InstrumentationScopeInfo.create("instrumentation2", "2", null)) + InstrumentationScopeInfo.builder("instrumentation2").setVersion("2").build()) .setBody("body2") .setSeverity(Severity.INFO) .setSeverityText("INFO") diff --git a/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingMetricExporterTest.java b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingMetricExporterTest.java index 76568fa582..2205352884 100644 --- a/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingMetricExporterTest.java +++ b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingMetricExporterTest.java @@ -53,7 +53,7 @@ class OtlpJsonLoggingMetricExporterTest { private static final MetricData METRIC2 = ImmutableMetricData.createDoubleSum( RESOURCE, - InstrumentationScopeInfo.create("instrumentation2", "2", null), + InstrumentationScopeInfo.builder("instrumentation2").setVersion("2").build(), "metric2", "metric2 description", "s", diff --git a/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingSpanExporterTest.java b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingSpanExporterTest.java index a139aabfbd..9c429003c4 100644 --- a/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingSpanExporterTest.java +++ b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingSpanExporterTest.java @@ -86,7 +86,7 @@ class OtlpJsonLoggingSpanExporterTest { .setKind(SpanKind.CLIENT) .setResource(RESOURCE) .setInstrumentationScopeInfo( - InstrumentationScopeInfo.create("instrumentation2", "2", null)) + InstrumentationScopeInfo.builder("instrumentation2").setVersion("2").build()) .build(); @RegisterExtension diff --git a/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingMetricExporterTest.java b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingMetricExporterTest.java index 267904ef92..fad2eba5e7 100644 --- a/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingMetricExporterTest.java +++ b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingMetricExporterTest.java @@ -63,7 +63,7 @@ class LoggingMetricExporterTest { long nowEpochNanos = System.currentTimeMillis() * 1000 * 1000; Resource resource = Resource.create(Attributes.of(stringKey("host"), "localhost")); InstrumentationScopeInfo instrumentationScopeInfo = - InstrumentationScopeInfo.create("manualInstrumentation", "1.0", null); + InstrumentationScopeInfo.builder("manualInstrumentation").setVersion("1.0").build(); exporter.export( Arrays.asList( ImmutableMetricData.createDoubleSummary( diff --git a/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingSpanExporterTest.java b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingSpanExporterTest.java index b1fa6330cd..6f929d47a4 100644 --- a/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingSpanExporterTest.java +++ b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingSpanExporterTest.java @@ -82,7 +82,8 @@ class LoggingSpanExporterTest { .setStatus(StatusData.error()) .setName("testSpan2") .setKind(SpanKind.CLIENT) - .setInstrumentationScopeInfo(InstrumentationScopeInfo.create("tracer2", "1.0", null)) + .setInstrumentationScopeInfo( + InstrumentationScopeInfo.builder("tracer2").setVersion("1.0").build()) .build(); @RegisterExtension diff --git a/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/SystemOutLogExporterTest.java b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/SystemOutLogExporterTest.java index 6cc8a499cc..b77a2330f0 100644 --- a/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/SystemOutLogExporterTest.java +++ b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/SystemOutLogExporterTest.java @@ -53,7 +53,8 @@ class SystemOutLogExporterTest { private static LogData sampleLog(long timestamp) { return TestLogData.builder() .setResource(Resource.empty()) - .setInstrumentationScopeInfo(InstrumentationScopeInfo.create("logTest", "1.0", null)) + .setInstrumentationScopeInfo( + InstrumentationScopeInfo.builder("logTest").setVersion("1.0").build()) .setAttributes(Attributes.of(stringKey("cheese"), "cheddar", longKey("amount"), 1L)) .setBody("message") .setSeverity(Severity.ERROR3) diff --git a/exporters/otlp/all/src/test/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterTest.java b/exporters/otlp/all/src/test/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterTest.java index 0389f3cbeb..140a279b96 100644 --- a/exporters/otlp/all/src/test/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterTest.java +++ b/exporters/otlp/all/src/test/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterTest.java @@ -347,7 +347,10 @@ class OtlpHttpSpanExporterTest { .setTotalRecordedLinks(0) .setTotalRecordedEvents(0) .setInstrumentationScopeInfo( - InstrumentationScopeInfo.create("testLib", "1.0", "http://url")) + InstrumentationScopeInfo.builder("testLib") + .setVersion("1.0") + .setSchemaUrl("http://url") + .build()) .build(); } } diff --git a/exporters/otlp/all/src/test/java/io/opentelemetry/exporter/otlp/trace/OtlpGrpcSpanExporterTest.java b/exporters/otlp/all/src/test/java/io/opentelemetry/exporter/otlp/trace/OtlpGrpcSpanExporterTest.java index c638ae8cf5..f411e7f6fb 100644 --- a/exporters/otlp/all/src/test/java/io/opentelemetry/exporter/otlp/trace/OtlpGrpcSpanExporterTest.java +++ b/exporters/otlp/all/src/test/java/io/opentelemetry/exporter/otlp/trace/OtlpGrpcSpanExporterTest.java @@ -78,7 +78,10 @@ class OtlpGrpcSpanExporterTest extends AbstractGrpcTelemetryExporterTest assertThat(metric) .hasName("testCounter") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test counter") .hasUnit("items") .hasDoubleSumSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/DistributionSummaryTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/DistributionSummaryTest.java index a7c68e5504..c0dee1047f 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/DistributionSummaryTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/DistributionSummaryTest.java @@ -38,8 +38,7 @@ class DistributionSummaryTest { metric -> assertThat(metric) .hasName("testSummary") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test distribution summary") .hasUnit("things") .hasHistogramSatisfying( @@ -102,8 +101,7 @@ class DistributionSummaryTest { metric -> assertThat(metric) .hasName("testSummary") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test distribution summary") .hasUnit("things") .hasHistogramSatisfying( @@ -175,8 +173,7 @@ class DistributionSummaryTest { metric -> assertThat(metric) .hasName("testSummary") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test distribution summary") .hasUnit("things") .hasHistogramSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionCounterTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionCounterTest.java index ec213a030c..6e0b058925 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionCounterTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionCounterTest.java @@ -40,8 +40,7 @@ class FunctionCounterTest { metric -> assertThat(metric) .hasName("testFunctionCounter") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test function counter") .hasUnit("items") .hasDoubleSumSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionTimerSecondsTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionTimerSecondsTest.java index 2e42f8d462..706015db9d 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionTimerSecondsTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionTimerSecondsTest.java @@ -57,8 +57,7 @@ class FunctionTimerSecondsTest { metric -> assertThat(metric) .hasName("testFunctionTimerSeconds.count") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test function timer") .hasUnit("1") .hasLongSumSatisfying( @@ -72,8 +71,7 @@ class FunctionTimerSecondsTest { metric -> assertThat(metric) .hasName("testFunctionTimerSeconds.sum") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test function timer") .hasUnit("s") .hasDoubleSumSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionTimerTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionTimerTest.java index 9446f5feb8..e8cb6448fc 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionTimerTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/FunctionTimerTest.java @@ -52,8 +52,7 @@ class FunctionTimerTest { metric -> assertThat(metric) .hasName("testFunctionTimer.count") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test function timer") .hasUnit("1") .hasLongSumSatisfying( @@ -67,8 +66,7 @@ class FunctionTimerTest { metric -> assertThat(metric) .hasName("testFunctionTimer.sum") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test function timer") .hasUnit("ms") .hasDoubleSumSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/GaugeTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/GaugeTest.java index b0fd7717d1..0b1afca375 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/GaugeTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/GaugeTest.java @@ -38,8 +38,7 @@ class GaugeTest { metric -> assertThat(metric) .hasName("testGauge") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test gauge") .hasUnit("items") .hasDoubleGaugeSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerHistogramTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerHistogramTest.java index 1bf52e31de..577a55fa7b 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerHistogramTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerHistogramTest.java @@ -54,8 +54,7 @@ class LongTaskTimerHistogramTest { metric -> assertThat(metric) .hasName("testLongTaskTimerHistogram.active") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test timer") .hasUnit("tasks") .hasLongSumSatisfying( @@ -66,8 +65,7 @@ class LongTaskTimerHistogramTest { metric -> assertThat(metric) .hasName("testLongTaskTimerHistogram.duration") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test timer") .hasUnit("ms") .hasDoubleSumSatisfying( @@ -84,8 +82,7 @@ class LongTaskTimerHistogramTest { metric -> assertThat(metric) .hasName("testLongTaskTimerHistogram.histogram") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDoubleGaugeSatisfying( gauge -> gauge.hasPointsSatisfying( @@ -106,8 +103,7 @@ class LongTaskTimerHistogramTest { metric -> assertThat(metric) .hasName("testLongTaskTimerHistogram.active") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test timer") .hasUnit("tasks") .hasLongSumSatisfying( @@ -118,8 +114,7 @@ class LongTaskTimerHistogramTest { metric -> assertThat(metric) .hasName("testLongTaskTimerHistogram.duration") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test timer") .hasUnit("ms") .hasDoubleSumSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerSecondsTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerSecondsTest.java index 714bfa03e4..fed7dbd5b6 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerSecondsTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerSecondsTest.java @@ -47,8 +47,7 @@ class LongTaskTimerSecondsTest { metric -> assertThat(metric) .hasName("testLongTaskTimerSeconds.active") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test long task timer") .hasUnit("tasks") .hasLongSumSatisfying( @@ -62,8 +61,7 @@ class LongTaskTimerSecondsTest { metric -> assertThat(metric) .hasName("testLongTaskTimerSeconds.duration") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test long task timer") .hasUnit("s") .hasDoubleSumSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerTest.java index 3ee22ed80d..15a0aed827 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerTest.java @@ -36,8 +36,7 @@ class LongTaskTimerTest { metric -> assertThat(metric) .hasName("testLongTaskTimer.active") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test long task timer") .hasUnit("tasks") .hasLongSumSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/MeterTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/MeterTest.java index 00432c9682..342e4cb6de 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/MeterTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/MeterTest.java @@ -52,8 +52,7 @@ class MeterTest { metric -> assertThat(metric) .hasName("testMeter.total") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test meter") .hasUnit("things") .hasDoubleSumSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/NamingConventionTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/NamingConventionTest.java index 5a48139fa0..9c82e25790 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/NamingConventionTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/NamingConventionTest.java @@ -67,8 +67,7 @@ class NamingConventionTest { metric -> assertThat(metric) .hasName("test.renamedCounter") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDoubleSumSatisfying( sum -> sum.hasPointsSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/PrometheusModeTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/PrometheusModeTest.java index b2765a8783..77cc55ad45 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/PrometheusModeTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/PrometheusModeTest.java @@ -62,8 +62,7 @@ class PrometheusModeTest { metric -> assertThat(metric) .hasName("testPrometheusCounter.items") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test counter") .hasUnit("items") .hasDoubleSumSatisfying( @@ -96,8 +95,7 @@ class PrometheusModeTest { metric -> assertThat(metric) .hasName("testPrometheusSummary.items") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test summary") .hasUnit("items") .hasHistogramSatisfying( @@ -111,8 +109,7 @@ class PrometheusModeTest { metric -> assertThat(metric) .hasName("testPrometheusSummary.items.max") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test summary") .hasUnit("items") .hasDoubleGaugeSatisfying( @@ -146,8 +143,7 @@ class PrometheusModeTest { metric -> assertThat(metric) .hasName("testPrometheusFunctionTimer.seconds.count") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test function timer") .hasUnit("1") .hasLongSumSatisfying( @@ -161,8 +157,7 @@ class PrometheusModeTest { metric -> assertThat(metric) .hasName("testPrometheusFunctionTimer.seconds.sum") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test function timer") .hasUnit("s") .hasDoubleSumSatisfying( @@ -189,8 +184,7 @@ class PrometheusModeTest { metric -> assertThat(metric) .hasName("testPrometheusGauge.items") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test gauge") .hasUnit("items") .hasDoubleGaugeSatisfying( @@ -220,8 +214,7 @@ class PrometheusModeTest { metric -> assertThat(metric) .hasName("testPrometheusLongTaskTimer.seconds.active") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test long task timer") .hasUnit("tasks") .hasLongSumSatisfying( @@ -235,8 +228,7 @@ class PrometheusModeTest { metric -> assertThat(metric) .hasName("testPrometheusLongTaskTimer.seconds.duration") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test long task timer") .hasUnit("s") .hasDoubleSumSatisfying( @@ -300,8 +292,7 @@ class PrometheusModeTest { metric -> assertThat(metric) .hasName("testPrometheusTimer.seconds") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test timer") .hasUnit("s") .hasHistogramSatisfying( @@ -315,8 +306,7 @@ class PrometheusModeTest { metric -> assertThat(metric) .hasName("testPrometheusTimer.seconds.max") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test timer") .hasUnit("s") .hasDoubleGaugeSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/TimerSecondsTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/TimerSecondsTest.java index d8bd0a49dd..a98381608b 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/TimerSecondsTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/TimerSecondsTest.java @@ -47,8 +47,7 @@ class TimerSecondsTest { metric -> assertThat(metric) .hasName("testTimerSeconds") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test timer") .hasUnit("s") .hasHistogramSatisfying( @@ -80,8 +79,7 @@ class TimerSecondsTest { metric -> assertThat(metric) .hasName("testTimerSeconds") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test timer") .hasUnit("s") .hasHistogramSatisfying( diff --git a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/TimerTest.java b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/TimerTest.java index 0b49c22ff5..221fb86677 100644 --- a/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/TimerTest.java +++ b/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/TimerTest.java @@ -39,8 +39,7 @@ class TimerTest { metric -> assertThat(metric) .hasName("testTimer") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test timer") .hasUnit("ms") .hasHistogramSatisfying( @@ -137,8 +136,7 @@ class TimerTest { metric -> assertThat(metric) .hasName("testTimer") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test timer") .hasUnit("ms") .hasHistogramSatisfying( @@ -210,8 +208,7 @@ class TimerTest { metric -> assertThat(metric) .hasName("testTimer") - .hasInstrumentationScope( - InstrumentationScopeInfo.create(INSTRUMENTATION_NAME, null, null)) + .hasInstrumentationScope(InstrumentationScopeInfo.create(INSTRUMENTATION_NAME)) .hasDescription("This is a test timer") .hasUnit("ms") .hasHistogramSatisfying( diff --git a/sdk/common/src/main/java/io/opentelemetry/sdk/common/InstrumentationScopeInfo.java b/sdk/common/src/main/java/io/opentelemetry/sdk/common/InstrumentationScopeInfo.java index 5028ea6f43..0aab48f47e 100644 --- a/sdk/common/src/main/java/io/opentelemetry/sdk/common/InstrumentationScopeInfo.java +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/common/InstrumentationScopeInfo.java @@ -30,7 +30,12 @@ public abstract class InstrumentationScopeInfo { return InstrumentationScopeInfo.create(name, null, null, Attributes.empty()); } - /** Creates a new instance of {@link InstrumentationScopeInfo}. */ + /** + * Creates a new instance of {@link InstrumentationScopeInfo}. + * + * @deprecated Use {@link #builder(String)} or {@link #create(String)}. + */ + @Deprecated public static InstrumentationScopeInfo create( String name, @Nullable String version, @Nullable String schemaUrl) { return InstrumentationScopeInfo.create(name, version, schemaUrl, Attributes.empty()); diff --git a/sdk/common/src/main/java/io/opentelemetry/sdk/internal/InstrumentationScopeUtil.java b/sdk/common/src/main/java/io/opentelemetry/sdk/internal/InstrumentationScopeUtil.java index 299a6f7d77..0d20273bb8 100644 --- a/sdk/common/src/main/java/io/opentelemetry/sdk/internal/InstrumentationScopeUtil.java +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/internal/InstrumentationScopeUtil.java @@ -6,6 +6,7 @@ package io.opentelemetry.sdk.internal; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfoBuilder; /** * This class is internal and is hence not for public use. Its APIs are unstable and can change at @@ -27,10 +28,15 @@ public final class InstrumentationScopeUtil { @SuppressWarnings("deprecation") // Utility method for compatibility public static InstrumentationScopeInfo toInstrumentationScopeInfo( io.opentelemetry.sdk.common.InstrumentationLibraryInfo instrumentationLibraryInfo) { - return InstrumentationScopeInfo.create( - instrumentationLibraryInfo.getName(), - instrumentationLibraryInfo.getVersion(), - instrumentationLibraryInfo.getSchemaUrl()); + InstrumentationScopeInfoBuilder builder = + InstrumentationScopeInfo.builder(instrumentationLibraryInfo.getName()); + if (instrumentationLibraryInfo.getVersion() != null) { + builder.setVersion(instrumentationLibraryInfo.getVersion()); + } + if (instrumentationLibraryInfo.getSchemaUrl() != null) { + builder.setSchemaUrl(instrumentationLibraryInfo.getSchemaUrl()); + } + return builder.build(); } private InstrumentationScopeUtil() {} diff --git a/sdk/common/src/test/java/io/opentelemetry/sdk/common/InstrumentationScopeInfoTest.java b/sdk/common/src/test/java/io/opentelemetry/sdk/common/InstrumentationScopeInfoTest.java index c31def8c2a..d5093d2f3b 100644 --- a/sdk/common/src/test/java/io/opentelemetry/sdk/common/InstrumentationScopeInfoTest.java +++ b/sdk/common/src/test/java/io/opentelemetry/sdk/common/InstrumentationScopeInfoTest.java @@ -6,7 +6,6 @@ package io.opentelemetry.sdk.common; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; import io.opentelemetry.api.common.Attributes; @@ -23,18 +22,35 @@ class InstrumentationScopeInfoTest { @Test void create_Valid() { - assertThatCode(() -> InstrumentationScopeInfo.builder("name").build()) - .doesNotThrowAnyException(); - assertThatCode(() -> InstrumentationScopeInfo.builder("name").setVersion(null).build()) - .doesNotThrowAnyException(); - assertThatCode(() -> InstrumentationScopeInfo.builder("name").setSchemaUrl(null).build()) - .doesNotThrowAnyException(); - assertThatCode( - () -> - InstrumentationScopeInfo.builder("name") - .setAttributes(Attributes.builder().put("key", "value").build()) - .build()) - .doesNotThrowAnyException(); + InstrumentationScopeInfo scope = InstrumentationScopeInfo.builder("name").build(); + assertThat(scope.getName()).isEqualTo("name"); + assertThat(scope.getVersion()).isNull(); + assertThat(scope.getSchemaUrl()).isNull(); + assertThat(scope.getAttributes()).isEqualTo(Attributes.empty()); + + scope = + InstrumentationScopeInfo.builder("name") + .setVersion("version") + .setSchemaUrl("schemaUrl") + .setAttributes(Attributes.builder().put("key", "value").build()) + .build(); + assertThat(scope.getName()).isEqualTo("name"); + assertThat(scope.getVersion()).isEqualTo("version"); + assertThat(scope.getSchemaUrl()).isEqualTo("schemaUrl"); + assertThat(scope.getAttributes()).isEqualTo(Attributes.builder().put("key", "value").build()); + } + + @Test + @SuppressWarnings("deprecation") // Testing deprecated code + void create_AllArgs() { + assertThat(InstrumentationScopeInfo.create("name", "version", "schemaUrl")) + .isEqualTo( + InstrumentationScopeInfo.builder("name") + .setVersion("version") + .setSchemaUrl("schemaUrl") + .build()); + assertThat(InstrumentationScopeInfo.create("name", null, null)) + .isEqualTo(InstrumentationScopeInfo.builder("name").build()); } @Test diff --git a/sdk/common/src/test/java/io/opentelemetry/sdk/internal/InstrumentationScopeUtilTest.java b/sdk/common/src/test/java/io/opentelemetry/sdk/internal/InstrumentationScopeUtilTest.java new file mode 100644 index 0000000000..27f2b28e99 --- /dev/null +++ b/sdk/common/src/test/java/io/opentelemetry/sdk/internal/InstrumentationScopeUtilTest.java @@ -0,0 +1,52 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.internal; + +import static org.assertj.core.api.Assertions.assertThat; + +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; +import org.junit.jupiter.api.Test; + +@SuppressWarnings("deprecation") // Testing deprecated code +class InstrumentationScopeUtilTest { + + @Test + void toInstrumentationLibraryInfo() { + assertThat( + InstrumentationScopeUtil.toInstrumentationLibraryInfo( + InstrumentationScopeInfo.builder("name").build())) + .isEqualTo( + io.opentelemetry.sdk.common.InstrumentationLibraryInfo.create("name", null, null)); + assertThat( + InstrumentationScopeUtil.toInstrumentationLibraryInfo( + InstrumentationScopeInfo.builder("name") + .setVersion("version") + .setSchemaUrl("schemaUrl") + .setAttributes(Attributes.builder().put("key", "value").build()) + .build())) + .isEqualTo( + io.opentelemetry.sdk.common.InstrumentationLibraryInfo.create( + "name", "version", "schemaUrl")); + } + + @Test + void toInstrumentationScopeInfo() { + assertThat( + InstrumentationScopeUtil.toInstrumentationScopeInfo( + io.opentelemetry.sdk.common.InstrumentationLibraryInfo.create("name", null, null))) + .isEqualTo(InstrumentationScopeInfo.builder("name").build()); + assertThat( + InstrumentationScopeUtil.toInstrumentationScopeInfo( + io.opentelemetry.sdk.common.InstrumentationLibraryInfo.create( + "name", "version", "schemaUrl"))) + .isEqualTo( + InstrumentationScopeInfo.builder("name") + .setVersion("version") + .setSchemaUrl("schemaUrl") + .build()); + } +} diff --git a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogEmitterProviderTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogEmitterProviderTest.java index c379d12b23..b8191b0268 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogEmitterProviderTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogEmitterProviderTest.java @@ -185,7 +185,10 @@ class SdkLogEmitterProviderTest { @Test void logEmitterBuilder_PropagatesToEmitter() { InstrumentationScopeInfo expected = - InstrumentationScopeInfo.create("test", "version", "http://url"); + InstrumentationScopeInfo.builder("test") + .setVersion("version") + .setSchemaUrl("http://url") + .build(); assertThat( ((SdkLogEmitter) sdkLogEmitterProvider diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/IdentityTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/IdentityTest.java index f9e76215f3..f4dfd95fe3 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/IdentityTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/IdentityTest.java @@ -173,7 +173,7 @@ class IdentityTest { metricData -> assertThat(metricData) .hasInstrumentationScope( - InstrumentationScopeInfo.create("meter1", "version1", null)) + InstrumentationScopeInfo.builder("meter1").setVersion("version1").build()) .hasName("counter1") .hasLongSumSatisfying( sum -> sum.hasPointsSatisfying(point -> point.hasValue(10)))); @@ -199,14 +199,17 @@ class IdentityTest { metricData -> assertThat(metricData) .hasInstrumentationScope( - InstrumentationScopeInfo.create("meter1", "version1", null)) + InstrumentationScopeInfo.builder("meter1").setVersion("version1").build()) .hasName("counter1") .hasLongSumSatisfying( sum -> sum.hasPointsSatisfying(point -> point.hasValue(10))), metricData -> assertThat(metricData) .hasInstrumentationScope( - InstrumentationScopeInfo.create("meter1", "version1", "schema1")) + InstrumentationScopeInfo.builder("meter1") + .setVersion("version1") + .setSchemaUrl("schema1") + .build()) .hasName("counter1") .hasLongSumSatisfying( sum -> sum.hasPointsSatisfying(point -> point.hasValue(10)))); @@ -566,7 +569,7 @@ class IdentityTest { metricData -> assertThat(metricData) .hasInstrumentationScope( - InstrumentationScopeInfo.create("meter1", "version1", null)) + InstrumentationScopeInfo.builder("meter1").setVersion("version1").build()) .hasName("counter1") .hasDescription("description1") .hasLongSumSatisfying( @@ -574,7 +577,7 @@ class IdentityTest { metricData -> { assertThat(metricData) .hasInstrumentationScope( - InstrumentationScopeInfo.create("meter1", "version2", null)) + InstrumentationScopeInfo.builder("meter1").setVersion("version2").build()) .hasName("counter1") .hasLongSumSatisfying( sum -> sum.hasPointsSatisfying(point -> point.hasValue(10))); @@ -613,7 +616,7 @@ class IdentityTest { metricData -> assertThat(metricData) .hasInstrumentationScope( - InstrumentationScopeInfo.create("meter1", null, "schema1")) + InstrumentationScopeInfo.builder("meter1").setSchemaUrl("schema1").build()) .hasName("counter1") .hasDescription("description1") .hasLongSumSatisfying( @@ -621,7 +624,7 @@ class IdentityTest { metricData -> { assertThat(metricData) .hasInstrumentationScope( - InstrumentationScopeInfo.create("meter1", null, "schema2")) + InstrumentationScopeInfo.builder("meter1").setSchemaUrl("schema2").build()) .hasName("counter1") .hasLongSumSatisfying( sum -> sum.hasPointsSatisfying(point -> point.hasValue(10))); diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/SdkMeterRegistryTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/SdkMeterRegistryTest.java index 1edc76dca1..49a92aa3a3 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/SdkMeterRegistryTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/SdkMeterRegistryTest.java @@ -91,7 +91,10 @@ class SdkMeterRegistryTest { @Test void propagatesInstrumentationScopeInfoToMeter() { InstrumentationScopeInfo expected = - InstrumentationScopeInfo.create("theName", "theVersion", "http://theschema"); + InstrumentationScopeInfo.builder("theName") + .setVersion("theVersion") + .setSchemaUrl("http://theschema") + .build(); SdkMeter meter = (SdkMeter) meterProvider diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/SynchronousMetricStorageTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/SynchronousMetricStorageTest.java index c1cc856b71..7f4a0d68ec 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/SynchronousMetricStorageTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/SynchronousMetricStorageTest.java @@ -39,7 +39,7 @@ import org.mockito.junit.jupiter.MockitoExtension; public class SynchronousMetricStorageTest { private static final Resource RESOURCE = Resource.empty(); private static final InstrumentationScopeInfo INSTRUMENTATION_SCOPE_INFO = - InstrumentationScopeInfo.create("test", "1.0", null); + InstrumentationScopeInfo.builder("test").setVersion("1.0").build(); private static final InstrumentDescriptor DESCRIPTOR = InstrumentDescriptor.create( "name", "description", "unit", InstrumentType.COUNTER, InstrumentValueType.DOUBLE); diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/view/ViewRegistryTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/view/ViewRegistryTest.java index 6ea6790cad..7ea64cf279 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/view/ViewRegistryTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/view/ViewRegistryTest.java @@ -30,7 +30,10 @@ class ViewRegistryTest { @RegisterExtension LogCapturer logs = LogCapturer.create().captureForType(ViewRegistry.class); private static final InstrumentationScopeInfo INSTRUMENTATION_SCOPE_INFO = - InstrumentationScopeInfo.create("name", "version", "schema_url"); + InstrumentationScopeInfo.builder("name") + .setVersion("version") + .setSchemaUrl("schema_url") + .build(); private static RegisteredView registeredView(InstrumentSelector instrumentSelector, View view) { return RegisteredView.create( diff --git a/sdk/testing/src/test/java/io/opentelemetry/sdk/testing/assertj/MetricAssertionsTest.java b/sdk/testing/src/test/java/io/opentelemetry/sdk/testing/assertj/MetricAssertionsTest.java index 2fc0602b98..b2b68f3853 100644 --- a/sdk/testing/src/test/java/io/opentelemetry/sdk/testing/assertj/MetricAssertionsTest.java +++ b/sdk/testing/src/test/java/io/opentelemetry/sdk/testing/assertj/MetricAssertionsTest.java @@ -53,7 +53,7 @@ class MetricAssertionsTest { private static final Resource RESOURCE = Resource.create(Attributes.builder().put("dog", "bark").build()); private static final InstrumentationScopeInfo INSTRUMENTATION_SCOPE_INFO = - InstrumentationScopeInfo.create("opentelemetry", "1.0", null); + InstrumentationScopeInfo.builder("opentelemetry").setVersion("1.0").build(); private static final AttributeKey BEAR = AttributeKey.stringKey("bear"); private static final AttributeKey CAT = AttributeKey.stringKey("cat"); diff --git a/sdk/testing/src/test/java/io/opentelemetry/sdk/testing/assertj/TraceAssertionsTest.java b/sdk/testing/src/test/java/io/opentelemetry/sdk/testing/assertj/TraceAssertionsTest.java index 118fdfffd3..9c87b5df11 100644 --- a/sdk/testing/src/test/java/io/opentelemetry/sdk/testing/assertj/TraceAssertionsTest.java +++ b/sdk/testing/src/test/java/io/opentelemetry/sdk/testing/assertj/TraceAssertionsTest.java @@ -46,7 +46,7 @@ class TraceAssertionsTest { private static final Resource RESOURCE = Resource.create(Attributes.builder().put("dog", "bark").build()); private static final InstrumentationScopeInfo INSTRUMENTATION_SCOPE_INFO = - InstrumentationScopeInfo.create("opentelemetry", "1.0", null); + InstrumentationScopeInfo.builder("opentelemetry").setVersion("1.0").build(); private static final AttributeKey BEAR = AttributeKey.stringKey("bear"); private static final AttributeKey CAT = AttributeKey.stringKey("cat"); diff --git a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkTracerProviderTest.java b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkTracerProviderTest.java index 95ffa8a6c6..c3386379e2 100644 --- a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkTracerProviderTest.java +++ b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkTracerProviderTest.java @@ -171,7 +171,10 @@ class SdkTracerProviderTest { @Test void propagatesInstrumentationScopeInfoToTracer() { InstrumentationScopeInfo expected = - InstrumentationScopeInfo.create("theName", "theVersion", "http://url"); + InstrumentationScopeInfo.builder("theName") + .setVersion("theVersion") + .setSchemaUrl("http://url") + .build(); Tracer tracer = tracerFactory .tracerBuilder(expected.getName()) diff --git a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkTracerTest.java b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkTracerTest.java index eafe5ca517..c17c121a36 100644 --- a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkTracerTest.java +++ b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkTracerTest.java @@ -27,8 +27,10 @@ class SdkTracerTest { "io.opentelemetry.sdk.trace.TracerSdkTest"; private static final String INSTRUMENTATION_SCOPE_VERSION = "0.2.0"; private static final InstrumentationScopeInfo instrumentationScopeInfo = - InstrumentationScopeInfo.create( - INSTRUMENTATION_SCOPE_NAME, INSTRUMENTATION_SCOPE_VERSION, "http://schemaurl"); + InstrumentationScopeInfo.builder(INSTRUMENTATION_SCOPE_NAME) + .setVersion(INSTRUMENTATION_SCOPE_VERSION) + .setSchemaUrl("http://schemaurl") + .build(); private final SdkTracer tracer = (SdkTracer) SdkTracerProvider.builder() @@ -51,12 +53,7 @@ class SdkTracerTest { @Test void propagatesInstrumentationScopeInfoToSpan() { ReadableSpan readableSpan = (ReadableSpan) tracer.spanBuilder("spanName").startSpan(); - assertThat(readableSpan.getInstrumentationScopeInfo()) - .isEqualTo( - InstrumentationScopeInfo.create( - instrumentationScopeInfo.getName(), - instrumentationScopeInfo.getVersion(), - instrumentationScopeInfo.getSchemaUrl())); + assertThat(readableSpan.getInstrumentationScopeInfo()).isEqualTo(instrumentationScopeInfo); } @Test