From 963bc384c8fbac94c58f3ede6bfb47d2c4f17ffc Mon Sep 17 00:00:00 2001 From: jack-berg <34418638+jack-berg@users.noreply.github.com> Date: Sat, 26 Feb 2022 12:43:55 -0600 Subject: [PATCH] Instrumentation scope (#4215) * Add InstrumentationScopeInfo class * Rewrite tracer provider documentation * Refactor ComponentRegistry to use InstrumentationScopeInfo * Finish updating documentation to reference scope instead of library * PR feedback --- .../api/GlobalOpenTelemetry.java | 59 +++++++++--------- .../io/opentelemetry/api/OpenTelemetry.java | 42 ++++++------- .../api/metrics/DefaultMeterProvider.java | 4 +- .../io/opentelemetry/api/metrics/Meter.java | 2 +- .../api/metrics/MeterBuilder.java | 9 ++- .../api/metrics/MeterProvider.java | 14 ++--- .../api/trace/DefaultTracerBuilder.java | 2 +- .../api/trace/DefaultTracerProvider.java | 4 +- .../api/trace/TracerBuilder.java | 9 ++- .../api/trace/TracerProvider.java | 24 ++++---- .../opentelemetry-sdk-common.txt | 12 +++- .../extension/noopapi/NoopTracerProvider.java | 4 +- .../opentelemetry/sdk/OpenTelemetrySdk.java | 16 ++--- .../sdk/common/InstrumentationScopeInfo.java | 60 +++++++++++++++++++ .../sdk/internal/ComponentRegistry.java | 47 ++++++++------- .../internal/InstrumentationScopeUtil.java | 27 +++++++++ .../common/InstrumentationScopeInfoTest.java | 27 +++++++++ .../sdk/internal/ComponentRegistryTest.java | 17 +++--- .../sdk/logs/LogEmitterBuilder.java | 8 +-- .../opentelemetry/sdk/logs/SdkLogEmitter.java | 13 ++-- .../sdk/logs/SdkLogEmitterBuilder.java | 14 ++--- .../sdk/logs/SdkLogEmitterProvider.java | 22 +++---- .../sdk/logs/SdkLogEmitterProviderTest.java | 12 ++-- .../sdk/logs/SdkLogEmitterTest.java | 4 +- .../opentelemetry/sdk/metrics/SdkMeter.java | 17 ++++-- .../sdk/metrics/SdkMeterBuilder.java | 14 ++--- .../sdk/metrics/SdkMeterProvider.java | 12 ++-- .../sdk/metrics/SdkMeterRegistryTest.java | 28 ++++----- .../io/opentelemetry/sdk/trace/SdkTracer.java | 21 +++---- .../sdk/trace/SdkTracerBuilder.java | 14 ++--- .../sdk/trace/SdkTracerProvider.java | 22 +++---- .../sdk/trace/SdkTracerProviderTest.java | 18 +++--- .../sdk/trace/SdkTracerTest.java | 32 ++++++---- 33 files changed, 383 insertions(+), 247 deletions(-) create mode 100644 sdk/common/src/main/java/io/opentelemetry/sdk/common/InstrumentationScopeInfo.java create mode 100644 sdk/common/src/main/java/io/opentelemetry/sdk/internal/InstrumentationScopeUtil.java create mode 100644 sdk/common/src/test/java/io/opentelemetry/sdk/common/InstrumentationScopeInfoTest.java diff --git a/api/all/src/main/java/io/opentelemetry/api/GlobalOpenTelemetry.java b/api/all/src/main/java/io/opentelemetry/api/GlobalOpenTelemetry.java index a25c4cc28a..0087e47b6c 100644 --- a/api/all/src/main/java/io/opentelemetry/api/GlobalOpenTelemetry.java +++ b/api/all/src/main/java/io/opentelemetry/api/GlobalOpenTelemetry.java @@ -106,44 +106,45 @@ public final class GlobalOpenTelemetry { /** * Gets or creates a named tracer instance from the globally registered {@link TracerProvider}. * - *

This is a shortcut method for {@code getTracerProvider().get(instrumentationName)} + *

This is a shortcut method for {@code getTracerProvider().get(instrumentationScopeName)} * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a tracer instance. */ - public static Tracer getTracer(String instrumentationName) { - return get().getTracer(instrumentationName); + public static Tracer getTracer(String instrumentationScopeName) { + return get().getTracer(instrumentationScopeName); } /** * Gets or creates a named and versioned tracer instance from the globally registered {@link * TracerProvider}. * - *

This is a shortcut method for {@code getTracerProvider().get(instrumentationName, - * instrumentationVersion)} + *

This is a shortcut method for {@code getTracerProvider().get(instrumentationScopeName, + * instrumentationScopeVersion)} * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null. - * @param instrumentationVersion The version of the instrumentation library (e.g., "1.0.0"). + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. + * @param instrumentationScopeVersion The version of the instrumentation scope (e.g., "1.0.0"). * @return a tracer instance. */ - public static Tracer getTracer(String instrumentationName, String instrumentationVersion) { - return get().getTracer(instrumentationName, instrumentationVersion); + public static Tracer getTracer( + String instrumentationScopeName, String instrumentationScopeVersion) { + return get().getTracer(instrumentationScopeName, instrumentationScopeVersion); } /** * Creates a TracerBuilder for a named {@link Tracer} instance. * - *

This is a shortcut method for {@code get().tracerBuilder(instrumentationName)} + *

This is a shortcut method for {@code get().tracerBuilder(instrumentationScopeName)} * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a TracerBuilder instance. * @since 1.4.0 */ - public static TracerBuilder tracerBuilder(String instrumentationName) { - return get().tracerBuilder(instrumentationName); + public static TracerBuilder tracerBuilder(String instrumentationScopeName) { + return get().tracerBuilder(instrumentationScopeName); } /** @@ -158,29 +159,29 @@ public final class GlobalOpenTelemetry { /** * Gets or creates a named meter instance from the globally registered {@link MeterProvider}. * - *

This is a shortcut method for {@code getMeterProvider().get(instrumentationName)} + *

This is a shortcut method for {@code getMeterProvider().get(instrumentationScopeName)} * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a Meter instance. * @since 1.10.0 */ - public static Meter getMeter(String instrumentationName) { - return get().getMeter(instrumentationName); + public static Meter getMeter(String instrumentationScopeName) { + return get().getMeter(instrumentationScopeName); } /** * Creates a MeterBuilder for a named {@link Meter} instance. * - *

This is a shortcut method for {@code get().meterBuilder(instrumentationName)} + *

This is a shortcut method for {@code get().meterBuilder(instrumentationScopeName)} * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a MeterBuilder instance. * @since 1.10.0 */ - public static MeterBuilder meterBuilder(String instrumentationName) { - return get().meterBuilder(instrumentationName); + public static MeterBuilder meterBuilder(String instrumentationScopeName) { + return get().meterBuilder(instrumentationScopeName); } /** @@ -258,8 +259,8 @@ public final class GlobalOpenTelemetry { } @Override - public TracerBuilder tracerBuilder(String instrumentationName) { - return delegate.tracerBuilder(instrumentationName); + public TracerBuilder tracerBuilder(String instrumentationScopeName) { + return delegate.tracerBuilder(instrumentationScopeName); } } } diff --git a/api/all/src/main/java/io/opentelemetry/api/OpenTelemetry.java b/api/all/src/main/java/io/opentelemetry/api/OpenTelemetry.java index 7ec2b36ddc..9dbe5c7da3 100644 --- a/api/all/src/main/java/io/opentelemetry/api/OpenTelemetry.java +++ b/api/all/src/main/java/io/opentelemetry/api/OpenTelemetry.java @@ -46,37 +46,37 @@ public interface OpenTelemetry { * Gets or creates a named tracer instance from the {@link TracerProvider} for this {@link * OpenTelemetry}. * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a tracer instance. */ - default Tracer getTracer(String instrumentationName) { - return getTracerProvider().get(instrumentationName); + default Tracer getTracer(String instrumentationScopeName) { + return getTracerProvider().get(instrumentationScopeName); } /** * Gets or creates a named and versioned tracer instance from the {@link TracerProvider} in this * {@link OpenTelemetry}. * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null. - * @param instrumentationVersion The version of the instrumentation library (e.g., "1.0.0"). + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. + * @param instrumentationScopeVersion The version of the instrumentation scope (e.g., "1.0.0"). * @return a tracer instance. */ - default Tracer getTracer(String instrumentationName, String instrumentationVersion) { - return getTracerProvider().get(instrumentationName, instrumentationVersion); + default Tracer getTracer(String instrumentationScopeName, String instrumentationScopeVersion) { + return getTracerProvider().get(instrumentationScopeName, instrumentationScopeVersion); } /** * Creates a {@link TracerBuilder} for a named {@link Tracer} instance. * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a TracerBuilder instance. * @since 1.4.0 */ - default TracerBuilder tracerBuilder(String instrumentationName) { - return getTracerProvider().tracerBuilder(instrumentationName); + default TracerBuilder tracerBuilder(String instrumentationScopeName) { + return getTracerProvider().tracerBuilder(instrumentationScopeName); } /** @@ -92,25 +92,25 @@ public interface OpenTelemetry { * Gets or creates a named meter instance from the {@link MeterProvider} for this {@link * OpenTelemetry}. * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a Meter instance. * @since 1.10.0 */ - default Meter getMeter(String instrumentationName) { - return getMeterProvider().get(instrumentationName); + default Meter getMeter(String instrumentationScopeName) { + return getMeterProvider().get(instrumentationScopeName); } /** * Creates a {@link MeterBuilder} for a named {@link Tracer} instance. * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a MeterBuilder instance. * @since 1.10.0 */ - default MeterBuilder meterBuilder(String instrumentationName) { - return getMeterProvider().meterBuilder(instrumentationName); + default MeterBuilder meterBuilder(String instrumentationScopeName) { + return getMeterProvider().meterBuilder(instrumentationScopeName); } /** Returns the {@link ContextPropagators} for this {@link OpenTelemetry}. */ diff --git a/api/all/src/main/java/io/opentelemetry/api/metrics/DefaultMeterProvider.java b/api/all/src/main/java/io/opentelemetry/api/metrics/DefaultMeterProvider.java index 92dd8005c7..6d1a6de3d4 100644 --- a/api/all/src/main/java/io/opentelemetry/api/metrics/DefaultMeterProvider.java +++ b/api/all/src/main/java/io/opentelemetry/api/metrics/DefaultMeterProvider.java @@ -8,7 +8,7 @@ package io.opentelemetry.api.metrics; /** A {@link MeterProvider} that does nothing. */ class DefaultMeterProvider implements MeterProvider { @Override - public MeterBuilder meterBuilder(String instrumentationName) { + public MeterBuilder meterBuilder(String instrumentationScopeName) { return BUILDER_INSTANCE; } @@ -29,7 +29,7 @@ class DefaultMeterProvider implements MeterProvider { } @Override - public MeterBuilder setInstrumentationVersion(String instrumentationVersion) { + public MeterBuilder setInstrumentationVersion(String instrumentationScopeVersion) { return this; } diff --git a/api/all/src/main/java/io/opentelemetry/api/metrics/Meter.java b/api/all/src/main/java/io/opentelemetry/api/metrics/Meter.java index b3a480ae32..c24f463805 100644 --- a/api/all/src/main/java/io/opentelemetry/api/metrics/Meter.java +++ b/api/all/src/main/java/io/opentelemetry/api/metrics/Meter.java @@ -13,7 +13,7 @@ import javax.annotation.concurrent.ThreadSafe; *

Instruments are obtained through builders provided by this interface. Each builder has a * default "type" associated with recordings that may be changed. * - *

A Meter is generally associated with an instrumentation library, e.g. "I monitor apache + *

A Meter is generally associated with an instrumentation scope, e.g. "I monitor apache * httpclient". * *

Choosing an instrument can be hard, but here's a rule of thumb for selecting the right diff --git a/api/all/src/main/java/io/opentelemetry/api/metrics/MeterBuilder.java b/api/all/src/main/java/io/opentelemetry/api/metrics/MeterBuilder.java index cc445ba1e3..10914306a3 100644 --- a/api/all/src/main/java/io/opentelemetry/api/metrics/MeterBuilder.java +++ b/api/all/src/main/java/io/opentelemetry/api/metrics/MeterBuilder.java @@ -18,19 +18,18 @@ public interface MeterBuilder { *

Schemas are used to identify expected metrics (semantic conventions) and allow backends to * "automatically migrate" to supported versions. * - * @param schemaUrl The URL of the OpenTelemetry schema being used by this instrumentation - * library. + * @param schemaUrl The URL of the OpenTelemetry schema being used by this instrumentation scope. * @return this */ MeterBuilder setSchemaUrl(String schemaUrl); /** - * Assigns a version to the instrumentation library that is using the resulting Meter. + * Assigns a version to the instrumentation scope that is using the resulting Meter. * - * @param instrumentationVersion The version of the instrumentation library. + * @param instrumentationScopeVersion The version of the instrumentation scope. * @return this */ - MeterBuilder setInstrumentationVersion(String instrumentationVersion); + MeterBuilder setInstrumentationVersion(String instrumentationScopeVersion); /** * Gets or creates a {@link Meter} instance. diff --git a/api/all/src/main/java/io/opentelemetry/api/metrics/MeterProvider.java b/api/all/src/main/java/io/opentelemetry/api/metrics/MeterProvider.java index 863f07d5cb..6e88298a98 100644 --- a/api/all/src/main/java/io/opentelemetry/api/metrics/MeterProvider.java +++ b/api/all/src/main/java/io/opentelemetry/api/metrics/MeterProvider.java @@ -23,23 +23,23 @@ public interface MeterProvider { /** * Gets or creates a named and versioned meter instance. * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a meter instance. */ - default Meter get(String instrumentationName) { - return meterBuilder(instrumentationName).build(); + default Meter get(String instrumentationScopeName) { + return meterBuilder(instrumentationScopeName).build(); } /** * Creates a MeterBuilder for a named meter instance. * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a MeterBuilder instance. * @since 1.4.0 */ - MeterBuilder meterBuilder(String instrumentationName); + MeterBuilder meterBuilder(String instrumentationScopeName); /** Returns a no-op {@link MeterProvider} which provides meters which do not record or emit. */ static MeterProvider noop() { diff --git a/api/all/src/main/java/io/opentelemetry/api/trace/DefaultTracerBuilder.java b/api/all/src/main/java/io/opentelemetry/api/trace/DefaultTracerBuilder.java index 91e2e22685..543d9a8cf9 100644 --- a/api/all/src/main/java/io/opentelemetry/api/trace/DefaultTracerBuilder.java +++ b/api/all/src/main/java/io/opentelemetry/api/trace/DefaultTracerBuilder.java @@ -18,7 +18,7 @@ class DefaultTracerBuilder implements TracerBuilder { } @Override - public TracerBuilder setInstrumentationVersion(String instrumentationVersion) { + public TracerBuilder setInstrumentationVersion(String instrumentationScopeVersion) { return this; } diff --git a/api/all/src/main/java/io/opentelemetry/api/trace/DefaultTracerProvider.java b/api/all/src/main/java/io/opentelemetry/api/trace/DefaultTracerProvider.java index ec300a420e..97ddbe0c7b 100644 --- a/api/all/src/main/java/io/opentelemetry/api/trace/DefaultTracerProvider.java +++ b/api/all/src/main/java/io/opentelemetry/api/trace/DefaultTracerProvider.java @@ -17,12 +17,12 @@ class DefaultTracerProvider implements TracerProvider { } @Override - public Tracer get(String instrumentationName) { + public Tracer get(String instrumentationScopeName) { return DefaultTracer.getInstance(); } @Override - public Tracer get(String instrumentationName, String instrumentationVersion) { + public Tracer get(String instrumentationScopeName, String instrumentationScopeVersion) { return DefaultTracer.getInstance(); } diff --git a/api/all/src/main/java/io/opentelemetry/api/trace/TracerBuilder.java b/api/all/src/main/java/io/opentelemetry/api/trace/TracerBuilder.java index 5c35f644be..ba814b3d3c 100644 --- a/api/all/src/main/java/io/opentelemetry/api/trace/TracerBuilder.java +++ b/api/all/src/main/java/io/opentelemetry/api/trace/TracerBuilder.java @@ -15,19 +15,18 @@ public interface TracerBuilder { /** * Assign an OpenTelemetry schema URL to the resulting Tracer. * - * @param schemaUrl The URL of the OpenTelemetry schema being used by this instrumentation - * library. + * @param schemaUrl The URL of the OpenTelemetry schema being used by this instrumentation scope. * @return this */ TracerBuilder setSchemaUrl(String schemaUrl); /** - * Assign a version to the instrumentation library that is using the resulting Tracer. + * Assign a version to the instrumentation scope that is using the resulting Tracer. * - * @param instrumentationVersion The version of the instrumentation library. + * @param instrumentationScopeVersion The version of the instrumentation scope. * @return this */ - TracerBuilder setInstrumentationVersion(String instrumentationVersion); + TracerBuilder setInstrumentationVersion(String instrumentationScopeVersion); /** * Gets or creates a {@link Tracer} instance. diff --git a/api/all/src/main/java/io/opentelemetry/api/trace/TracerProvider.java b/api/all/src/main/java/io/opentelemetry/api/trace/TracerProvider.java index d284f67167..2ef9d12acf 100644 --- a/api/all/src/main/java/io/opentelemetry/api/trace/TracerProvider.java +++ b/api/all/src/main/java/io/opentelemetry/api/trace/TracerProvider.java @@ -27,35 +27,31 @@ public interface TracerProvider { /** * Gets or creates a named tracer instance. * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null. If the - * instrumented library is providing its own instrumentation, this should match the library - * name. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a tracer instance. */ - Tracer get(String instrumentationName); + Tracer get(String instrumentationScopeName); /** * Gets or creates a named and versioned tracer instance. * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null. If the - * instrumented library is providing its own instrumentation, this should match the library - * name. - * @param instrumentationVersion The version of the instrumentation library (e.g., "1.0.0"). + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. + * @param instrumentationScopeVersion The version of the instrumentation scope (e.g., "1.0.0"). * @return a tracer instance. */ - Tracer get(String instrumentationName, String instrumentationVersion); + Tracer get(String instrumentationScopeName, String instrumentationScopeVersion); /** * Creates a TracerBuilder for a named {@link Tracer} instance. * - * @param instrumentationName The name of the instrumentation library, not the name of the - * instrument*ed* library. + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a TracerBuilder instance. * @since 1.4.0 */ - default TracerBuilder tracerBuilder(String instrumentationName) { + default TracerBuilder tracerBuilder(String instrumentationScopeName) { return DefaultTracerBuilder.getInstance(); } } diff --git a/docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt b/docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt index df26146497..33b01551a2 100644 --- a/docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt +++ b/docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt @@ -1,2 +1,12 @@ Comparing source compatibility of against -No changes. \ No newline at end of file ++++ NEW CLASS: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.InstrumentationScopeInfo (not serializable) + +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. + +++ NEW SUPERCLASS: java.lang.Object + +++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.InstrumentationScopeInfo create(java.lang.String) + +++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.InstrumentationScopeInfo create(java.lang.String, java.lang.String, java.lang.String) + +++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.InstrumentationScopeInfo empty() + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getName() + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getSchemaUrl() + +++ NEW ANNOTATION: javax.annotation.Nullable + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getVersion() + +++ NEW ANNOTATION: javax.annotation.Nullable diff --git a/extensions/noop-api/src/main/java/io/opentelemetry/extension/noopapi/NoopTracerProvider.java b/extensions/noop-api/src/main/java/io/opentelemetry/extension/noopapi/NoopTracerProvider.java index 4a0e413828..f74839b24c 100644 --- a/extensions/noop-api/src/main/java/io/opentelemetry/extension/noopapi/NoopTracerProvider.java +++ b/extensions/noop-api/src/main/java/io/opentelemetry/extension/noopapi/NoopTracerProvider.java @@ -20,12 +20,12 @@ enum NoopTracerProvider implements TracerProvider { INSTANCE; @Override - public Tracer get(String instrumentationName) { + public Tracer get(String instrumentationScopeName) { return NoopTracer.INSTANCE; } @Override - public Tracer get(String instrumentationName, String instrumentationVersion) { + public Tracer get(String instrumentationScopeName, String instrumentationScopeVersion) { return NoopTracer.INSTANCE; } diff --git a/sdk/all/src/main/java/io/opentelemetry/sdk/OpenTelemetrySdk.java b/sdk/all/src/main/java/io/opentelemetry/sdk/OpenTelemetrySdk.java index 3a10cb9f64..a915b2e207 100644 --- a/sdk/all/src/main/java/io/opentelemetry/sdk/OpenTelemetrySdk.java +++ b/sdk/all/src/main/java/io/opentelemetry/sdk/OpenTelemetrySdk.java @@ -98,18 +98,18 @@ public final class OpenTelemetrySdk implements OpenTelemetry { } @Override - public Tracer get(String instrumentationName) { - return delegate.get(instrumentationName); + public Tracer get(String instrumentationScopeName) { + return delegate.get(instrumentationScopeName); } @Override - public Tracer get(String instrumentationName, String instrumentationVersion) { - return delegate.get(instrumentationName, instrumentationVersion); + public Tracer get(String instrumentationScopeName, String instrumentationScopeVersion) { + return delegate.get(instrumentationScopeName, instrumentationScopeVersion); } @Override - public TracerBuilder tracerBuilder(String instrumentationName) { - return delegate.tracerBuilder(instrumentationName); + public TracerBuilder tracerBuilder(String instrumentationScopeName) { + return delegate.tracerBuilder(instrumentationScopeName); } public SdkTracerProvider unobfuscate() { @@ -135,8 +135,8 @@ public final class OpenTelemetrySdk implements OpenTelemetry { } @Override - public MeterBuilder meterBuilder(String instrumentationName) { - return delegate.meterBuilder(instrumentationName); + public MeterBuilder meterBuilder(String instrumentationScopeName) { + return delegate.meterBuilder(instrumentationScopeName); } public SdkMeterProvider unobfuscate() { 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 new file mode 100644 index 0000000000..2980d369d2 --- /dev/null +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/common/InstrumentationScopeInfo.java @@ -0,0 +1,60 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.common; + +import static java.util.Objects.requireNonNull; + +import com.google.auto.value.AutoValue; +import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; + +/** + * Holds information about instrumentation scope. + * + *

Instrumentation scope is a logical unit of the application code with which emitted telemetry + * is associated. The most common approach is to use the instrumentation library as the scope, + * however other scopes are also common, e.g. a module, a package, or a class may be chosen as the + * instrumentation scope. + */ +@AutoValue +@Immutable +public abstract class InstrumentationScopeInfo { + private static final InstrumentationScopeInfo EMPTY = create(""); + + /** Creates a new instance of {@link InstrumentationScopeInfo}. */ + public static InstrumentationScopeInfo create(String name) { + requireNonNull(name, "name"); + return new AutoValue_InstrumentationScopeInfo(name, null, null); + } + + /** Creates a new instance of {@link InstrumentationScopeInfo}. */ + public static InstrumentationScopeInfo create( + String name, @Nullable String version, @Nullable String schemaUrl) { + requireNonNull(name, "name"); + return new AutoValue_InstrumentationScopeInfo(name, version, schemaUrl); + } + + /** Returns an "empty" {@link InstrumentationScopeInfo}. */ + public static InstrumentationScopeInfo empty() { + return EMPTY; + } + + /** Returns the name of the instrumentation scope. */ + public abstract String getName(); + + /** Returns the version of the instrumentation scope, or {@code null} if not available. */ + @Nullable + public abstract String getVersion(); + + /** + * Returns the URL of the schema used by this instrumentation scope, or {@code null} if not + * available. + */ + @Nullable + public abstract String getSchemaUrl(); + + InstrumentationScopeInfo() {} +} diff --git a/sdk/common/src/main/java/io/opentelemetry/sdk/internal/ComponentRegistry.java b/sdk/common/src/main/java/io/opentelemetry/sdk/internal/ComponentRegistry.java index 39613fa67c..9aa09ddddb 100644 --- a/sdk/common/src/main/java/io/opentelemetry/sdk/internal/ComponentRegistry.java +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/internal/ComponentRegistry.java @@ -5,7 +5,7 @@ package io.opentelemetry.sdk.internal; -import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -17,17 +17,17 @@ import javax.annotation.Nullable; /** * Base class for all the provider classes (TracerProvider, MeterProvider, etc.). * - *

This class is internal and is hence not for public use. Its APIs are unstable and can hange at - * any time. + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. * * @param the type of the registered value. */ public final class ComponentRegistry { - private final ConcurrentMap registry = new ConcurrentHashMap<>(); - private final Function factory; + private final ConcurrentMap registry = new ConcurrentHashMap<>(); + private final Function factory; - public ComponentRegistry(Function factory) { + public ComponentRegistry(Function factory) { this.factory = factory; } @@ -36,11 +36,11 @@ public final class ComponentRegistry { * otherwise creates a new instance and associates it with the given name and {@code null} version * and schemaUrl. * - * @param instrumentationName the name of the instrumentation library. + * @param instrumentationScopeName the name of the instrumentation scope. * @return the registered value associated with this name and {@code null} version. */ - public V get(String instrumentationName) { - return get(instrumentationName, null); + public V get(String instrumentationScopeName) { + return get(instrumentationScopeName, null); } /** @@ -48,39 +48,40 @@ public final class ComponentRegistry { * new instance and associates it with the given name and version. The schemaUrl will be set to * null. * - * @param instrumentationName the name of the instrumentation library. - * @param instrumentationVersion the version of the instrumentation library. + * @param instrumentationScopeName the name of the instrumentation scope. + * @param instrumentationScopeVersion the version of the instrumentation scope. * @return the registered value associated with this name and version. */ - public V get(String instrumentationName, @Nullable String instrumentationVersion) { - return get(instrumentationName, instrumentationVersion, null); + public V get(String instrumentationScopeName, @Nullable String instrumentationScopeVersion) { + return get(instrumentationScopeName, instrumentationScopeVersion, null); } /** * Returns the registered value associated with this name and version if any, otherwise creates a * new instance and associates it with the given name and version. * - * @param instrumentationName the name of the instrumentation library. - * @param instrumentationVersion the version of the instrumentation library. - * @param schemaUrl the URL of the OpenTelemetry schema used by the instrumentation library. + * @param instrumentationScopeName the name of the instrumentation scope. + * @param instrumentationScopeVersion the version of the instrumentation scope. + * @param schemaUrl the URL of the OpenTelemetry schema used by the instrumentation scope. * @return the registered value associated with this name and version. * @since 1.4.0 */ public V get( - String instrumentationName, - @Nullable String instrumentationVersion, + String instrumentationScopeName, + @Nullable String instrumentationScopeVersion, @Nullable String schemaUrl) { - InstrumentationLibraryInfo instrumentationLibraryInfo = - InstrumentationLibraryInfo.create(instrumentationName, instrumentationVersion, schemaUrl); + InstrumentationScopeInfo instrumentationScopeInfo = + InstrumentationScopeInfo.create( + instrumentationScopeName, instrumentationScopeVersion, schemaUrl); // Optimistic lookup, before creating the new component. - V component = registry.get(instrumentationLibraryInfo); + V component = registry.get(instrumentationScopeInfo); if (component != null) { return component; } - V newComponent = factory.apply(instrumentationLibraryInfo); - V oldComponent = registry.putIfAbsent(instrumentationLibraryInfo, newComponent); + V newComponent = factory.apply(instrumentationScopeInfo); + V oldComponent = registry.putIfAbsent(instrumentationScopeInfo, newComponent); return oldComponent != null ? oldComponent : newComponent; } 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 new file mode 100644 index 0000000000..2236c3fc5f --- /dev/null +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/internal/InstrumentationScopeUtil.java @@ -0,0 +1,27 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.internal; + +import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; + +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public final class InstrumentationScopeUtil { + + /** Convert to {@link InstrumentationLibraryInfo}. */ + public static InstrumentationLibraryInfo toInstrumentationLibraryInfo( + InstrumentationScopeInfo instrumentationScopeInfo) { + return InstrumentationLibraryInfo.create( + instrumentationScopeInfo.getName(), + instrumentationScopeInfo.getVersion(), + instrumentationScopeInfo.getSchemaUrl()); + } + + 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 new file mode 100644 index 0000000000..fd628d3827 --- /dev/null +++ b/sdk/common/src/test/java/io/opentelemetry/sdk/common/InstrumentationScopeInfoTest.java @@ -0,0 +1,27 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.common; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.junit.jupiter.api.Test; + +class InstrumentationScopeInfoTest { + + @Test + void emptyScopeInfo() { + assertThat(InstrumentationScopeInfo.empty().getName()).isEmpty(); + assertThat(InstrumentationScopeInfo.empty().getVersion()).isNull(); + } + + @Test + void nullName() { + assertThatThrownBy(() -> InstrumentationScopeInfo.create(null)) + .isInstanceOf(NullPointerException.class) + .hasMessage("name"); + } +} diff --git a/sdk/common/src/test/java/io/opentelemetry/sdk/internal/ComponentRegistryTest.java b/sdk/common/src/test/java/io/opentelemetry/sdk/internal/ComponentRegistryTest.java index 93c9831040..df2a718191 100644 --- a/sdk/common/src/test/java/io/opentelemetry/sdk/internal/ComponentRegistryTest.java +++ b/sdk/common/src/test/java/io/opentelemetry/sdk/internal/ComponentRegistryTest.java @@ -8,10 +8,9 @@ package io.opentelemetry.sdk.internal; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import org.junit.jupiter.api.Test; -/** Tests for {@link InstrumentationLibraryInfo}. */ class ComponentRegistryTest { private static final String INSTRUMENTATION_NAME = "test_name"; @@ -20,18 +19,18 @@ class ComponentRegistryTest { new ComponentRegistry<>(TestComponent::new); @Test - void libraryName_MustNotBeNull() { + void scopeName_MustNotBeNull() { assertThatThrownBy(() -> registry.get(null, "version")) .isInstanceOf(NullPointerException.class) .hasMessage("name"); } @Test - void libraryVersion_AllowsNull() { + void scopeVersion_AllowsNull() { TestComponent testComponent = registry.get(INSTRUMENTATION_NAME, null); assertThat(testComponent).isNotNull(); - assertThat(testComponent.instrumentationLibraryInfo.getName()).isEqualTo(INSTRUMENTATION_NAME); - assertThat(testComponent.instrumentationLibraryInfo.getVersion()).isNull(); + assertThat(testComponent.instrumentationScopeInfo.getName()).isEqualTo(INSTRUMENTATION_NAME); + assertThat(testComponent.instrumentationScopeInfo.getVersion()).isNull(); } @Test @@ -60,10 +59,10 @@ class ComponentRegistryTest { } private static final class TestComponent { - private final InstrumentationLibraryInfo instrumentationLibraryInfo; + private final InstrumentationScopeInfo instrumentationScopeInfo; - private TestComponent(InstrumentationLibraryInfo instrumentationLibraryInfo) { - this.instrumentationLibraryInfo = instrumentationLibraryInfo; + private TestComponent(InstrumentationScopeInfo instrumentationScopeInfo) { + this.instrumentationScopeInfo = instrumentationScopeInfo; } } } diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogEmitterBuilder.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogEmitterBuilder.java index b31986b853..fc055ab2a4 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogEmitterBuilder.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogEmitterBuilder.java @@ -11,18 +11,18 @@ public interface LogEmitterBuilder { /** * Assign an OpenTelemetry schema URL to the resulting {@link LogEmitter}. * - * @param schemaUrl the URL of the OpenTelemetry schema being used by this instrumentation library + * @param schemaUrl the URL of the OpenTelemetry schema being used by this instrumentation scope * @return this */ LogEmitterBuilder setSchemaUrl(String schemaUrl); /** - * Assign a version to the instrumentation library that is using the resulting {@link LogEmitter}. + * Assign a version to the instrumentation scope that is using the resulting {@link LogEmitter}. * - * @param instrumentationVersion the version of the instrumentation library + * @param instrumentationScopeVersion the version of the instrumentation scope * @return this */ - LogEmitterBuilder setInstrumentationVersion(String instrumentationVersion); + LogEmitterBuilder setInstrumentationVersion(String instrumentationScopeVersion); /** * Gets or creates a {@link LogEmitter} instance. diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitter.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitter.java index 7acf71336a..7de0ca0a23 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitter.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitter.java @@ -6,19 +6,24 @@ package io.opentelemetry.sdk.logs; import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; +import io.opentelemetry.sdk.internal.InstrumentationScopeUtil; import io.opentelemetry.sdk.logs.data.LogDataBuilder; /** SDK implementation of {@link LogEmitter}. */ final class SdkLogEmitter implements LogEmitter { private final LogEmitterSharedState logEmitterSharedState; + private final InstrumentationScopeInfo instrumentationScopeInfo; private final InstrumentationLibraryInfo instrumentationLibraryInfo; SdkLogEmitter( LogEmitterSharedState logEmitterSharedState, - InstrumentationLibraryInfo instrumentationLibraryInfo) { + InstrumentationScopeInfo instrumentationScopeInfo) { this.logEmitterSharedState = logEmitterSharedState; - this.instrumentationLibraryInfo = instrumentationLibraryInfo; + this.instrumentationScopeInfo = instrumentationScopeInfo; + this.instrumentationLibraryInfo = + InstrumentationScopeUtil.toInstrumentationLibraryInfo(instrumentationScopeInfo); } @Override @@ -32,7 +37,7 @@ final class SdkLogEmitter implements LogEmitter { } // VisibleForTesting - InstrumentationLibraryInfo getInstrumentationLibraryInfo() { - return instrumentationLibraryInfo; + InstrumentationScopeInfo getInstrumentationScopeInfo() { + return instrumentationScopeInfo; } } diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitterBuilder.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitterBuilder.java index 30b8903dad..f4eef29135 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitterBuilder.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitterBuilder.java @@ -11,13 +11,13 @@ import javax.annotation.Nullable; final class SdkLogEmitterBuilder implements LogEmitterBuilder { private final ComponentRegistry registry; - private final String instrumentationName; - @Nullable private String getInstrumentationVersion; + private final String instrumentationScopeName; + @Nullable private String instrumentationScopeVersion; @Nullable private String schemaUrl; - SdkLogEmitterBuilder(ComponentRegistry registry, String instrumentationName) { + SdkLogEmitterBuilder(ComponentRegistry registry, String instrumentationScopeName) { this.registry = registry; - this.instrumentationName = instrumentationName; + this.instrumentationScopeName = instrumentationScopeName; } @Override @@ -27,13 +27,13 @@ final class SdkLogEmitterBuilder implements LogEmitterBuilder { } @Override - public SdkLogEmitterBuilder setInstrumentationVersion(String instrumentationVersion) { - this.getInstrumentationVersion = instrumentationVersion; + public SdkLogEmitterBuilder setInstrumentationVersion(String instrumentationScopeVersion) { + this.instrumentationScopeVersion = instrumentationScopeVersion; return this; } @Override public SdkLogEmitter build() { - return registry.get(instrumentationName, getInstrumentationVersion, schemaUrl); + return registry.get(instrumentationScopeName, instrumentationScopeVersion, schemaUrl); } } diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitterProvider.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitterProvider.java index 42da4d200d..b2d14e52cf 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitterProvider.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogEmitterProvider.java @@ -42,32 +42,32 @@ public final class SdkLogEmitterProvider implements Closeable { this.sharedState = new LogEmitterSharedState(resource, logLimitsSupplier, processors, clock); this.logEmitterComponentRegistry = new ComponentRegistry<>( - instrumentationLibraryInfo -> - new SdkLogEmitter(sharedState, instrumentationLibraryInfo)); + instrumentationScopeInfo -> new SdkLogEmitter(sharedState, instrumentationScopeInfo)); } /** * Gets or creates a named log emitter instance. * - * @param instrumentationName the name of the instrumentation library + * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as + * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a log emitter instance */ - public LogEmitter get(String instrumentationName) { - return logEmitterBuilder(instrumentationName).build(); + public LogEmitter get(String instrumentationScopeName) { + return logEmitterBuilder(instrumentationScopeName).build(); } /** * Creates a {@link LogEmitterBuilder} instance. * - * @param instrumentationName the name of the instrumentation library + * @param instrumentationScopeName the name of the instrumentation scope * @return a log emitter builder instance */ - public LogEmitterBuilder logEmitterBuilder(String instrumentationName) { - if (instrumentationName == null || instrumentationName.isEmpty()) { - LOGGER.fine("LogEmitter requested without instrumentation name."); - instrumentationName = DEFAULT_EMITTER_NAME; + public LogEmitterBuilder logEmitterBuilder(String instrumentationScopeName) { + if (instrumentationScopeName == null || instrumentationScopeName.isEmpty()) { + LOGGER.fine("LogEmitter requested without instrumentation scope name."); + instrumentationScopeName = DEFAULT_EMITTER_NAME; } - return new SdkLogEmitterBuilder(logEmitterComponentRegistry, instrumentationName); + return new SdkLogEmitterBuilder(logEmitterComponentRegistry, instrumentationScopeName); } /** 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 47fc11ff2e..5c1c6af6fe 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 @@ -15,7 +15,7 @@ import static org.mockito.Mockito.when; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.sdk.common.Clock; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import io.opentelemetry.sdk.logs.data.LogData; import io.opentelemetry.sdk.resources.Resource; import java.util.ArrayList; @@ -175,8 +175,8 @@ class SdkLogEmitterProviderTest { @Test void logEmitterBuilder_PropagatesToEmitter() { - InstrumentationLibraryInfo expected = - InstrumentationLibraryInfo.create("test", "version", "http://url"); + InstrumentationScopeInfo expected = + InstrumentationScopeInfo.create("test", "version", "http://url"); assertThat( ((SdkLogEmitter) sdkLogEmitterProvider @@ -184,7 +184,7 @@ class SdkLogEmitterProviderTest { .setInstrumentationVersion("version") .setSchemaUrl("http://url") .build()) - .getInstrumentationLibraryInfo()) + .getInstrumentationScopeInfo()) .isEqualTo(expected); } @@ -192,13 +192,13 @@ class SdkLogEmitterProviderTest { void logEmitterBuilder_DefaultEmitterName() { assertThat( ((SdkLogEmitter) sdkLogEmitterProvider.logEmitterBuilder(null).build()) - .getInstrumentationLibraryInfo() + .getInstrumentationScopeInfo() .getName()) .isEqualTo(SdkLogEmitterProvider.DEFAULT_EMITTER_NAME); assertThat( ((SdkLogEmitter) sdkLogEmitterProvider.logEmitterBuilder("").build()) - .getInstrumentationLibraryInfo() + .getInstrumentationScopeInfo() .getName()) .isEqualTo(SdkLogEmitterProvider.DEFAULT_EMITTER_NAME); } diff --git a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogEmitterTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogEmitterTest.java index 527dc7561b..44c04288fe 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogEmitterTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogEmitterTest.java @@ -18,7 +18,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.api.internal.StringUtils; import io.opentelemetry.sdk.common.Clock; -import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import io.opentelemetry.sdk.logs.data.LogData; import io.opentelemetry.sdk.resources.Resource; import java.util.Arrays; @@ -30,7 +30,7 @@ class SdkLogEmitterTest { @Test void logBuilder() { LogEmitterSharedState state = mock(LogEmitterSharedState.class); - InstrumentationLibraryInfo info = InstrumentationLibraryInfo.create("foo", "bar"); + InstrumentationScopeInfo info = InstrumentationScopeInfo.create("foo"); AtomicReference seenLog = new AtomicReference<>(); LogProcessor logProcessor = seenLog::set; Clock clock = mock(Clock.class); diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeter.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeter.java index ce42e6f8ab..5ece228af1 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeter.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeter.java @@ -10,7 +10,8 @@ import io.opentelemetry.api.metrics.DoubleHistogramBuilder; import io.opentelemetry.api.metrics.LongCounterBuilder; import io.opentelemetry.api.metrics.LongUpDownCounterBuilder; import io.opentelemetry.api.metrics.Meter; -import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; +import io.opentelemetry.sdk.internal.InstrumentationScopeUtil; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.internal.export.CollectionInfo; import io.opentelemetry.sdk.metrics.internal.state.MeterProviderSharedState; @@ -19,19 +20,23 @@ import java.util.Collection; /** {@link SdkMeter} is SDK implementation of {@link Meter}. */ final class SdkMeter implements Meter { + private final InstrumentationScopeInfo instrumentationScopeInfo; private final MeterProviderSharedState meterProviderSharedState; private final MeterSharedState meterSharedState; SdkMeter( MeterProviderSharedState meterProviderSharedState, - InstrumentationLibraryInfo instrumentationLibraryInfo) { + InstrumentationScopeInfo instrumentationScopeInfo) { + this.instrumentationScopeInfo = instrumentationScopeInfo; this.meterProviderSharedState = meterProviderSharedState; - this.meterSharedState = MeterSharedState.create(instrumentationLibraryInfo); + this.meterSharedState = + MeterSharedState.create( + InstrumentationScopeUtil.toInstrumentationLibraryInfo(instrumentationScopeInfo)); } - // Only used in testing.... - InstrumentationLibraryInfo getInstrumentationLibraryInfo() { - return meterSharedState.getInstrumentationLibraryInfo(); + // Visible for testing + InstrumentationScopeInfo getInstrumentationScopeInfo() { + return instrumentationScopeInfo; } /** Collects all the metric recordings that changed since the previous call. */ diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeterBuilder.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeterBuilder.java index 47256d489a..eef6be97be 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeterBuilder.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeterBuilder.java @@ -13,13 +13,13 @@ import javax.annotation.Nullable; class SdkMeterBuilder implements MeterBuilder { private final ComponentRegistry registry; - private final String instrumentationName; - @Nullable private String instrumentationVersion; + private final String instrumentationScopeName; + @Nullable private String instrumentationScopeVersion; @Nullable private String schemaUrl; - SdkMeterBuilder(ComponentRegistry registry, String instrumentationName) { + SdkMeterBuilder(ComponentRegistry registry, String instrumentationScopeName) { this.registry = registry; - this.instrumentationName = instrumentationName; + this.instrumentationScopeName = instrumentationScopeName; } @Override @@ -29,13 +29,13 @@ class SdkMeterBuilder implements MeterBuilder { } @Override - public MeterBuilder setInstrumentationVersion(String instrumentationVersion) { - this.instrumentationVersion = instrumentationVersion; + public MeterBuilder setInstrumentationVersion(String instrumentationScopeVersion) { + this.instrumentationScopeVersion = instrumentationScopeVersion; return this; } @Override public Meter build() { - return registry.get(instrumentationName, instrumentationVersion, schemaUrl); + return registry.get(instrumentationScopeName, instrumentationScopeVersion, schemaUrl); } } diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeterProvider.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeterProvider.java index e02efd824f..08843929ee 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeterProvider.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeterProvider.java @@ -88,15 +88,15 @@ public final class SdkMeterProvider implements MeterProvider, Closeable { } @Override - public MeterBuilder meterBuilder(String instrumentationName) { + public MeterBuilder meterBuilder(String instrumentationScopeName) { if (collectionInfoMap.isEmpty()) { - return MeterProvider.noop().meterBuilder(instrumentationName); + return MeterProvider.noop().meterBuilder(instrumentationScopeName); } - if (instrumentationName == null || instrumentationName.isEmpty()) { - LOGGER.fine("Meter requested without instrumentation name."); - instrumentationName = DEFAULT_METER_NAME; + if (instrumentationScopeName == null || instrumentationScopeName.isEmpty()) { + LOGGER.fine("Meter requested without instrumentation scope name."); + instrumentationScopeName = DEFAULT_METER_NAME; } - return new SdkMeterBuilder(registry, instrumentationName); + return new SdkMeterBuilder(registry, instrumentationScopeName); } /** 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 82ae1e0316..74dd24cab6 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 @@ -5,8 +5,8 @@ package io.opentelemetry.sdk.metrics; +import static io.opentelemetry.sdk.internal.InstrumentationScopeUtil.toInstrumentationLibraryInfo; import static io.opentelemetry.sdk.testing.assertj.MetricAssertions.assertThat; -import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; @@ -14,7 +14,8 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.metrics.LongCounter; import io.opentelemetry.api.metrics.Meter; import io.opentelemetry.sdk.common.Clock; -import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; +import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.resources.Resource; import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; import io.opentelemetry.sdk.testing.time.TestClock; @@ -89,9 +90,9 @@ class SdkMeterRegistryTest { } @Test - void propagatesInstrumentationLibraryInfoToMeter() { - InstrumentationLibraryInfo expected = - InstrumentationLibraryInfo.create("theName", "theVersion", "http://theschema"); + void propagatesInstrumentationScopeInfoToMeter() { + InstrumentationScopeInfo expected = + InstrumentationScopeInfo.create("theName", "theVersion", "http://theschema"); SdkMeter meter = (SdkMeter) meterProvider @@ -99,11 +100,10 @@ class SdkMeterRegistryTest { .setInstrumentationVersion(expected.getVersion()) .setSchemaUrl(expected.getSchemaUrl()) .build(); - assertThat(meter.getInstrumentationLibraryInfo()).isEqualTo(expected); + assertThat(meter.getInstrumentationScopeInfo()).isEqualTo(expected); } @Test - @SuppressWarnings("unchecked") void metricProducer_GetAllMetrics() { Meter sdkMeter1 = meterProvider.get("io.opentelemetry.sdk.metrics.MeterSdkRegistryTest_1"); LongCounter longCounter1 = sdkMeter1.counterBuilder("testLongCounter").build(); @@ -127,31 +127,31 @@ class SdkMeterRegistryTest { .hasValue(10) .hasStartEpochNanos(testClock.now()) .hasEpochNanos(testClock.now()))) - .extracting(metric -> metric.getInstrumentationLibraryInfo()) + .extracting(MetricData::getInstrumentationLibraryInfo) .containsExactlyInAnyOrder( - ((SdkMeter) sdkMeter1).getInstrumentationLibraryInfo(), - ((SdkMeter) sdkMeter2).getInstrumentationLibraryInfo()); + toInstrumentationLibraryInfo(((SdkMeter) sdkMeter1).getInstrumentationScopeInfo()), + toInstrumentationLibraryInfo(((SdkMeter) sdkMeter2).getInstrumentationScopeInfo())); } @Test void suppliesDefaultMeterForNullName() { SdkMeter meter = (SdkMeter) meterProvider.get(null); - assertThat(meter.getInstrumentationLibraryInfo().getName()) + assertThat(meter.getInstrumentationScopeInfo().getName()) .isEqualTo(SdkMeterProvider.DEFAULT_METER_NAME); meter = (SdkMeter) meterProvider.meterBuilder(null).build(); - assertThat(meter.getInstrumentationLibraryInfo().getName()) + assertThat(meter.getInstrumentationScopeInfo().getName()) .isEqualTo(SdkMeterProvider.DEFAULT_METER_NAME); } @Test void suppliesDefaultMeterForEmptyName() { SdkMeter meter = (SdkMeter) meterProvider.get(""); - assertThat(meter.getInstrumentationLibraryInfo().getName()) + assertThat(meter.getInstrumentationScopeInfo().getName()) .isEqualTo(SdkMeterProvider.DEFAULT_METER_NAME); meter = (SdkMeter) meterProvider.meterBuilder("").build(); - assertThat(meter.getInstrumentationLibraryInfo().getName()) + assertThat(meter.getInstrumentationScopeInfo().getName()) .isEqualTo(SdkMeterProvider.DEFAULT_METER_NAME); } } diff --git a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracer.java b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracer.java index 12eb453535..8a51ef2605 100644 --- a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracer.java +++ b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracer.java @@ -9,17 +9,22 @@ import io.opentelemetry.api.trace.SpanBuilder; import io.opentelemetry.api.trace.Tracer; import io.opentelemetry.api.trace.TracerProvider; import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; +import io.opentelemetry.sdk.internal.InstrumentationScopeUtil; /** {@link SdkTracer} is SDK implementation of {@link Tracer}. */ final class SdkTracer implements Tracer { static final String FALLBACK_SPAN_NAME = ""; private final TracerSharedState sharedState; + private final InstrumentationScopeInfo instrumentationScopeInfo; private final InstrumentationLibraryInfo instrumentationLibraryInfo; - SdkTracer(TracerSharedState sharedState, InstrumentationLibraryInfo instrumentationLibraryInfo) { + SdkTracer(TracerSharedState sharedState, InstrumentationScopeInfo instrumentationScopeInfo) { this.sharedState = sharedState; - this.instrumentationLibraryInfo = instrumentationLibraryInfo; + this.instrumentationScopeInfo = instrumentationScopeInfo; + this.instrumentationLibraryInfo = + InstrumentationScopeUtil.toInstrumentationLibraryInfo(instrumentationScopeInfo); } @Override @@ -28,19 +33,15 @@ final class SdkTracer implements Tracer { spanName = FALLBACK_SPAN_NAME; } if (sharedState.hasBeenShutdown()) { - Tracer tracer = TracerProvider.noop().get(instrumentationLibraryInfo.getName()); + Tracer tracer = TracerProvider.noop().get(instrumentationScopeInfo.getName()); return tracer.spanBuilder(spanName); } return new SdkSpanBuilder( spanName, instrumentationLibraryInfo, sharedState, sharedState.getSpanLimits()); } - /** - * Returns the instrumentation library specified when creating the tracer. - * - * @return an instance of {@link InstrumentationLibraryInfo} - */ - InstrumentationLibraryInfo getInstrumentationLibraryInfo() { - return instrumentationLibraryInfo; + // Visible for testing + InstrumentationScopeInfo getInstrumentationScopeInfo() { + return instrumentationScopeInfo; } } diff --git a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracerBuilder.java b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracerBuilder.java index 130e775b9f..fb6ccdea62 100644 --- a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracerBuilder.java +++ b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracerBuilder.java @@ -13,13 +13,13 @@ import javax.annotation.Nullable; class SdkTracerBuilder implements TracerBuilder { private final ComponentRegistry registry; - private final String instrumentationName; - @Nullable private String instrumentationVersion; + private final String instrumentationScopeName; + @Nullable private String instrumentationScopeVersion; @Nullable private String schemaUrl; - SdkTracerBuilder(ComponentRegistry registry, String instrumentationName) { + SdkTracerBuilder(ComponentRegistry registry, String instrumentationScopeName) { this.registry = registry; - this.instrumentationName = instrumentationName; + this.instrumentationScopeName = instrumentationScopeName; } @Override @@ -29,13 +29,13 @@ class SdkTracerBuilder implements TracerBuilder { } @Override - public TracerBuilder setInstrumentationVersion(String instrumentationVersion) { - this.instrumentationVersion = instrumentationVersion; + public TracerBuilder setInstrumentationVersion(String instrumentationScopeVersion) { + this.instrumentationScopeVersion = instrumentationScopeVersion; return this; } @Override public Tracer build() { - return registry.get(instrumentationName, instrumentationVersion, schemaUrl); + return registry.get(instrumentationScopeName, instrumentationScopeVersion, schemaUrl); } } diff --git a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracerProvider.java b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracerProvider.java index b371b8a16d..44d33f0934 100644 --- a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracerProvider.java +++ b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkTracerProvider.java @@ -49,29 +49,29 @@ public final class SdkTracerProvider implements TracerProvider, Closeable { clock, idsGenerator, resource, spanLimitsSupplier, sampler, spanProcessors); this.tracerSdkComponentRegistry = new ComponentRegistry<>( - instrumentationLibraryInfo -> new SdkTracer(sharedState, instrumentationLibraryInfo)); + instrumentationScopeInfo -> new SdkTracer(sharedState, instrumentationScopeInfo)); } @Override - public Tracer get(String instrumentationName) { - return tracerBuilder(instrumentationName).build(); + public Tracer get(String instrumentationScopeName) { + return tracerBuilder(instrumentationScopeName).build(); } @Override - public Tracer get(String instrumentationName, String instrumentationVersion) { - return tracerBuilder(instrumentationName) - .setInstrumentationVersion(instrumentationVersion) + public Tracer get(String instrumentationScopeName, String instrumentationScopeVersion) { + return tracerBuilder(instrumentationScopeName) + .setInstrumentationVersion(instrumentationScopeVersion) .build(); } @Override - public TracerBuilder tracerBuilder(@Nullable String instrumentationName) { + public TracerBuilder tracerBuilder(@Nullable String instrumentationScopeName) { // Per the spec, both null and empty are "invalid" and a default value should be used. - if (instrumentationName == null || instrumentationName.isEmpty()) { - logger.fine("Tracer requested without instrumentation name."); - instrumentationName = DEFAULT_TRACER_NAME; + if (instrumentationScopeName == null || instrumentationScopeName.isEmpty()) { + logger.fine("Tracer requested without instrumentation scope name."); + instrumentationScopeName = DEFAULT_TRACER_NAME; } - return new SdkTracerBuilder(tracerSdkComponentRegistry, instrumentationName); + return new SdkTracerBuilder(tracerSdkComponentRegistry, instrumentationScopeName); } /** Returns the {@link SpanLimits} that are currently applied to created spans. */ 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 d1ddf39fe0..95ffa8a6c6 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 @@ -16,7 +16,7 @@ import io.opentelemetry.api.trace.Tracer; import io.opentelemetry.internal.testing.slf4j.SuppressLogger; import io.opentelemetry.sdk.common.Clock; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import io.opentelemetry.sdk.resources.Resource; import io.opentelemetry.sdk.trace.samplers.Sampler; import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; @@ -169,16 +169,16 @@ class SdkTracerProviderTest { } @Test - void propagatesInstrumentationLibraryInfoToTracer() { - InstrumentationLibraryInfo expected = - InstrumentationLibraryInfo.create("theName", "theVersion", "http://url"); + void propagatesInstrumentationScopeInfoToTracer() { + InstrumentationScopeInfo expected = + InstrumentationScopeInfo.create("theName", "theVersion", "http://url"); Tracer tracer = tracerFactory .tracerBuilder(expected.getName()) .setInstrumentationVersion(expected.getVersion()) .setSchemaUrl(expected.getSchemaUrl()) .build(); - assertThat(((SdkTracer) tracer).getInstrumentationLibraryInfo()).isEqualTo(expected); + assertThat(((SdkTracer) tracer).getInstrumentationScopeInfo()).isEqualTo(expected); } @Test @@ -228,22 +228,22 @@ class SdkTracerProviderTest { @Test void suppliesDefaultTracerForNullName() { SdkTracer tracer = (SdkTracer) tracerFactory.get(null); - assertThat(tracer.getInstrumentationLibraryInfo().getName()) + assertThat(tracer.getInstrumentationScopeInfo().getName()) .isEqualTo(SdkTracerProvider.DEFAULT_TRACER_NAME); tracer = (SdkTracer) tracerFactory.get(null, null); - assertThat(tracer.getInstrumentationLibraryInfo().getName()) + assertThat(tracer.getInstrumentationScopeInfo().getName()) .isEqualTo(SdkTracerProvider.DEFAULT_TRACER_NAME); } @Test void suppliesDefaultTracerForEmptyName() { SdkTracer tracer = (SdkTracer) tracerFactory.get(""); - assertThat(tracer.getInstrumentationLibraryInfo().getName()) + assertThat(tracer.getInstrumentationScopeInfo().getName()) .isEqualTo(SdkTracerProvider.DEFAULT_TRACER_NAME); tracer = (SdkTracer) tracerFactory.get("", ""); - assertThat(tracer.getInstrumentationLibraryInfo().getName()) + assertThat(tracer.getInstrumentationScopeInfo().getName()) .isEqualTo(SdkTracerProvider.DEFAULT_TRACER_NAME); } } 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 7bbecf7a6f..e6bd396119 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 @@ -12,6 +12,7 @@ import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.sdk.common.CompletableResultCode; import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import io.opentelemetry.sdk.trace.StressTestRunner.OperationUpdater; import io.opentelemetry.sdk.trace.data.SpanData; import io.opentelemetry.sdk.trace.export.BatchSpanProcessor; @@ -23,18 +24,18 @@ import org.junit.jupiter.api.Test; class SdkTracerTest { private static final String SPAN_NAME = "span_name"; - private static final String INSTRUMENTATION_LIBRARY_NAME = + private static final String INSTRUMENTATION_SCOPE_NAME = "io.opentelemetry.sdk.trace.TracerSdkTest"; - private static final String INSTRUMENTATION_LIBRARY_VERSION = "0.2.0"; - private static final InstrumentationLibraryInfo instrumentationLibraryInfo = - InstrumentationLibraryInfo.create( - INSTRUMENTATION_LIBRARY_NAME, INSTRUMENTATION_LIBRARY_VERSION, "http://schemaurl"); + 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"); private final SdkTracer tracer = (SdkTracer) SdkTracerProvider.builder() .build() - .tracerBuilder(INSTRUMENTATION_LIBRARY_NAME) - .setInstrumentationVersion(INSTRUMENTATION_LIBRARY_VERSION) + .tracerBuilder(INSTRUMENTATION_SCOPE_NAME) + .setInstrumentationVersion(INSTRUMENTATION_SCOPE_VERSION) .setSchemaUrl("http://schemaurl") .build(); @@ -44,14 +45,19 @@ class SdkTracerTest { } @Test - void getInstrumentationLibraryInfo() { - assertThat(tracer.getInstrumentationLibraryInfo()).isEqualTo(instrumentationLibraryInfo); + void getInstrumentationScopeInfo() { + assertThat(tracer.getInstrumentationScopeInfo()).isEqualTo(instrumentationScopeInfo); } @Test - void propagatesInstrumentationLibraryInfoToSpan() { + void propagatesInstrumentationScopeInfoToSpan() { ReadableSpan readableSpan = (ReadableSpan) tracer.spanBuilder("spanName").startSpan(); - assertThat(readableSpan.getInstrumentationLibraryInfo()).isEqualTo(instrumentationLibraryInfo); + assertThat(readableSpan.getInstrumentationLibraryInfo()) + .isEqualTo( + InstrumentationLibraryInfo.create( + instrumentationScopeInfo.getName(), + instrumentationScopeInfo.getVersion(), + instrumentationScopeInfo.getSchemaUrl())); } @Test @@ -70,7 +76,7 @@ class SdkTracerTest { SdkTracerProvider.builder().addSpanProcessor(spanProcessor).build(); SdkTracer tracer = (SdkTracer) - sdkTracerProvider.get(INSTRUMENTATION_LIBRARY_NAME, INSTRUMENTATION_LIBRARY_VERSION); + sdkTracerProvider.get(INSTRUMENTATION_SCOPE_NAME, INSTRUMENTATION_SCOPE_VERSION); StressTestRunner.Builder stressTestBuilder = StressTestRunner.builder().setTracer(tracer).setSpanProcessor(spanProcessor); @@ -93,7 +99,7 @@ class SdkTracerTest { SdkTracerProvider.builder().addSpanProcessor(spanProcessor).build(); SdkTracer tracer = (SdkTracer) - sdkTracerProvider.get(INSTRUMENTATION_LIBRARY_NAME, INSTRUMENTATION_LIBRARY_VERSION); + sdkTracerProvider.get(INSTRUMENTATION_SCOPE_NAME, INSTRUMENTATION_SCOPE_VERSION); StressTestRunner.Builder stressTestBuilder = StressTestRunner.builder().setTracer(tracer).setSpanProcessor(spanProcessor);