diff --git a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml index ea9a06eb9129..154e4abd37d1 100755 --- a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml +++ b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml @@ -76,8 +76,9 @@ - - + + + @@ -126,8 +127,8 @@ - - + + diff --git a/pom.client.xml b/pom.client.xml index 0b5f53afb627..33d80bc2a03d 100644 --- a/pom.client.xml +++ b/pom.client.xml @@ -423,7 +423,8 @@ Azure Telemetry - com.azure.tracing.opentelemetry* + Azure Telemetry - OpenCensus + com.azure.core.tracing* @@ -868,6 +869,6 @@ sdk/storage/azure-storage-file-datalake sdk/storage/azure-storage-queue sdk/storage/azure-storage-queue-cryptography - sdk/tracing/tracing-opentelemetry + sdk/tracing/azure-core-tracing-opencensus diff --git a/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/TracerProvider.java b/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/TracerProvider.java index 81695b067341..f21db781778d 100644 --- a/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/TracerProvider.java +++ b/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/TracerProvider.java @@ -2,8 +2,6 @@ // Licensed under the MIT License. package com.azure.core.amqp.implementation; -import static com.azure.core.util.tracing.Tracer.OPENTELEMETRY_SPAN_KEY; - import com.azure.core.amqp.exception.AmqpException; import com.azure.core.implementation.tracing.ProcessKind; import com.azure.core.util.Context; @@ -14,6 +12,8 @@ import java.util.Objects; import reactor.core.publisher.Signal; +import static com.azure.core.util.tracing.Tracer.OPENCENSUS_SPAN_KEY; + public class TracerProvider { private final ClientLogger logger = new ClientLogger(TracerProvider.class); private final List tracers = new ArrayList<>(); @@ -62,7 +62,7 @@ public void endSpan(Context context, Signal signal) { Objects.requireNonNull(signal, "'signal' cannot be null"); // Get the context that was added to the mono, this will contain the information needed to end the span. - if (!context.getData(OPENTELEMETRY_SPAN_KEY).isPresent()) { + if (!context.getData(OPENCENSUS_SPAN_KEY).isPresent()) { return; } diff --git a/sdk/core/azure-core-amqp/src/test/java/com/azure/core/amqp/implementation/TracerProviderTest.java b/sdk/core/azure-core-amqp/src/test/java/com/azure/core/amqp/implementation/TracerProviderTest.java index 188c1530e38a..c9be69a8a9db 100644 --- a/sdk/core/azure-core-amqp/src/test/java/com/azure/core/amqp/implementation/TracerProviderTest.java +++ b/sdk/core/azure-core-amqp/src/test/java/com/azure/core/amqp/implementation/TracerProviderTest.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.Optional; -import static com.azure.core.util.tracing.Tracer.OPENTELEMETRY_SPAN_KEY; +import static com.azure.core.util.tracing.Tracer.OPENCENSUS_SPAN_KEY; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; @@ -114,7 +114,7 @@ public void startSpanReturnsUpdatedContext() { @Test public void endSpanSuccess() { // Act - tracerProvider.endSpan(new Context(OPENTELEMETRY_SPAN_KEY, "value"), Signal.complete()); + tracerProvider.endSpan(new Context(OPENCENSUS_SPAN_KEY, "value"), Signal.complete()); // Assert for (Tracer t : tracers) { @@ -137,7 +137,7 @@ public void endSpanNoKey() { public void endSpanError() { // Arrange Throwable testThrow = new Throwable("testError"); - Context sendContext = new Context(OPENTELEMETRY_SPAN_KEY, "value"); + Context sendContext = new Context(OPENCENSUS_SPAN_KEY, "value"); // Act tracerProvider.endSpan(sendContext, Signal.error(testThrow)); @@ -152,7 +152,7 @@ public void endSpanError() { public void endSpanOnSubscribe() { // Arrange Throwable testThrow = new Throwable("testError"); - Context sendContext = new Context(OPENTELEMETRY_SPAN_KEY, "value"); + Context sendContext = new Context(OPENCENSUS_SPAN_KEY, "value"); // Act tracerProvider.endSpan(sendContext, Signal.error(testThrow)); @@ -168,7 +168,7 @@ public void endSpanAmqpException() { // Arrange final ErrorCondition errorCondition = ErrorCondition.NOT_FOUND; final Exception exception = new AmqpException(true, errorCondition, "", null); - Context sendContext = new Context(OPENTELEMETRY_SPAN_KEY, "value"); + Context sendContext = new Context(OPENCENSUS_SPAN_KEY, "value"); // Act tracerProvider.endSpan(sendContext, Signal.error(exception)); diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/tracing/Tracer.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/tracing/Tracer.java index eb978487f12e..96e3c19ef41d 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/util/tracing/Tracer.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/tracing/Tracer.java @@ -11,21 +11,21 @@ */ public interface Tracer { /** - * Key for {@link Context} which indicates that the context contains OpenTelemetry span data. This span will be used + * Key for {@link Context} which indicates that the context contains OpenCensus span data. This span will be used * as the parent span for all spans the SDK creates. * * If no span data is listed when the SDK creates its first span it will be used as the parent for all further spans * it creates. */ - String OPENTELEMETRY_SPAN_KEY = "opentelemetry-span"; + String OPENCENSUS_SPAN_KEY = "opencensus-span"; /** - * Key for {@link Context} which indicates that the context contains the name for the OpenTelemetry spans that are + * Key for {@link Context} which indicates that the context contains the name for the OpenCensus spans that are * created. * * If no span name is listed when the span is created it will default to using the calling method's name. */ - String OPENTELEMETRY_SPAN_NAME_KEY = "opentelemetry-span-name"; + String OPENCENSUS_SPAN_NAME_KEY = "opencensus-span-name"; /** * Key for {@link Context} which indicates that the context contains the Entity Path, remote endpoint path. diff --git a/sdk/core/azure-core/src/main/java/module-info.java b/sdk/core/azure-core/src/main/java/module-info.java index 0b6d1d43f75b..fa29c322ba1d 100644 --- a/sdk/core/azure-core/src/main/java/module-info.java +++ b/sdk/core/azure-core/src/main/java/module-info.java @@ -91,9 +91,10 @@ com.azure.storage.file, // FIXME this should not be a long-term solution com.azure.storage.queue; // FIXME this should not be a long-term solution exports com.azure.core.implementation.util to + com.azure.core.amqp, // FIXME this should not be a long-term solution com.azure.core.management, // FIXME this should not be a long-term solution com.azure.core.test, // FIXME this should not be a long-term solution - com.azure.core.amqp, // FIXME this should not be a long-term solution + com.azure.core.tracing.opencensus, // FIXME this should not be a long-term solution com.azure.data.appconfiguration, // FIXME this should not be a long-term solution com.azure.http.netty, // FIXME this should not be a long-term solution com.azure.messaging.eventhubs, // FIXME this should not be a long-term solution @@ -103,7 +104,6 @@ com.azure.security.keyvault.keys, // FIXME this should not be a long-term solution com.azure.security.keyvault.secrets, // FIXME this should not be a long-term solution com.azure.storage.common, // FIXME this should not be a long-term solution - com.azure.tracing.opentelemetry, // FIXME this should not be a long-term solution com.azure.storage.blob, // FIXME this should not be a long-term solution com.azure.storage.file, // FIXME this should not be a long-term solution com.azure.storage.queue; // FIXME this should not be a long-term solution @@ -118,7 +118,7 @@ com.azure.security.keyvault.keys, // FIXME this should not be a long-term solution com.azure.security.keyvault.secrets, // FIXME this should not be a long-term solution com.azure.storage.common, // FIXME this should not be a long-term solution - com.azure.tracing.opentelemetry, // FIXME this should not be a long-term solution + com.azure.core.tracing.opencensus, // FIXME this should not be a long-term solution com.azure.storage.blob, // FIXME this should not be a long-term solution com.azure.storage.file, // FIXME this should not be a long-term solution com.azure.storage.queue; // FIXME this should not be a long-term solution @@ -133,7 +133,7 @@ com.azure.security.keyvault.keys, // FIXME this should not be a long-term solution com.azure.security.keyvault.secrets, // FIXME this should not be a long-term solution com.azure.storage.common, // FIXME this should not be a long-term solution - com.azure.tracing.opentelemetry, // FIXME this should not be a long-term solution + com.azure.core.tracing.opencensus, // FIXME this should not be a long-term solution com.azure.storage.blob, // FIXME this should not be a long-term solution com.azure.storage.file, // FIXME this should not be a long-term solution com.azure.storage.queue; diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubAsyncProducerTest.java b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubAsyncProducerTest.java index e061cb6c1488..3e685cc0f5ff 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubAsyncProducerTest.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubAsyncProducerTest.java @@ -36,7 +36,7 @@ import java.util.List; import static com.azure.core.util.tracing.Tracer.DIAGNOSTIC_ID_KEY; -import static com.azure.core.util.tracing.Tracer.OPENTELEMETRY_SPAN_KEY; +import static com.azure.core.util.tracing.Tracer.OPENCENSUS_SPAN_KEY; import static com.azure.core.util.tracing.Tracer.SPAN_CONTEXT; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.ArgumentMatchers.any; @@ -196,14 +196,14 @@ public void sendStartSpanSingleMessage() { when(tracer1.start(eq("Azure.eventhubs.send"), any(), eq(ProcessKind.SEND))).thenAnswer( invocation -> { Context passed = invocation.getArgument(1, Context.class); - return passed.addData(OPENTELEMETRY_SPAN_KEY, "value"); + return passed.addData(OPENCENSUS_SPAN_KEY, "value"); } ); when(tracer1.start(eq("Azure.eventhubs.message"), any(), eq(ProcessKind.RECEIVE))).thenAnswer( invocation -> { Context passed = invocation.getArgument(1, Context.class); - return passed.addData(OPENTELEMETRY_SPAN_KEY, "value").addData(DIAGNOSTIC_ID_KEY, "value2"); + return passed.addData(OPENCENSUS_SPAN_KEY, "value").addData(DIAGNOSTIC_ID_KEY, "value2"); } ); @@ -243,7 +243,7 @@ public void sendMessageAddlink() { when(tracer1.start(eq("Azure.eventhubs.send"), any(), eq(ProcessKind.SEND))).thenAnswer( invocation -> { Context passed = invocation.getArgument(1, Context.class); - return passed.addData(OPENTELEMETRY_SPAN_KEY, "value"); + return passed.addData(OPENCENSUS_SPAN_KEY, "value"); } ); diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerTest.java b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerTest.java index e3e7a83b9bc4..6297f34fba7d 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerTest.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerTest.java @@ -37,7 +37,7 @@ import java.util.List; import static com.azure.core.util.tracing.Tracer.DIAGNOSTIC_ID_KEY; -import static com.azure.core.util.tracing.Tracer.OPENTELEMETRY_SPAN_KEY; +import static com.azure.core.util.tracing.Tracer.OPENCENSUS_SPAN_KEY; import static com.azure.core.util.tracing.Tracer.SPAN_CONTEXT; import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.ArgumentMatchers.any; @@ -126,14 +126,14 @@ public void sendStartSpanSingleMessage() { when(tracer1.start(eq("Azure.eventhubs.send"), any(), eq(ProcessKind.SEND))).thenAnswer( invocation -> { Context passed = invocation.getArgument(1, Context.class); - return passed.addData(OPENTELEMETRY_SPAN_KEY, "value"); + return passed.addData(OPENCENSUS_SPAN_KEY, "value"); } ); when(tracer1.start(eq("Azure.eventhubs.message"), any(), eq(ProcessKind.RECEIVE))).thenAnswer( invocation -> { Context passed = invocation.getArgument(1, Context.class); - return passed.addData(OPENTELEMETRY_SPAN_KEY, "value").addData(DIAGNOSTIC_ID_KEY, "value2"); + return passed.addData(OPENCENSUS_SPAN_KEY, "value").addData(DIAGNOSTIC_ID_KEY, "value2"); } ); //Act @@ -166,7 +166,7 @@ public void sendMessageAddlink() { when(tracer1.start(eq("Azure.eventhubs.send"), any(), eq(ProcessKind.SEND))).thenAnswer( invocation -> { Context passed = invocation.getArgument(1, Context.class); - return passed.addData(OPENTELEMETRY_SPAN_KEY, "value"); + return passed.addData(OPENCENSUS_SPAN_KEY, "value"); } ); diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventProcessorTest.java b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventProcessorTest.java index 8fc1daa81d7c..576992d7b826 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventProcessorTest.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventProcessorTest.java @@ -4,7 +4,7 @@ package com.azure.messaging.eventhubs; import static com.azure.core.util.tracing.Tracer.DIAGNOSTIC_ID_KEY; -import static com.azure.core.util.tracing.Tracer.OPENTELEMETRY_SPAN_KEY; +import static com.azure.core.util.tracing.Tracer.OPENCENSUS_SPAN_KEY; import static com.azure.core.util.tracing.Tracer.SPAN_CONTEXT; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -217,7 +217,7 @@ public void testErrorProcessSpans() throws Exception { return passed.addData(SPAN_CONTEXT, "value1") .addData("scope", (Closeable) () -> { }) - .addData(OPENTELEMETRY_SPAN_KEY, "value2"); + .addData(OPENCENSUS_SPAN_KEY, "value2"); } ); @@ -274,7 +274,7 @@ public void testProcessSpans() throws Exception { Context passed = invocation.getArgument(1, Context.class); return passed.addData(SPAN_CONTEXT, "value1").addData("scope", (Closeable) () -> { return; - }).addData(OPENTELEMETRY_SPAN_KEY, "value2"); + }).addData(OPENCENSUS_SPAN_KEY, "value2"); } ); diff --git a/sdk/tracing/README.md b/sdk/tracing/README.md deleted file mode 100644 index 9676eba059f7..000000000000 --- a/sdk/tracing/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Azure Tracing client library for Java -This package contains the OpenTelemetry tracing plugin for Azure SDK Java libraries. - -## Getting started - -## Key concepts - -## Examples - -## Troubleshooting - -## Next steps - -## Contributing -This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. - -When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments. - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java/sdk/tracing/README.png) \ No newline at end of file diff --git a/sdk/tracing/tracing-opentelemetry/CHANGELOG.md b/sdk/tracing/azure-core-tracing-opencensus/CHANGELOG.md similarity index 100% rename from sdk/tracing/tracing-opentelemetry/CHANGELOG.md rename to sdk/tracing/azure-core-tracing-opencensus/CHANGELOG.md diff --git a/sdk/tracing/azure-core-tracing-opencensus/README.md b/sdk/tracing/azure-core-tracing-opencensus/README.md new file mode 100644 index 000000000000..cc38f69cd7df --- /dev/null +++ b/sdk/tracing/azure-core-tracing-opencensus/README.md @@ -0,0 +1,228 @@ +# Azure Tracing client library for Java +This package enables distributed tracing across Azure SDK Java libraries through [Opencensus][opencensus]. OpenCensus is an open source, vendor-agnostic, single distribution of libraries to provide metrics collection and distributed tracing for services. +The Azure core tracing package provides: +- Context propagation, in order to correlate activities and requests between services with an initial customer action. +- Tracing user requests to the system, allowing to pinpoint failures and performance issues. + +[Source code][source_code] | [API reference documentation][api_documentation] | [Product +documentation][api_documentation] | [Samples][samples] + +## Getting started +### Prerequisites +- Java Development Kit (JDK) with version 8 or above +- [Maven][maven] +```xml + + io.opencensus + opencensus-api + 0.21.0 + + + + io.opencensus + opencensus-impl + 0.21.0 + +``` + +### Adding the package to your product +```xml + + com.azure + azure-core-tracing-opencensus + 1.0.0-preview.3 + +``` + +### Default HTTP Client +All client libraries support a pluggable HTTP transport layer. Users can specify an HTTP client specific for their needs by including the following dependency in the Maven pom.xml file: + +```xml + + com.azure + azure-core-http-netty + 1.0.0-preview.4 + +``` + +This will automatically configure all client libraries on the same classpath to make use of Netty for the HTTP client. Netty is the recommended HTTP client for most applications. OkHttp is recommended only when the application being built is deployed to Android devices. + +If, instead of Netty it is preferable to use OkHTTP, there is a HTTP client available for that too. Simply include the following dependency instead: + +```xml + + com.azure + azure-core-http-okhttp + 1.0.0-preview.4 + +``` + +### Configuring HTTP clients +When an HTTP client is included on the classpath, as shown above, it is not necessary to specify it in the client library [builders][create-eventhubs-builders], unless you want to customize the HTTP client in some fashion. If this is desired, the `httpClient` builder method is often available to achieve just this, by allowing users to provide a custom (or customized) `com.azure.core.http.HttpClient` instances. + +For starters, by having the Netty or OkHTTP dependencies on your classpath, as shown above, you can create new instances of these `HttpClient` types using their builder APIs. For example, here is how you would create a Netty HttpClient instance: + +```java +HttpClient client = new NettyAsyncHttpClientBuilder() + .port(8080) + .wiretap(true) + .build(); +``` + +## Key concepts +### Trace +A trace is a tree of spans showing the path of work through a system. A trace on its own is distinguishable by a unique 16 byte sequence called a TraceID. +### Span +A span represents a single operation in a trace. A span could be representative of an HTTP request, a remote procedure call (RPC), a database query, or even the path that a code takes. + +## Examples +The following sections provides examples of using the azure-core-tracing-opencensus plugin with some of the Azure Java SDK libraries: +### Using the plugin package with HTTP client libraries +- Sync create a secret using [azure-keyvault-secrets][azure-keyvault-secrets] with tracing enabled. + + Users can additionally pass the value of the current tracing span to the SDKs using key **"opencensus-span"** on the [Context][context] parameter of the calling method: + ```java + import com.azure.identity.credential.DefaultAzureCredentialBuilder; + import com.azure.security.keyvault.secrets.SecretClientBuilder; + import com.azure.security.keyvault.secrets.SecretClient; + import com.azure.security.keyvault.secrets.models.Secret; + import io.opencensus.common.Scope; + import io.opencensus.trace.Tracer; + import io.opencensus.trace.Tracing; + import com.azure.core.util.Context; + + import static com.azure.core.implementation.tracing.Tracer.OPENCENSUS_SPAN_KEY; + + SecretClient client = new SecretClientBuilder() + .endpoint("") + .credential(new DefaultAzureCredentialBuilder().build()) + .buildClient(); + + Tracer tracer = Tracing.getTracer(); + + try (Scope scope = tracer.spanBuilder("tracing-user-span").startScopedSpan()) { + + // Create context with key "opencensus-span" and current tracing span as value + Context tracingContext = new Context(OPENCENSUS_SPAN_KEY, tracer.getCurrentSpan()); + + // Set secret and pass tracing context to pass the user-span to calling methods + Secret secret = secretClient.setSecretWithResponse(new Secret("secret_name", "secret_value", tracingContext)); + System.out.printf("Secret is created with name %s and value %s %n", secret.getName(), secret.getValue()); + } + ``` +- Async create a secret using [azure-keyvault-secrets][azure-keyvault-secrets] with tracing enabled. + + To enabled tracing in async clients, users can additionally pass the value of the current tracing span to the SDKs using key **"opencensus-span"** on the subscriberContext of the calling method: + ```java + import com.azure.identity.credential.DefaultAzureCredentialBuilder; + import com.azure.security.keyvault.secrets.SecretClientBuilder; + import com.azure.security.keyvault.secrets.SecretAsyncClient; + import com.azure.security.keyvault.secrets.models.Secret; + import io.opencensus.common.Scope; + import io.opencensus.trace.Tracer; + import io.opencensus.trace.Tracing; + import com.azure.core.util.Context; + + import static com.azure.core.implementation.tracing.Tracer.OPENCENSUS_SPAN_KEY; + + SecretAsyncClient secretAsyncClient = new SecretClientBuilder() + .endpoint("") + .credential(new DefaultAzureCredentialBuilder().build()) + .buildClient(); + + Tracer tracer = Tracing.getTracer(); + + Scope scope = tracer.spanBuilder("tracing-user-span").startScopedSpan()) + // Set secret and pass tracing context with method call + secretAsyncClient.setSecret(new Secret("secret_name", "secret_value") + .subscriberContext(Context.of(OPENCENSUS_SPAN_KEY, tracer.getCurrentSpan()).doFinally(secret -> + System.out.printf("Secret is created with name %s and value %s %n", secret.getName(), secret.getValue())); + scope.close(); + ``` + +### Using the plugin package with AMQP client libraries +Async send single event using [azure-messaging-eventhubs][azure-messaging-eventhubs] with tracing. + +Users can additionally pass the value of the current tracing span to the EventData object with key **"opencensus-span"** on the [Context][context] object: + +```java +import io.opencensus.common.Scope; +import io.opencensus.trace.Tracer; +import io.opencensus.trace.Tracing; +import com.azure.core.util.Context; +import com.azure.messaging.eventhubs.EventData; +import com.azure.messaging.eventhubs.EventHubAsyncClient; +import com.azure.messaging.eventhubs.EventHubAsyncProducer; +import com.azure.messaging.eventhubs.EventHubClientBuilder; + +EventHubAsyncClient client = new EventHubClientBuilder() + .connectionString("<< CONNECTION STRING FOR SPECIFIC EVENT HUB INSTANCE >>") + .buildAsyncClient(); +EventHubAsyncProducer producer = client.createProducer(); + +Scope scope = tracer.spanBuilder("tracing-user-span").startScopedSpan()) +Context tracingContext = new Context(OPENCENSUS_SPAN_KEY, tracer.getCurrentSpan()); +// Create an event to send +final EventData eventData = new EventData("Hello world!".getBytes(UTF_8)); +// Add tracing context to the event +eventData.context(tracingContext); +producer.send(eventData).doFinally((ignored) -> System.out.println("Event sent.")); +scope.close(); +``` + +## Troubleshooting +### General + +For more information on Opencensus Java support for tracing, see [Opencensus Java Quickstart][opencensus-quickstart]. + +Please refer to the [Quickstart Zipkin][zipkin-quickstart] for more documentation on using a Zipkin exporter. + +## Next steps +### Samples +Several Java SDK samples are available to you in the SDKs GitHub repository. +These following samples provide example code for additional scenarios commonly encountered while working with Tracing: + +#### Enqueue and dequeue messages using Storage Queue client +* [HelloWorld.java][sample_helloWorld] and [HelloWorldAsync.java][sample_helloWorldAsync] - Contains samples for following scenarios with tracing support: + * Create a Queue client using [azure-storage-queue][azure-storage-queue] Java SDK. + * Enqueue and dequeue messages using the created Queue client. +#### List Operations for secrets in a Key Vault +* [ListOperations.java][sample_list] and [ListOperationsAsync.java][sample_list_async] - Contains samples for following scenarios with tracing support: + * Create a secret. + * List secrets. + * Create new version of an existing secret. + * List versions of an existing secret. +#### Publish multiple Events to an Event Hub +* [PublishEvents.java][sample_publish_events] - Contains sample for publishing multiple events with tracing support. + +### Additional Documentation +For more extensive documentation on OpenCensus, see the [API reference documentation][opencensus]. + +## Contributing +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments. + + +[api_documentation]: https://azure.github.io/azure-sdk-for-java/track2reports/index.html +[azure-keyvault-secrets]: ../keyvault/azure-keyvault-secrets +[azure-messaging-eventhubs]: ../eventhubs/azure-messaging-eventhubs +[azure-storage-queue]: ../storage/azure-storage-queue +[context]: ../core/azure-core/src/main/java/com/azure/core/util/Context.java +[create-eventhubs-builders]: ../eventhubs/azure-messaging-eventhubs#create-an-event-hub-client-using-a-connection-string +[maven]: https://maven.apache.org/ +[source_code]: src +[api_documentation]: https://aka.ms/java-docs +[sample_helloWorld]: ./src/samples/java/com/azure/core/tracing//HelloWorld.java +[sample_helloWorldAsync]: ./src/samples/java/com/azure/core/tracing/HelloWorldAsync.java +[sample_list]: ./src/samples/java/com/azure/core/tracing//ListOperationsTracing.java +[sample_list_async]: ./src/samples/java/com/azure/core/tracing//ListOperationsAsync.java +[sample_publish_events]: ./src/samples/java/com/azure/core/tracing/PublishEvents.java +[samples]: ./src/samples/java/com/azure/core/tracing/ +[opencensus]: https://opencensus.io/quickstart/java/tracing/ +[opencensus-quickstart]: https://opencensus.io/quickstart/java/tracing/ +[zipkin-quickstart]: https://zipkin.io/pages/quickstart + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java/sdk/tracing/README.png) diff --git a/sdk/tracing/azure-core-tracing-opencensus/pom.xml b/sdk/tracing/azure-core-tracing-opencensus/pom.xml new file mode 100644 index 000000000000..5642787fc404 --- /dev/null +++ b/sdk/tracing/azure-core-tracing-opencensus/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.4.0 + ../../../pom.client.xml + + + com.azure + azure-core-tracing-opencensus + 1.0.0-preview.3 + + Microsoft Azure OpenCensus tracing plugin + This package contains the OpenCensus tracing plugin for Azure client libraries. + https://github.com/Azure/azure-sdk-for-java + + + + azure-java-build-docs + ${site.url}/site/${project.artifactId} + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + + com.azure + azure-core + 1.0.0-preview.5 + + + io.opencensus + opencensus-api + + + + io.opencensus + opencensus-exporter-trace-zipkin + 0.20.0 + test + + + com.azure + azure-storage-queue + 12.0.0-preview.4 + test + + + com.azure + azure-keyvault-secrets + 4.0.0-preview.4 + test + + + com.azure + azure-identity + 1.0.0-preview.4 + test + + + com.azure + azure-messaging-eventhubs + 5.0.0-preview.4 + test + + + diff --git a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/OpenTelemetryHttpPolicy.java b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/OpenCensusHttpPolicy.java similarity index 89% rename from sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/OpenTelemetryHttpPolicy.java rename to sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/OpenCensusHttpPolicy.java index 2d2ae1ebf25a..97228999a03e 100644 --- a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/OpenTelemetryHttpPolicy.java +++ b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/OpenCensusHttpPolicy.java @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.tracing.opentelemetry; +package com.azure.core.tracing.opencensus; import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpPipelineCallContext; import com.azure.core.http.HttpPipelineNextPolicy; import com.azure.core.http.HttpRequest; import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.HttpPipelinePolicy; import com.azure.core.http.policy.AfterRetryPolicyProvider; +import com.azure.core.http.policy.HttpPipelinePolicy; import com.azure.core.implementation.util.ImplUtils; -import com.azure.tracing.opentelemetry.implementation.HttpTraceUtil; +import com.azure.core.tracing.opencensus.implementation.HttpTraceUtil; import io.opencensus.trace.AttributeValue; import io.opencensus.trace.Span; import io.opencensus.trace.Span.Kind; @@ -27,22 +27,22 @@ import java.util.Optional; +import static com.azure.core.util.tracing.Tracer.OPENCENSUS_SPAN_KEY; + /** - * Pipeline policy that creates an OpenTelemetry span which traces the service request. + * Pipeline policy that creates an OpenCensus span which traces the service request. */ -public class OpenTelemetryHttpPolicy implements AfterRetryPolicyProvider, HttpPipelinePolicy { +public class OpenCensusHttpPolicy implements AfterRetryPolicyProvider, HttpPipelinePolicy { /** - * @return a OpenTelemetry HTTP policy. + * @return a OpenCensus HTTP policy. */ public HttpPipelinePolicy create() { return this; } - // Singleton OpenTelemetry tracer capable of starting and exporting spans. + // Singleton OpenCensus tracer capable of starting and exporting spans. private static final Tracer TRACER = Tracing.getTracer(); - private static final String OPENTELEMETRY_SPAN_KEY = - com.azure.core.util.tracing.Tracer.OPENTELEMETRY_SPAN_KEY; // standard attributes with http call information private static final String HTTP_USER_AGENT = "http.user_agent"; @@ -57,7 +57,7 @@ public HttpPipelinePolicy create() { @Override public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { - Span parentSpan = (Span) context.getData(OPENTELEMETRY_SPAN_KEY).orElse(TRACER.getCurrentSpan()); + Span parentSpan = (Span) context.getData(OPENCENSUS_SPAN_KEY).orElse(TRACER.getCurrentSpan()); HttpRequest request = context.getHttpRequest(); // Build new child span representing this outgoing request. @@ -82,7 +82,7 @@ public Mono process(HttpPipelineCallContext context, HttpPipelineN // run the next policy and handle success and error return next.process() - .doOnEach(OpenTelemetryHttpPolicy::handleResponse) + .doOnEach(OpenCensusHttpPolicy::handleResponse) .subscriberContext(Context.of("TRACING_SPAN", span, "REQUEST", request)); } @@ -162,7 +162,7 @@ private static void spanEnd(Span span, HttpResponse response, Throwable error) { private final TextFormat.Setter contextSetter = new TextFormat.Setter() { @Override public void put(HttpRequest request, String key, String value) { - request.setHeader(key, value); + request.getHeaders().put(key, value); } }; } diff --git a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/OpenTelemetryTracer.java b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/OpenCensusTracer.java similarity index 80% rename from sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/OpenTelemetryTracer.java rename to sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/OpenCensusTracer.java index 564499d464fe..63a186ced860 100644 --- a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/OpenTelemetryTracer.java +++ b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/OpenCensusTracer.java @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.tracing.opentelemetry; +package com.azure.core.tracing.opencensus; import com.azure.core.implementation.tracing.ProcessKind; import com.azure.core.implementation.util.ImplUtils; +import com.azure.core.tracing.opencensus.implementation.AmqpPropagationFormatUtil; +import com.azure.core.tracing.opencensus.implementation.AmqpTraceUtil; +import com.azure.core.tracing.opencensus.implementation.HttpTraceUtil; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; -import com.azure.tracing.opentelemetry.implementation.AmqpPropagationFormatUtil; -import com.azure.tracing.opentelemetry.implementation.AmqpTraceUtil; -import com.azure.tracing.opentelemetry.implementation.HttpTraceUtil; import io.opencensus.trace.AttributeValue; import io.opencensus.trace.Link; import io.opencensus.trace.Span; @@ -19,16 +19,15 @@ import io.opencensus.trace.Tracer; import io.opencensus.trace.Tracing; -import java.util.Locale; import java.util.Optional; import static io.opencensus.trace.Link.Type.PARENT_LINKED_SPAN; /** - * OpenTelemetry span + * OpenCensus span */ -public class OpenTelemetryTracer implements com.azure.core.util.tracing.Tracer { - // Singleton OpenTelemetry tracer capable of starting and exporting spans. +public class OpenCensusTracer implements com.azure.core.util.tracing.Tracer { + // Singleton OpenCensus tracer capable of starting and exporting spans. private static final Tracer TRACER = Tracing.getTracer(); // standard attributes with AMQP call information @@ -36,17 +35,17 @@ public class OpenTelemetryTracer implements com.azure.core.util.tracing.Tracer { private static final String MESSAGE_BUS_DESTINATION = "message_bus.destination"; private static final String PEER_ENDPOINT = "peer.address"; - private final ClientLogger logger = new ClientLogger(OpenTelemetryTracer.class); + private final ClientLogger logger = new ClientLogger(OpenCensusTracer.class); @Override public Context start(String methodName, Context context) { - Span parentSpan = (Span) context.getData(OPENTELEMETRY_SPAN_KEY).orElse(TRACER.getCurrentSpan()); - String spanName = (String) context.getData(OPENTELEMETRY_SPAN_NAME_KEY).orElse(methodName); + Span parentSpan = (Span) context.getData(OPENCENSUS_SPAN_KEY).orElse(TRACER.getCurrentSpan()); + String spanName = (String) context.getData(OPENCENSUS_SPAN_NAME_KEY).orElse(methodName); SpanBuilder spanBuilder = TRACER.spanBuilderWithExplicitParent(spanName, parentSpan); Span span = spanBuilder.startSpan(); - return context.addData(OPENTELEMETRY_SPAN_KEY, span); + return context.addData(OPENCENSUS_SPAN_KEY, span); } @Override @@ -61,13 +60,13 @@ public Context start(String spanName, Context context, ProcessKind processKind) // If span is sampled in, add additional TRACING attributes addSpanRequestAttributes(span, context, spanName); } - return context.addData(OPENTELEMETRY_SPAN_KEY, span); + return context.addData(OPENCENSUS_SPAN_KEY, span); case RECEIVE: spanBuilder = startSpanWithExplicitParent(spanName, context); span = spanBuilder.startSpan(); // Add diagnostic Id to Context context = setContextData(span); - return context.addData(OPENTELEMETRY_SPAN_KEY, span); + return context.addData(OPENCENSUS_SPAN_KEY, span); case PROCESS: return startScopedSpan(spanName, context); default: @@ -106,7 +105,7 @@ public void setAttribute(String key, String value, Context context) { @Override public Context setSpanName(String spanName, Context context) { - return context.addData(OPENTELEMETRY_SPAN_NAME_KEY, spanName); + return context.addData(OPENCENSUS_SPAN_NAME_KEY, spanName); } @Override @@ -163,22 +162,29 @@ private Context startScopedSpan(String spanName, Context context) { SpanBuilder spanBuilder = startSpanWithExplicitParent(spanName, context); span = spanBuilder.setSpanKind(Span.Kind.SERVER).startSpan(); } - return context.addData(OPENTELEMETRY_SPAN_KEY, span).addData("scope", TRACER.withSpan(span)); + return context.addData(OPENCENSUS_SPAN_KEY, span).addData("scope", TRACER.withSpan(span)); } private SpanBuilder startSpanWithExplicitParent(String spanName, Context context) { - Optional optionalSpanKey = context.getData(OPENTELEMETRY_SPAN_KEY); - Optional optionalSpanNameKey = context.getData(OPENTELEMETRY_SPAN_NAME_KEY); + Optional optionalSpanKey = context.getData(OPENCENSUS_SPAN_KEY); + Optional optionalSpanNameKey = context.getData(OPENCENSUS_SPAN_NAME_KEY); Span parentSpan = null; String spanNameKey = null; - if (optionalSpanKey.get() instanceof Span && optionalSpanNameKey.get() instanceof String) { - parentSpan = (Span) context.getData(OPENTELEMETRY_SPAN_KEY).orElse(TRACER.getCurrentSpan()); - spanNameKey = (String) context.getData(OPENTELEMETRY_SPAN_NAME_KEY).orElse(spanName); + if (!optionalSpanNameKey.isPresent()) { + spanNameKey = spanName; + } else if (optionalSpanKey.isPresent() && optionalSpanNameKey.get() instanceof String) { + spanNameKey = (String) optionalSpanNameKey.get(); } else { - logger.warning(String.format(Locale.US, - "Parent span type is not of type Span, but type: %s. Failed to add span links.", - optionalSpanKey.get() != null ? optionalSpanKey.get().getClass() : "null")); + logger.warning("Span name type is not of type String, but type: {}. Failed to add span links.", + optionalSpanNameKey.get() != null ? optionalSpanNameKey.get().getClass() : "null"); + } + + if (optionalSpanKey.get() instanceof Span) { + parentSpan = (Span) context.getData(OPENCENSUS_SPAN_KEY).orElse(TRACER.getCurrentSpan()); + } else { + logger.warning("Parent span type is not of type Span, but type: {}. Failed to add span links.", + optionalSpanKey.get() != null ? optionalSpanKey.get().getClass() : "null"); } SpanBuilder spanBuilder = TRACER.spanBuilderWithExplicitParent(spanNameKey, parentSpan); @@ -221,7 +227,7 @@ private static String parseComponentValue(String spanName) { * @return The {@link Span} contained in the context, and {@code null} if it does not. */ private Span getSpan(Context context) { - final Optional spanOptional = context.getData(OPENTELEMETRY_SPAN_KEY); + final Optional spanOptional = context.getData(OPENCENSUS_SPAN_KEY); if (!spanOptional.isPresent()) { logger.warning("Failed to find span in the context."); return null; @@ -230,7 +236,7 @@ private Span getSpan(Context context) { final Object value = spanOptional.get(); if (!(value instanceof Span)) { logger.warning("Could not extract span. Data in {} is not of type Span. Actual class: {}", - OPENTELEMETRY_SPAN_KEY, + OPENCENSUS_SPAN_KEY, value.getClass()); return null; } diff --git a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/implementation/AmqpPropagationFormatUtil.java b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/implementation/AmqpPropagationFormatUtil.java similarity index 98% rename from sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/implementation/AmqpPropagationFormatUtil.java rename to sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/implementation/AmqpPropagationFormatUtil.java index 14589b23ecff..7f8e99c77524 100644 --- a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/implementation/AmqpPropagationFormatUtil.java +++ b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/implementation/AmqpPropagationFormatUtil.java @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.tracing.opentelemetry.implementation; +package com.azure.core.tracing.opencensus.implementation; import static com.azure.core.util.tracing.Tracer.SPAN_CONTEXT; diff --git a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/implementation/AmqpTraceUtil.java b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/implementation/AmqpTraceUtil.java similarity index 95% rename from sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/implementation/AmqpTraceUtil.java rename to sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/implementation/AmqpTraceUtil.java index 48cc2c2810d1..25c330c0d002 100644 --- a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/implementation/AmqpTraceUtil.java +++ b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/implementation/AmqpTraceUtil.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.tracing.opentelemetry.implementation; +package com.azure.core.tracing.opencensus.implementation; import io.opencensus.trace.Status; diff --git a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/implementation/HttpTraceUtil.java b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/implementation/HttpTraceUtil.java similarity index 95% rename from sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/implementation/HttpTraceUtil.java rename to sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/implementation/HttpTraceUtil.java index 6f9bd5049c66..68be48a05f3c 100644 --- a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/implementation/HttpTraceUtil.java +++ b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/implementation/HttpTraceUtil.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.tracing.opentelemetry.implementation; +package com.azure.core.tracing.opencensus.implementation; import io.opencensus.trace.Status; @@ -28,18 +28,18 @@ public final class HttpTraceUtil { private HttpTraceUtil() { } /** - * Parse OpenTelemetry Status from HTTP response status code. + * Parse OpenCensus Status from HTTP response status code. * *

This method serves a default routine to map HTTP status code to Open Census Status. The * mapping is defined in Google API * canonical error code, and the behavior is defined in OpenTelemetry + * href="https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/HTTP.md">OpenCensus * Specs. * * @param statusCode the HTTP response status code. {@code 0} means invalid response. * @param error the error occurred during response transmission (optional). - * @return the corresponding OpenTelemetry {@code Status}. + * @return the corresponding OpenCensus {@code Status}. */ public static Status parseResponseStatus(int statusCode, Throwable error) { String message = null; diff --git a/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/package-info.java b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/package-info.java new file mode 100644 index 000000000000..7103e663493f --- /dev/null +++ b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/com/azure/core/tracing/opencensus/package-info.java @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +/** + * An OpenCensus implementation of the tracing APIs required by azure-core to enable users to effectively trace their + * calls and have this information submitted to an OpenCensus backend. + */ +package com.azure.core.tracing.opencensus; diff --git a/sdk/tracing/azure-core-tracing-opencensus/src/main/java/module-info.java b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/module-info.java new file mode 100644 index 000000000000..fd8201ad2b0e --- /dev/null +++ b/sdk/tracing/azure-core-tracing-opencensus/src/main/java/module-info.java @@ -0,0 +1,11 @@ +module com.azure.core.tracing.opencensus { + requires com.azure.core; + requires opencensus.api; + + exports com.azure.core.tracing.opencensus; + + provides com.azure.core.util.tracing.Tracer + with com.azure.core.tracing.opencensus.OpenCensusTracer; + provides com.azure.core.http.policy.AfterRetryPolicyProvider + with com.azure.core.tracing.opencensus.OpenCensusHttpPolicy; +} diff --git a/sdk/tracing/azure-core-tracing-opencensus/src/main/resources/META-INF/services/com.azure.core.implementation.http.policy.spi.AfterRetryPolicyProvider b/sdk/tracing/azure-core-tracing-opencensus/src/main/resources/META-INF/services/com.azure.core.implementation.http.policy.spi.AfterRetryPolicyProvider new file mode 100644 index 000000000000..ce924dfff53b --- /dev/null +++ b/sdk/tracing/azure-core-tracing-opencensus/src/main/resources/META-INF/services/com.azure.core.implementation.http.policy.spi.AfterRetryPolicyProvider @@ -0,0 +1 @@ +com.azure.core.tracing.opencensus.OpenCensusHttpPolicy diff --git a/sdk/tracing/azure-core-tracing-opencensus/src/main/resources/META-INF/services/com.azure.core.util.tracing.Tracer b/sdk/tracing/azure-core-tracing-opencensus/src/main/resources/META-INF/services/com.azure.core.util.tracing.Tracer new file mode 100644 index 000000000000..46d0f4640c99 --- /dev/null +++ b/sdk/tracing/azure-core-tracing-opencensus/src/main/resources/META-INF/services/com.azure.core.util.tracing.Tracer @@ -0,0 +1 @@ +com.azure.core.tracing.opencensus.OpenCensusTracer diff --git a/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/HelloWorld.java b/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/HelloWorld.java new file mode 100644 index 000000000000..0fde58e61558 --- /dev/null +++ b/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/HelloWorld.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.tracing.opencensus; + +import com.azure.core.util.Context; +import com.azure.storage.queue.QueueClient; +import com.azure.storage.queue.QueueClientBuilder; +import io.opencensus.common.Scope; +import io.opencensus.exporter.trace.zipkin.ZipkinTraceExporter; +import io.opencensus.trace.Tracer; +import io.opencensus.trace.Tracing; +import io.opencensus.trace.config.TraceConfig; +import io.opencensus.trace.config.TraceParams; +import io.opencensus.trace.samplers.Samplers; + +import static com.azure.core.util.tracing.Tracer.OPENCENSUS_SPAN_KEY; + +/* + * This example shows tracing support in azure-storage-queue SDK using azure-core-tracing plugin package. + */ +public class HelloWorld { + private static final String ACCOUNT_NAME = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); + private static final String QUEUE_NAME = "queue_name"; + + /** + * The main method shows how we do the basic operations of enqueueing and dequeueing messages on async queue client + * with tracing enabled support. This example relies on user the having started a Zipkin exporter localhost on port + * 9411. + * + * Please refer to the Quickstart Zipkin for more documentation on + * using a Zipkin exporter. + * + * @param args No args needed for main method. + */ + public static void main(String[] args) { + ZipkinTraceExporter.createAndRegister("http://localhost:9411/api/v2/spans", "tracing-to-zipkin-service"); + + TraceConfig traceConfig = Tracing.getTraceConfig(); + TraceParams activeTraceParams = traceConfig.getActiveTraceParams(); + traceConfig.updateActiveTraceParams(activeTraceParams.toBuilder().setSampler(Samplers.alwaysSample()).build()); + + Tracer tracer = Tracing.getTracer(); + + Scope scope = tracer.spanBuilder("user-parent-span").startScopedSpan(); + try { + QueueClient queueClient = new QueueClientBuilder() + .endpoint(String.format("https://%s.queue.core.windows.net/%s%s", ACCOUNT_NAME, QUEUE_NAME, "")) + .buildClient(); + + // Create a queue, enqueue two messages. + Context tracingContext = new Context(OPENCENSUS_SPAN_KEY, tracer.getCurrentSpan()); + queueClient.createWithResponse(null, null, tracingContext); + queueClient.enqueueMessageWithResponse("This is message 1", null, null, null, tracingContext); + queueClient.enqueueMessageWithResponse("This is message 2", null, null, null, tracingContext); + System.out.println("Enqueuing of messages has completed!"); + + } finally { + scope.close(); + Tracing.getExportComponent().shutdown(); + } + } +} diff --git a/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/HelloWorldAsync.java b/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/HelloWorldAsync.java new file mode 100644 index 000000000000..7ff5d44ea55e --- /dev/null +++ b/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/HelloWorldAsync.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.tracing.opencensus; + +import com.azure.storage.queue.QueueAsyncClient; +import com.azure.storage.queue.QueueClientBuilder; +import io.opencensus.common.Scope; +import io.opencensus.exporter.trace.zipkin.ZipkinTraceExporter; +import io.opencensus.trace.Tracer; +import io.opencensus.trace.Tracing; +import io.opencensus.trace.config.TraceConfig; +import io.opencensus.trace.config.TraceParams; +import io.opencensus.trace.samplers.Samplers; +import reactor.util.context.Context; + +import java.util.concurrent.Semaphore; + +import static com.azure.core.util.tracing.Tracer.OPENCENSUS_SPAN_KEY; + +/* + * This example shows tracing support in azure-storage-queue SDK using azure-core-tracing plugin package. + */ +public class HelloWorldAsync { + private static final String ACCOUNT_NAME = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); + private static final String QUEUE_NAME = "queue_name"; + + /** + * The main method shows how we do the basic operations of enqueueing and dequeueing messages on async queue client + * with tracing enabled support. This example relies on user the having started a Zipkin exporter localhost on port + * 9411. + * + * Please refer to the Quickstart Zipkin for more documentation on + * using a Zipkin exporter. + * + * @param args No args needed for main method. + * @throws InterruptedException when the thread is interrupted in sleep mode. + */ + public static void main(String[] args) throws InterruptedException { + ZipkinTraceExporter.createAndRegister("http://localhost:9411/api/v2/spans", "tracing-to-zipkin-service"); + + TraceConfig traceConfig = Tracing.getTraceConfig(); + TraceParams activeTraceParams = traceConfig.getActiveTraceParams(); + traceConfig.updateActiveTraceParams(activeTraceParams.toBuilder().setSampler(Samplers.alwaysSample()).build()); + + Tracer tracer = Tracing.getTracer(); + Semaphore semaphore = new Semaphore(1); + Scope scope = tracer.spanBuilder("user-parent-span").startScopedSpan(); + + semaphore.acquire(); + String queueURL = String.format("https://%s.queue.core.windows.net/%s%s", ACCOUNT_NAME, QUEUE_NAME, ""); + QueueAsyncClient queueAsyncClient = new QueueClientBuilder().endpoint(queueURL).buildAsyncClient(); + + // Create a queue, enqueue two messages. + queueAsyncClient.create() + .doOnSuccess(response -> queueAsyncClient.enqueueMessage("This is message 1")) + .then(queueAsyncClient.enqueueMessage("This is message 2")) + .subscriberContext(Context.of(OPENCENSUS_SPAN_KEY, tracer.getCurrentSpan())) + .subscribe( + response -> System.out.printf("Message successfully enqueued by queueAsyncClient. Message id: %s%n", + response.getMessageId()), + err -> { + System.out.printf("Error thrown when enqueue the message. Error message: %s%n", + err.getMessage()); + scope.close(); + semaphore.release(); + }, + () -> { + scope.close(); + semaphore.release(); + System.out.println("The enqueue has been completed."); + Tracing.getExportComponent().shutdown(); + }); + } +} diff --git a/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/ListOperations.java b/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/ListOperations.java new file mode 100644 index 000000000000..42474eb27b98 --- /dev/null +++ b/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/ListOperations.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.tracing.opencensus; + +import com.azure.core.util.Context; +import com.azure.identity.credential.DefaultAzureCredentialBuilder; +import com.azure.security.keyvault.secrets.SecretClient; +import com.azure.security.keyvault.secrets.SecretClientBuilder; +import com.azure.security.keyvault.secrets.models.Secret; +import com.azure.security.keyvault.secrets.models.SecretBase; +import io.opencensus.common.Scope; +import io.opencensus.exporter.trace.zipkin.ZipkinTraceExporter; +import io.opencensus.trace.Tracer; +import io.opencensus.trace.Tracing; +import io.opencensus.trace.config.TraceConfig; +import io.opencensus.trace.config.TraceParams; +import io.opencensus.trace.samplers.Samplers; + +import static com.azure.core.util.tracing.Tracer.OPENCENSUS_SPAN_KEY; + +/** + * Sample demonstrates how to list secrets and versions of a given secret in the key vault with tracing enabled. + */ +public class ListOperations { + /** + * Authenticates with the key vault and shows how to list secrets and list versions of a specific secret in the key + * vault with trace spans exported to Zipkin. + * + * Please refer to the Quickstart Zipkin for more documentation on + * using a Zipkin exporter. + * + * @param args Unused. Arguments to the program. + * @throws IllegalArgumentException when invalid key vault endpoint is passed. + */ + public static void main(String[] args) throws IllegalArgumentException { + ZipkinTraceExporter.createAndRegister("http://localhost:9411/api/v2/spans", "tracing-to-zipkin-service"); + + TraceConfig traceConfig = Tracing.getTraceConfig(); + TraceParams activeTraceParams = traceConfig.getActiveTraceParams(); + traceConfig.updateActiveTraceParams(activeTraceParams.toBuilder().setSampler(Samplers.alwaysSample()).build()); + + Tracer tracer = Tracing.getTracer(); + + // Instantiate a client that will be used to call the service. Notice that the client is using default Azure + // credentials. To make default credentials work, ensure that environment variables 'AZURE_CLIENT_ID', + // 'AZURE_CLIENT_KEY' and 'AZURE_TENANT_ID' are set with the service principal credentials. + SecretClient client = new SecretClientBuilder() + .endpoint("https://{YOUR_VAULT_NAME}.vault.azure.net") + .credential(new DefaultAzureCredentialBuilder().build()) + .buildClient(); + + Scope scope = tracer.spanBuilder("user-parent-span").startScopedSpan(); + try { + + Context traceContext = new Context(OPENCENSUS_SPAN_KEY, tracer.getCurrentSpan()); + // Let's create secrets holding storage and bank accounts credentials. if the secret + // already exists in the key vault, then a new version of the secret is created. + client.setSecretWithResponse(new Secret("StorageAccountPassword", "password"), traceContext); + + client.setSecretWithResponse(new Secret("BankAccountPassword", "password"), traceContext); + + // You need to check if any of the secrets are sharing same values. Let's list the secrets and print their values. + // List operations don't return the secrets with value information. So, for each returned secret we call getSecret to get the secret with its value information. + for (SecretBase secret : client.listSecrets(traceContext)) { + Secret secretWithValue = client.getSecretWithResponse(secret, traceContext).getValue(); + System.out.printf("Received secret with name %s and value %s%n", secretWithValue.getName(), secretWithValue.getValue()); + } + + // The bank account password got updated, so you want to update the secret in key vault to ensure it reflects the new password. + // Calling setSecret on an existing secret creates a new version of the secret in the key vault with the new value. + client.setSecret("BankAccountPassword", "newPassword"); + + // You need to check all the different values your bank account password secret had previously. Lets print all the versions of this secret. + for (SecretBase secret : client.listSecretVersions("BankAccountPassword", traceContext)) { + Secret secretWithValue = client.getSecretWithResponse(secret, traceContext).getValue(); + System.out.printf("Received secret's version with name %s and value %s%n", secretWithValue.getName(), secretWithValue.getValue()); + } + } finally { + scope.close(); + Tracing.getExportComponent().shutdown(); + } + } +} diff --git a/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/ListOperationsAsync.java b/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/ListOperationsAsync.java new file mode 100644 index 000000000000..19c679b97509 --- /dev/null +++ b/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/ListOperationsAsync.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.tracing.opencensus; + +import com.azure.identity.credential.DefaultAzureCredentialBuilder; +import com.azure.security.keyvault.secrets.SecretAsyncClient; +import com.azure.security.keyvault.secrets.SecretClientBuilder; +import com.azure.security.keyvault.secrets.models.Secret; +import io.opencensus.common.Scope; +import io.opencensus.exporter.trace.zipkin.ZipkinTraceExporter; +import io.opencensus.trace.Tracer; +import io.opencensus.trace.Tracing; +import io.opencensus.trace.config.TraceConfig; +import io.opencensus.trace.config.TraceParams; +import io.opencensus.trace.samplers.Samplers; +import reactor.util.context.Context; + +import java.util.concurrent.Semaphore; + +import static com.azure.core.util.tracing.Tracer.OPENCENSUS_SPAN_KEY; + +/** + * Sample demonstrates how to list secrets and versions of a given secret in the key vault with tracing enabled. + */ +public class ListOperationsAsync { + /** + * Authenticates with the key vault and shows how to list secrets and list versions of a specific secret in the key + * vault with trace spans exported to Zipkin. + * + * Please refer to the Quickstart Zipkin for more documentation on + * using a Zipkin exporter. + * + * @param args Unused. Arguments to the program. + * @throws IllegalArgumentException when invalid key vault endpoint is passed. + * @throws InterruptedException when the thread is interrupted in sleep mode. + */ + public static void main(String[] args) throws IllegalArgumentException, InterruptedException { + ZipkinTraceExporter.createAndRegister("http://localhost:9411/api/v2/spans", "tracing-to-zipkin-service"); + + TraceConfig traceConfig = Tracing.getTraceConfig(); + TraceParams activeTraceParams = traceConfig.getActiveTraceParams(); + traceConfig.updateActiveTraceParams(activeTraceParams.toBuilder().setSampler(Samplers.alwaysSample()).build()); + + Tracer tracer = Tracing.getTracer(); + + // Instantiate a client that will be used to call the service. Notice that the client is using default Azure + // credentials. To make default credentials work, ensure that environment variables 'AZURE_CLIENT_ID', + // 'AZURE_CLIENT_KEY' and 'AZURE_TENANT_ID' are set with the service principal credentials. + SecretAsyncClient client = new SecretClientBuilder() + .endpoint("https://{YOUR_VAULT_NAME}.vault.azure.net") + .credential(new DefaultAzureCredentialBuilder().build()) + .buildAsyncClient(); + + Semaphore semaphore = new Semaphore(1); + Scope scope = tracer.spanBuilder("user-parent-span").startScopedSpan(); + + semaphore.acquire(); + Context traceContext = Context.of(OPENCENSUS_SPAN_KEY, tracer.getCurrentSpan()); + // Let's create secrets holding storage and bank accounts credentials. if the secret + // already exists in the key vault, then a new version of the secret is created. + client.setSecret(new Secret("StorageAccountPassword", "password")) + .then(client.setSecret(new Secret("BankAccountPassword", "password"))) + .subscriberContext(traceContext) + .subscribe(secretResponse -> + System.out.printf("Secret is created with name %s and value %s %n", secretResponse.getName(), secretResponse.getValue()), + err -> { + System.out.printf("Error thrown when enqueue the message. Error message: %s%n", + err.getMessage()); + scope.close(); + semaphore.release(); + }, + () -> { + semaphore.release(); + }); + + semaphore.acquire(); + // You need to check if any of the secrets are sharing same values. Let's list the secrets and print their values. + // List operations don't return the secrets with value information. So, for each returned secret we call getSecret to get the secret with its value information. + client.listSecrets() + .subscriberContext(traceContext) + .subscribe(secretBase -> client.getSecret(secretBase) + .subscriberContext(traceContext) + .subscribe(secret -> System.out.printf("Received secret with name %s and value %s%n", + secret.getName(), secret.getValue()))); + + // The bank account password got updated, so you want to update the secret in key vault to ensure it reflects the new password. + // Calling setSecret on an existing secret creates a new version of the secret in the key vault with the new value. + client.setSecret("BankAccountPassword", "new password") + .subscriberContext(traceContext) + .subscribe(secretResponse -> + System.out.printf("Secret is created with name %s and value %s %n", secretResponse.getName(), secretResponse.getValue()), + err -> { + System.out.printf("Error thrown when enqueue the message. Error message: %s%n", + err.getMessage()); + scope.close(); + semaphore.release(); + }, + () -> { + semaphore.release(); + }); + + semaphore.acquire(); + + // You need to check all the different values your bank account password secret had previously. Lets print all the versions of this secret. + client.listSecretVersions("BankAccountPassword") + .subscriberContext(traceContext) + .subscribe(secretBase -> System.out.printf("Received secret's version with name %s%n", + secretBase.getName())); + + scope.close(); + Tracing.getExportComponent().shutdown(); + } +} diff --git a/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/PublishEvents.java b/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/PublishEvents.java new file mode 100644 index 000000000000..9dad2840cad9 --- /dev/null +++ b/sdk/tracing/azure-core-tracing-opencensus/src/samples/java/com/azure/core/tracing/opencensus/PublishEvents.java @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.tracing.opencensus; + +import com.azure.core.util.Context; +import com.azure.messaging.eventhubs.EventData; +import com.azure.messaging.eventhubs.EventHubAsyncClient; +import com.azure.messaging.eventhubs.EventHubAsyncProducer; +import com.azure.messaging.eventhubs.EventHubClientBuilder; +import io.opencensus.common.Scope; +import io.opencensus.exporter.trace.zipkin.ZipkinTraceExporter; +import io.opencensus.trace.Tracer; +import io.opencensus.trace.Tracing; +import io.opencensus.trace.config.TraceConfig; +import io.opencensus.trace.config.TraceParams; +import io.opencensus.trace.samplers.Samplers; +import reactor.core.publisher.Flux; + +import java.io.IOException; +import java.util.concurrent.Semaphore; + +import static com.azure.core.util.tracing.Tracer.OPENCENSUS_SPAN_KEY; +import static java.nio.charset.StandardCharsets.UTF_8; + +/** + * Sample demonstrates how to send a message to an Azure Event Hub with tracing support. + */ +public class PublishEvents { + private static final String CONNECTION_STRING = System.getenv("AZURE_EVENTHUBS_CONNECTION_STRING"); + + /** + * Main method to invoke this demo on how to send a message to an Azure Event Hub with trace spans exported to + * Zipkin. + * + * Please refer to the Quickstart Zipkin for more documentation on + * using a Zipkin exporter. + * + * @param args Unused arguments to the program. + * @throws InterruptedException when the thread is interrupted in sleep mode. + */ + public static void main(String[] args) throws InterruptedException { + ZipkinTraceExporter.createAndRegister("http://localhost:9411/api/v2/spans", "tracing-to-zipkin-service"); + + TraceConfig traceConfig = Tracing.getTraceConfig(); + TraceParams activeTraceParams = traceConfig.getActiveTraceParams(); + traceConfig.updateActiveTraceParams(activeTraceParams.toBuilder().setSampler(Samplers.alwaysSample()).build()); + + Tracer tracer = Tracing.getTracer(); + Semaphore semaphore = new Semaphore(1); + Scope scope = tracer.spanBuilder("user-parent-span").startScopedSpan(); + + semaphore.acquire(); + // The connection string value can be obtained by: + // 1. Going to your Event Hubs namespace in Azure Portal. + // 2. Creating an Event Hub instance. + // 3. Creating a "Shared access policy" for your Event Hub instance. + // 4. Copying the connection string from the policy's properties. + + // Instantiate a client that will be used to call the service. + EventHubAsyncClient client = new EventHubClientBuilder() + .connectionString(CONNECTION_STRING) + .buildAsyncClient(); + + Context context = new Context(OPENCENSUS_SPAN_KEY, tracer.getCurrentSpan()); + final int count = 2; + final byte[] body = "Hello World!".getBytes(UTF_8); + final Flux testData = Flux.range(0, count).flatMap(number -> { + final EventData data = new EventData(body, context); + return Flux.just(data); + }); + + // Create a producer. This overload of `createProducer` does not accept any arguments. Consequently, events + // sent from this producer are load balanced between all available partitions in the Event Hub instance. + EventHubAsyncProducer producer = client.createProducer(); + + // Send those events. This call returns a Mono, which we subscribe to. It completes successfully when the + // event has been delivered to the Event Hub. It completes with an error if an exception occurred while sending + // the event. + producer.send(testData).subscribe( + response -> System.out.println("Message successfully sent"), + err -> { + System.out.printf("Error thrown when sending the message. Error message: %s%n", + err.getMessage()); + scope.close(); + semaphore.release(); + }, + () -> { + semaphore.release(); + System.out.println("The process has been completed."); + }); + semaphore.acquire(); + try { + producer.close(); + } catch (IOException e) { + System.err.println("Error encountered while closing producer: " + e.toString()); + } + + client.close(); + scope.close(); + Tracing.getExportComponent().shutdown(); + } +} diff --git a/sdk/tracing/pom.service.xml b/sdk/tracing/pom.service.xml index b5b793f3d10b..0d3a66c010ae 100644 --- a/sdk/tracing/pom.service.xml +++ b/sdk/tracing/pom.service.xml @@ -10,6 +10,14 @@ 1.0.0 ../core/azure-core - tracing-opentelemetry + ../core/azure-core-amqp + ../core/azure-core-test + ../core/azure-core-http-netty + ../identity/azure-identity + ../storage/azure-storage-queue + ../storage/azure-storage-common + ../eventhubs/azure-messaging-eventhubs + ../keyvault/azure-keyvault-secrets + azure-core-tracing-opencensus diff --git a/sdk/tracing/tracing-opentelemetry/README.md b/sdk/tracing/tracing-opentelemetry/README.md deleted file mode 100644 index 32f1ffca0789..000000000000 --- a/sdk/tracing/tracing-opentelemetry/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Azure Tracing client library for Java - -## Getting started - -## Key concepts - -## Examples - -## Troubleshooting - -## Next steps - -## Contributing - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java/sdk/tracing/tracing-opentelemetry/README.png) \ No newline at end of file diff --git a/sdk/tracing/tracing-opentelemetry/pom.xml b/sdk/tracing/tracing-opentelemetry/pom.xml deleted file mode 100644 index 410514b46c1c..000000000000 --- a/sdk/tracing/tracing-opentelemetry/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - - com.azure - azure-client-sdk-parent - 1.4.0 - ../../../pom.client.xml - - - com.azure - tracing-opentelemetry - 1.0.0-preview.3 - - Microsoft Azure OpenTelemetry tracing plugin - This package contains the OpenTelemetry tracing plugin for Azure client libraries. - https://github.com/Azure/azure-sdk-for-java - - - - azure-java-build-docs - ${site.url}/site/${project.artifactId} - - - - - scm:git:https://github.com/Azure/azure-sdk-for-java - scm:git:git@github.com:Azure/azure-sdk-for-java.git - HEAD - - - - - com.azure - azure-core - 1.0.0-preview.5 - - - io.opencensus - opencensus-api - - - com.azure - azure-core - 1.0.0-preview.5 - compile - - - diff --git a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/package-info.java b/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/package-info.java deleted file mode 100644 index 0632e1f800fe..000000000000 --- a/sdk/tracing/tracing-opentelemetry/src/main/java/com/azure/tracing/opentelemetry/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -/** - * An OpenTelemetry implementation of the tracing APIs required by azure-core to enable users to effectively trace their - * calls and have this information submitted to an OpenTelemetry backend. - */ -package com.azure.tracing.opentelemetry; diff --git a/sdk/tracing/tracing-opentelemetry/src/main/java/module-info.java b/sdk/tracing/tracing-opentelemetry/src/main/java/module-info.java deleted file mode 100644 index e33f19b2ec23..000000000000 --- a/sdk/tracing/tracing-opentelemetry/src/main/java/module-info.java +++ /dev/null @@ -1,12 +0,0 @@ -module com.azure.tracing.opentelemetry { - requires com.azure.core; - - requires opencensus.api; - - exports com.azure.tracing.opentelemetry; - - provides com.azure.core.util.tracing.Tracer - with com.azure.tracing.opentelemetry.OpenTelemetryTracer; - provides com.azure.core.http.policy.AfterRetryPolicyProvider - with com.azure.tracing.opentelemetry.OpenTelemetryHttpPolicy; -} diff --git a/sdk/tracing/tracing-opentelemetry/src/main/resources/META-INF/services/com.azure.core.http.policy.AfterRetryPolicyProvider b/sdk/tracing/tracing-opentelemetry/src/main/resources/META-INF/services/com.azure.core.http.policy.AfterRetryPolicyProvider deleted file mode 100644 index c2342fa80322..000000000000 --- a/sdk/tracing/tracing-opentelemetry/src/main/resources/META-INF/services/com.azure.core.http.policy.AfterRetryPolicyProvider +++ /dev/null @@ -1 +0,0 @@ -com.azure.tracing.opentelemetry.OpenTelemetryHttpPolicy diff --git a/sdk/tracing/tracing-opentelemetry/src/main/resources/META-INF/services/com.azure.core.util.tracing.Tracer b/sdk/tracing/tracing-opentelemetry/src/main/resources/META-INF/services/com.azure.core.util.tracing.Tracer deleted file mode 100644 index 0138e5f35f9b..000000000000 --- a/sdk/tracing/tracing-opentelemetry/src/main/resources/META-INF/services/com.azure.core.util.tracing.Tracer +++ /dev/null @@ -1 +0,0 @@ -com.azure.tracing.opentelemetry.OpenTelemetryTracer