diff --git a/eng/versioning/external_dependencies.txt b/eng/versioning/external_dependencies.txt index 9a9c5367cd22a..c190cd9b10034 100644 --- a/eng/versioning/external_dependencies.txt +++ b/eng/versioning/external_dependencies.txt @@ -63,8 +63,8 @@ com.microsoft.azure:azure-storage;8.0.0 com.microsoft.azure:msal4j;1.3.0 com.sun.activation:jakarta.activation;1.2.1 commons-collections:commons-collections;3.2.2 -io.opentelemetry:opentelemetry-api;0.2.0 -io.opentelemetry:opentelemetry-sdk;0.2.0 +io.opentelemetry:opentelemetry-api;0.2.4 +io.opentelemetry:opentelemetry-sdk;0.2.4 io.projectreactor:reactor-test;3.3.0.RELEASE junit:junit;4.13-beta-3 org.assertj:assertj-core;3.11.1 diff --git a/sdk/core/azure-core-tracing-opentelemetry/CHANGELOG.md b/sdk/core/azure-core-tracing-opentelemetry/CHANGELOG.md index 74e6ee3f2dd50..23ccfacb085f2 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/CHANGELOG.md +++ b/sdk/core/azure-core-tracing-opentelemetry/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.0.0-beta.4 (Unreleased) - Keyvault: add az namespace info attribute to all outgoing spans. - +- `io.opentelemetry` version update to `0.2.4` API changes. ## 1.0.0-beta.3 (2020-03-06) diff --git a/sdk/core/azure-core-tracing-opentelemetry/pom.xml b/sdk/core/azure-core-tracing-opentelemetry/pom.xml index 8c436028659c5..d103f1a2141d8 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/pom.xml +++ b/sdk/core/azure-core-tracing-opentelemetry/pom.xml @@ -35,7 +35,7 @@ io.opentelemetry opentelemetry-api - 0.2.0 + 0.2.4 com.azure @@ -47,7 +47,7 @@ io.opentelemetry opentelemetry-sdk - 0.2.0 + 0.2.4 test diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryHttpPolicy.java b/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryHttpPolicy.java index 3af66b7f4be0e..9ea308d7b834b 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryHttpPolicy.java +++ b/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryHttpPolicy.java @@ -14,8 +14,8 @@ import com.azure.core.util.CoreUtils; import com.azure.core.util.UrlBuilder; import io.opentelemetry.OpenTelemetry; +import io.opentelemetry.common.AttributeValue; import io.opentelemetry.context.propagation.HttpTextFormat; -import io.opentelemetry.trace.AttributeValue; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.SpanContext; import io.opentelemetry.trace.Tracer; @@ -42,7 +42,7 @@ public HttpPipelinePolicy create() { } // Singleton OpenTelemetry tracer capable of starting and exporting spans. - private static final Tracer TRACER = OpenTelemetry.getTracerFactory().get("Azure-OpenTelemetry"); + private static final Tracer TRACER = OpenTelemetry.getTracerProvider().get("Azure-OpenTelemetry"); // standard attributes with http call information private static final String HTTP_USER_AGENT = "http.user_agent"; diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracer.java b/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracer.java index 94b31b2552c77..b8aa4948311fa 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracer.java +++ b/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracer.java @@ -11,7 +11,7 @@ import com.azure.core.util.logging.ClientLogger; import com.azure.core.util.tracing.ProcessKind; import io.opentelemetry.OpenTelemetry; -import io.opentelemetry.trace.AttributeValue; +import io.opentelemetry.common.AttributeValue; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.Span.Builder; import io.opentelemetry.trace.SpanContext; @@ -29,7 +29,7 @@ * requests. */ public class OpenTelemetryTracer implements com.azure.core.util.tracing.Tracer { - private static final Tracer TRACER = OpenTelemetry.getTracerFactory().get("Azure-OpenTelemetry"); + private static final Tracer TRACER = OpenTelemetry.getTracerProvider().get("Azure-OpenTelemetry"); // standard attributes with AMQP request static final String AZ_NAMESPACE_KEY = "az.namespace"; diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/implementation/AmqpPropagationFormatUtil.java b/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/implementation/AmqpPropagationFormatUtil.java index 0702a4f8821f2..a943015e8a8c5 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/implementation/AmqpPropagationFormatUtil.java +++ b/sdk/core/azure-core-tracing-opentelemetry/src/main/java/com/azure/core/tracing/opentelemetry/implementation/AmqpPropagationFormatUtil.java @@ -9,7 +9,7 @@ import io.opentelemetry.trace.SpanId; import io.opentelemetry.trace.TraceFlags; import io.opentelemetry.trace.TraceId; -import io.opentelemetry.trace.Tracestate; +import io.opentelemetry.trace.TraceState; import java.util.Objects; @@ -71,13 +71,13 @@ private static SpanContext fromDiagnosticId(String diagnosticId) { TraceId.getInvalid(), SpanId.getInvalid(), TraceFlags.getDefault(), - Tracestate.getDefault() + TraceState.getDefault() ); } return SpanContext.create( TraceId.fromLowerBase16(diagnosticId, 3), SpanId.fromLowerBase16(diagnosticId, 36), TraceFlags.fromLowerBase16(diagnosticId, 53), - Tracestate.builder().build()); + TraceState.builder().build()); } } diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/main/java/module-info.java b/sdk/core/azure-core-tracing-opentelemetry/src/main/java/module-info.java index f3c53360330dc..2776ebee56a90 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/main/java/module-info.java +++ b/sdk/core/azure-core-tracing-opentelemetry/src/main/java/module-info.java @@ -3,7 +3,9 @@ module com.azure.core.tracing.opentelemetry { requires transitive com.azure.core; - requires opentelemetry.api; + + requires io.opentelemetry.api; + requires io.opentelemetry.context.propagation; opens com.azure.core.tracing.opentelemetry to com.fasterxml.jackson.databind; diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/samples/AsyncListKeyVaultSecretsSample.md b/sdk/core/azure-core-tracing-opentelemetry/src/samples/AsyncListKeyVaultSecretsSample.md index 88eadefdf4bda..37a2093eda129 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/samples/AsyncListKeyVaultSecretsSample.md +++ b/sdk/core/azure-core-tracing-opentelemetry/src/samples/AsyncListKeyVaultSecretsSample.md @@ -9,12 +9,12 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** as implementation package io.opentelemetry opentelemetry-sdk - 0.2.0 + 0.2.4 io.opentelemetry opentelemetry-exporters-logging - 0.2.0 + 0.2.4 ``` @@ -23,7 +23,7 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** as implementation package com.azure azure-security-keyvault-secrets - 4.1.0 + 4.2.0-beta.1 ``` [//]: # ({x-version-update-end}) @@ -32,7 +32,7 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** as implementation package com.azure azure-core-tracing-opentelemetry - 1.0.0-beta.2 + 1.0.0-beta.4 ``` [//]: # ({x-version-update-end}) @@ -44,7 +44,7 @@ import com.azure.security.keyvault.secrets.SecretAsyncClient; import com.azure.security.keyvault.secrets.SecretClientBuilder; import com.azure.security.keyvault.secrets.models.KeyVaultSecret; import io.opentelemetry.context.Scope; -import io.opentelemetry.sdk.trace.TracerSdkFactory; +import io.opentelemetry.sdk.trace.TracerSdkProvider; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.Tracer; import reactor.util.context.Context; @@ -61,11 +61,11 @@ public class Sample { private static final Logger LOGGER = getLogger("Sample"); private static final Tracer TRACER; - private static final TracerSdkFactory TRACER_SDK_FACTORY; + private static final TracerSdkProvider TRACER_SDK_PROVIDER; static { - TRACER_SDK_FACTORY = Helper.configureOpenTelemetryAndJaegerExporter(LOGGER); - TRACER = TRACER_SDK_FACTORY.get("Sample"); + TRACER_SDK_PROVIDER = Helper.configureOpenTelemetryAndLoggingExporter(); + TRACER = TRACER_SDK_PROVIDER.get("Sample"); } public static void main(String[] args) throws InterruptedException { @@ -74,9 +74,17 @@ public class Sample { doClientWork(); userSpan.end(); scope.close(); - TRACER_SDK_FACTORY.shutdown(); + TRACER_SDK_PROVIDER.shutdown(); } - + + private static TracerSdkProvider configureOpenTelemetryAndLoggingExporter() { + LoggingExporter exporter = new LoggingExporter(); + TracerSdkProvider tracerSdkProvider = (TracerSdkProvider) OpenTelemetry.getTracerFactory(); + tracerSdkProvider.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build()); + + return tracerSdkProvider; + } + public static void doClientWork() throws InterruptedException { SecretAsyncClient client = new SecretClientBuilder() .vaultUrl("YOUR_VAULT_URL") diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/samples/CreateConfigurationSettingTracingSample.md b/sdk/core/azure-core-tracing-opentelemetry/src/samples/CreateConfigurationSettingTracingSample.md index 5c87cbe731501..fbb6194d4d57d 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/samples/CreateConfigurationSettingTracingSample.md +++ b/sdk/core/azure-core-tracing-opentelemetry/src/samples/CreateConfigurationSettingTracingSample.md @@ -9,12 +9,12 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** as implementation package io.opentelemetry opentelemetry-sdk - 0.2.0 + 0.2.4 io.opentelemetry opentelemetry-exporters-logging - 0.2.0 + 0.2.4 ``` @@ -23,7 +23,7 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** as implementation package com.azure azure-data-appconfiguration - 1.0.1 + 1.2.0-beta.1 ``` [//]: # ({x-version-update-end}) @@ -32,7 +32,7 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** as implementation package com.azure azure-core-tracing-opentelemetry - 1.0.0-beta.2 + 1.0.0-beta.4 ``` [//]: # ({x-version-update-end}) @@ -43,11 +43,8 @@ import com.azure.core.util.Context; import com.azure.data.appconfiguration.ConfigurationClient; import com.azure.data.appconfiguration.ConfigurationClientBuilder; import com.azure.data.appconfiguration.models.ConfigurationSetting; -import io.opentelemetry.OpenTelemetry; import io.opentelemetry.context.Scope; -import io.opentelemetry.exporters.logging.LoggingExporter; -import io.opentelemetry.sdk.trace.TracerSdkFactory; -import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor; +import io.opentelemetry.sdk.trace.TracerSdkProvider; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.Tracer; @@ -60,24 +57,24 @@ public class Sample { final static String CONNECTION_STRING = ""; private static final Logger LOGGER = getLogger("Sample"); private static final Tracer TRACER; - private static final TracerSdkFactory TRACER_SDK_FACTORY; + private static final TracerSdkProvider TRACER_SDK_PROVIDER; static { - TRACER_SDK_FACTORY = configureOpenTelemetryAndLoggingExporter(); - TRACER = TRACER_SDK_FACTORY.get("Sample"); + TRACER_SDK_PROVIDER = configureOpenTelemetryAndLoggingExporter(); + TRACER = TRACER_SDK_PROVIDER.get("Sample"); } public static void main(String[] args) { doClientWork(); - TRACER_SDK_FACTORY.shutdown(); + TRACER_SDK_PROVIDER.shutdown(); } - private static TracerSdkFactory configureOpenTelemetryAndLoggingExporter() { + private static TracerSdkProvider configureOpenTelemetryAndLoggingExporter() { LoggingExporter exporter = new LoggingExporter(); - TracerSdkFactory tracerSdkFactory = (TracerSdkFactory) OpenTelemetry.getTracerFactory(); - tracerSdkFactory.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build()); + TracerSdkProvider tracerSdkProvider = (TracerSdkProvider) OpenTelemetry.getTracerFactory(); + tracerSdkProvider.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build()); - return tracerSdkFactory; + return tracerSdkProvider; } private static void doClientWork() { diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/samples/ListKeyVaultSecretsTracingSample.md b/sdk/core/azure-core-tracing-opentelemetry/src/samples/ListKeyVaultSecretsTracingSample.md index 760d9304e526c..66c6cbcd97a74 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/samples/ListKeyVaultSecretsTracingSample.md +++ b/sdk/core/azure-core-tracing-opentelemetry/src/samples/ListKeyVaultSecretsTracingSample.md @@ -9,12 +9,12 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** as implementation package io.opentelemetry opentelemetry-sdk - 0.2.0 + 0.2.4 io.opentelemetry opentelemetry-exporters-logging - 0.2.0 + 0.2.4 ``` @@ -23,7 +23,7 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** as implementation package com.azure azure-security-keyvault-secrets - 4.1.0 + 4.2.0-beta.1 ``` [//]: # ({x-version-update-end}) @@ -32,7 +32,7 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** as implementation package com.azure azure-core-tracing-opentelemetry - 1.0.0-beta.2 + 1.0.0-beta.4 ``` [//]: # ({x-version-update-end}) @@ -45,7 +45,7 @@ import com.azure.security.keyvault.secrets.SecretClient; import com.azure.security.keyvault.secrets.SecretClientBuilder; import com.azure.security.keyvault.secrets.models.KeyVaultSecret; import io.opentelemetry.context.Scope; -import io.opentelemetry.sdk.trace.TracerSdkFactory; +import io.opentelemetry.sdk.trace.TracerSdkProvider; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.Tracer; @@ -58,29 +58,29 @@ public class Sample { final static String VAULT_URL = ""; private static final Logger LOGGER = getLogger("Sample"); private static final Tracer TRACER; - private static final TracerSdkFactory TRACER_SDK_FACTORY; + private static final TracerSdkProvider TRACER_SDK_PROVIDER; static { - TRACER_SDK_FACTORY = configureOpenTelemetryAndLoggingExporter(); - TRACER = TRACER_SDK_FACTORY.get("Sample"); + TRACER_SDK_PROVIDER = configureOpenTelemetryAndLoggingExporter(); + TRACER = TRACER_SDK_PROVIDER.get("Sample"); } public static void main(String[] args) { doClientWork(); - TRACER_SDK_FACTORY.shutdown(); + TRACER_SDK_PROVIDER.shutdown(); } - private static TracerSdkFactory configureOpenTelemetryAndLoggingExporter() { + private static TracerSdkProvider configureOpenTelemetryAndLoggingExporter() { LoggingExporter exporter = new LoggingExporter(); - TracerSdkFactory tracerSdkFactory = (TracerSdkFactory) OpenTelemetry.getTracerFactory(); - tracerSdkFactory.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build()); + TracerSdkProvider tracerSdkProvider = (TracerSdkProvider) OpenTelemetry.getTracerFactory(); + tracerSdkProvider.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build()); - return tracerSdkFactory; + return tracerSdkProvider; } private static void doClientWork() { SecretClient secretClient = new SecretClientBuilder() - .vaultUrl(VAULT_URL) + .vaultUrl("VAULT_URL") .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/samples/PublishEventsTracingSample.md b/sdk/core/azure-core-tracing-opentelemetry/src/samples/PublishEventsTracingSample.md index e7243cc6b0687..a98564bd8d540 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/samples/PublishEventsTracingSample.md +++ b/sdk/core/azure-core-tracing-opentelemetry/src/samples/PublishEventsTracingSample.md @@ -9,12 +9,12 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** for implementation and ** io.opentelemetry opentelemetry-sdk - 0.2.0 + 0.2.4 io.opentelemetry opentelemetry-exporters-logging - 0.2.0 + 0.2.4 ``` @@ -23,7 +23,7 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** for implementation and ** com.azure azure-messaging-eventhubs - 5.0.1 + 5.0.2 ``` [//]: # ({x-version-update-end}) @@ -32,7 +32,7 @@ Sample uses **[opentelemetry-sdk][opentelemetry_sdk]** for implementation and ** com.azure azure-core-tracing-opentelemetry - 1.0.0-beta.2 + 1.0.0-beta.4 ``` [//]: # ({x-version-update-end}) @@ -44,7 +44,7 @@ import com.azure.messaging.eventhubs.EventData; import com.azure.messaging.eventhubs.EventHubClientBuilder; import com.azure.messaging.eventhubs.EventHubProducerClient; import io.opentelemetry.context.Scope; -import io.opentelemetry.sdk.trace.TracerSdkFactory; +import io.opentelemetry.sdk.trace.TracerSdkProvider; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.Tracer; import reactor.core.publisher.Flux; @@ -56,33 +56,32 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.logging.Logger.getLogger; public class Sample { - final static String VAULT_URL = ""; private static final Logger LOGGER = getLogger("Sample"); private static final Tracer TRACER; - private static final TracerSdkFactory TRACER_SDK_FACTORY; + private static final TracerSdkProvider TRACER_SDK_PROVIDER; private static final Duration OPERATION_TIMEOUT = Duration.ofSeconds(30); static { - TRACER_SDK_FACTORY = configureOpenTelemetryAndLoggingExporter(); - TRACER = TRACER_SDK_FACTORY.get("Sample"); + TRACER_SDK_PROVIDER = configureOpenTelemetryAndLoggingExporter(); + TRACER = TRACER_SDK_PROVIDER.get("Sample"); } public static void main(String[] args) { doClientWork(); - TRACER_SDK_FACTORY.shutdown(); + TRACER_SDK_PROVIDER.shutdown(); } - private static TracerSdkFactory configureOpenTelemetryAndLoggingExporter() { + private static TracerSdkProvider configureOpenTelemetryAndLoggingExporter() { LoggingExporter exporter = new LoggingExporter(); - TracerSdkFactory tracerSdkFactory = (TracerSdkFactory) OpenTelemetry.getTracerFactory(); - tracerSdkFactory.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build()); + TracerSdkProvider tracerSdkProvider = (TracerSdkProvider) OpenTelemetry.getTracerFactory(); + tracerSdkProvider.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build()); - return tracerSdkFactory; + return tracerSdkProvider; } private static void doClientWork() { EventHubProducerAsyncClient producer = new EventHubClientBuilder() - .connectionString(CONNECTION_STRING) + .connectionString("CONNECTION_STRING") .buildAsyncProducerClient(); Span span = TRACER.spanBuilder("user-parent-span").startSpan(); diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/test/java/com/azure/core/tracing/opentelemetry/OpenTelemetryHttpPolicyTests.java b/sdk/core/azure-core-tracing-opentelemetry/src/test/java/com/azure/core/tracing/opentelemetry/OpenTelemetryHttpPolicyTests.java index 22ff418088815..6ef78294fa276 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/test/java/com/azure/core/tracing/opentelemetry/OpenTelemetryHttpPolicyTests.java +++ b/sdk/core/azure-core-tracing-opentelemetry/src/test/java/com/azure/core/tracing/opentelemetry/OpenTelemetryHttpPolicyTests.java @@ -59,7 +59,7 @@ interface TestService { public void openTelemetryHttpPolicyTest() { // Arrange // Get the global singleton Tracer object. - Tracer tracer = OpenTelemetry.getTracerFactory().get("TracerSdkTest"); + Tracer tracer = OpenTelemetry.getTracerProvider().get("TracerSdkTest"); // Start user parent span. Span parentSpan = tracer.spanBuilder(PARENT_SPAN_KEY).startSpan(); tracer.withSpan(parentSpan); @@ -100,7 +100,7 @@ private static void verifySpanContextAttributes(SpanContext expectedSpanContext, assertEquals(expectedSpanContext.getTraceId(), actualSpanContext.getTraceId()); assertNotEquals(expectedSpanContext.getSpanId(), actualSpanContext.getSpanId()); assertEquals(expectedSpanContext.getTraceFlags(), actualSpanContext.getTraceFlags()); - assertEquals(expectedSpanContext.getTracestate(), actualSpanContext.getTracestate()); + assertEquals(expectedSpanContext.getTraceState(), actualSpanContext.getTraceState()); assertEquals(expectedSpanContext.isValid(), actualSpanContext.isValid()); assertEquals(expectedSpanContext.isRemote(), actualSpanContext.isRemote()); } diff --git a/sdk/core/azure-core-tracing-opentelemetry/src/test/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracerTest.java b/sdk/core/azure-core-tracing-opentelemetry/src/test/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracerTest.java index 9840c3d846375..b5401c1bddfde 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/src/test/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracerTest.java +++ b/sdk/core/azure-core-tracing-opentelemetry/src/test/java/com/azure/core/tracing/opentelemetry/OpenTelemetryTracerTest.java @@ -6,17 +6,17 @@ import com.azure.core.util.Context; import com.azure.core.util.tracing.ProcessKind; import io.opentelemetry.OpenTelemetry; +import io.opentelemetry.common.AttributeValue; import io.opentelemetry.sdk.trace.ReadableSpan; -import io.opentelemetry.sdk.trace.SpanData; -import io.opentelemetry.trace.AttributeValue; +import io.opentelemetry.sdk.trace.data.SpanData; import io.opentelemetry.trace.Link; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.SpanContext; import io.opentelemetry.trace.SpanId; import io.opentelemetry.trace.TraceFlags; import io.opentelemetry.trace.TraceId; +import io.opentelemetry.trace.TraceState; import io.opentelemetry.trace.Tracer; -import io.opentelemetry.trace.Tracestate; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -66,7 +66,7 @@ public void setUp() { System.out.println("Running: setUp"); openTelemetryTracer = new OpenTelemetryTracer(); // Get the global singleton Tracer object. - tracer = OpenTelemetry.getTracerFactory().get("TracerSdkTest"); + tracer = OpenTelemetry.getTracerProvider().get("TracerSdkTest"); // Start user parent span. parentSpan = tracer.spanBuilder(PARENT_SPAN_KEY).startSpan(); tracer.withSpan(parentSpan); @@ -247,7 +247,7 @@ public void startProcessSpanWithRemoteParent() { testSpan.getContext().getTraceId(), testSpan.getContext().getSpanId(), testSpan.getContext().getTraceFlags(), - testSpan.getContext().getTracestate()); + testSpan.getContext().getTraceState()); final Context traceContext = tracingContext.addData(SPAN_CONTEXT_KEY, spanContext); // Act @@ -414,7 +414,7 @@ public void extractContextValidDiagnosticId() { TraceId.fromLowerBase16(diagnosticId, 3), SpanId.fromLowerBase16(diagnosticId, 36), TraceFlags.fromLowerBase16(diagnosticId, 53), - Tracestate.builder().build()); + TraceState.builder().build()); // Act Context updatedContext = openTelemetryTracer.extractContext(diagnosticId, Context.NONE); @@ -426,7 +426,6 @@ public void extractContextValidDiagnosticId() { assertEquals(spanContext, validSpanContext); } - @Test public void extractContextInvalidDiagnosticId() { // Arrange @@ -435,7 +434,7 @@ public void extractContextInvalidDiagnosticId() { TraceId.getInvalid(), SpanId.getInvalid(), TraceFlags.getDefault(), - Tracestate.getDefault() + TraceState.getDefault() ); // Act @@ -481,7 +480,6 @@ private static void assertSpanWithRemoteParent(Context updatedContext, SpanId pa assertEquals(parentSpanId, recordEventsSpan.toSpanData().getParentSpanId()); } - private static void verifySpanAttributes(Map actualAttributeMap, Map expectedMapValue) { actualAttributeMap.forEach((attributeKey, attributeValue) ->