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 5094af9ca2790..c4ed0ce6c72ba 100644
--- a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml
+++ b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml
@@ -125,10 +125,10 @@
files="com.azure.containers.containerregistry.ContainerRegistryContentClient.java"/>
+ files="com.azure.monitor.opentelemetry.exporter.AzureMonitorExporter.java"/>
+ files="com.azure.monitor.opentelemetry.exporter.AzureMonitorExporterOptions"/>
ATTRIBUTE_KEY = AttributeKey.stringKey
public void spanProcessor() {
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(sdkBuilder);
+ AzureMonitorExporter.customize(sdkBuilder);
SpanProcessor spanProcessor = new SpanProcessor() {
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/AzureMonitor.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporter.java
similarity index 80%
rename from sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/AzureMonitor.java
rename to sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporter.java
index 5baf17c068c50..3c7418943a9e5 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/AzureMonitor.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporter.java
@@ -1,9 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
-package com.azure.monitor.opentelemetry;
+package com.azure.monitor.opentelemetry.exporter;
-import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporterBuilder;
import com.azure.monitor.opentelemetry.exporter.implementation.AzureMonitorExporterProviderKeys;
import com.azure.monitor.opentelemetry.exporter.implementation.AzureMonitorLogRecordExporterProvider;
import com.azure.monitor.opentelemetry.exporter.implementation.AzureMonitorMetricExporterProvider;
@@ -19,9 +18,9 @@
/**
* Class to enable Azure Monitor for OpenTelemetry autoconfiguration.
*/
-public final class AzureMonitor {
+public final class AzureMonitorExporter {
- private AzureMonitor() {
+ private AzureMonitorExporter() {
}
/**
@@ -30,8 +29,8 @@ private AzureMonitor() {
* @param autoConfigurationCustomizer The OpenTelemetry autoconfiguration to set up.
*/
public static void customize(AutoConfigurationCustomizer autoConfigurationCustomizer) {
- AzureMonitorExporterBuilder azureMonitorExporterBuilder = new AzureMonitorExporterBuilder();
- customize(autoConfigurationCustomizer, azureMonitorExporterBuilder);
+ AzureMonitorExporterOptions exporterOptions = new AzureMonitorExporterOptions();
+ customize(autoConfigurationCustomizer, exporterOptions);
}
/**
@@ -40,18 +39,18 @@ public static void customize(AutoConfigurationCustomizer autoConfigurationCustom
* @param connectionString The connection string to connect to an Application Insights resource.
*/
public static void customize(AutoConfigurationCustomizer autoConfigurationCustomizer, String connectionString) {
- AzureMonitorExporterBuilder azureMonitorExporterBuilder
- = new AzureMonitorExporterBuilder().connectionString(connectionString);
- customize(autoConfigurationCustomizer, azureMonitorExporterBuilder);
+ AzureMonitorExporterOptions exporterOptions
+ = new AzureMonitorExporterOptions().connectionString(connectionString);
+ customize(autoConfigurationCustomizer, exporterOptions);
}
/**
* Customizes an {@link AutoConfigurationCustomizer} for Azure Monitor.
* @param autoConfigurationCustomizer the {@link AutoConfigurationCustomizer} object.
- * @param azureMonitorExporterBuilder Advanced configuration to send the data to Azure Monitor.
+ * @param exporterOptions Advanced configuration to send the data to Azure Monitor.
*/
public static void customize(AutoConfigurationCustomizer autoConfigurationCustomizer,
- AzureMonitorExporterBuilder azureMonitorExporterBuilder) {
+ AzureMonitorExporterOptions exporterOptions) {
autoConfigurationCustomizer.addPropertiesSupplier(() -> {
Map props = new HashMap<>();
props.put("otel.traces.exporter", AzureMonitorExporterProviderKeys.EXPORTER_NAME);
@@ -62,19 +61,19 @@ public static void customize(AutoConfigurationCustomizer autoConfigurationCustom
});
autoConfigurationCustomizer.addSpanExporterCustomizer((spanExporter, configProperties) -> {
if (spanExporter instanceof AzureMonitorSpanExporterProvider.MarkerSpanExporter) {
- spanExporter = azureMonitorExporterBuilder.buildSpanExporter(configProperties);
+ spanExporter = exporterOptions.buildSpanExporter(configProperties);
}
return spanExporter;
});
autoConfigurationCustomizer.addMetricExporterCustomizer((metricExporter, configProperties) -> {
if (metricExporter instanceof AzureMonitorMetricExporterProvider.MarkerMetricExporter) {
- metricExporter = azureMonitorExporterBuilder.buildMetricExporter(configProperties);
+ metricExporter = exporterOptions.buildMetricExporter(configProperties);
}
return metricExporter;
});
autoConfigurationCustomizer.addLogRecordExporterCustomizer((logRecordExporter, configProperties) -> {
if (logRecordExporter instanceof AzureMonitorLogRecordExporterProvider.MarkerLogRecordExporter) {
- logRecordExporter = azureMonitorExporterBuilder.buildLogRecordExporter(configProperties);
+ logRecordExporter = exporterOptions.buildLogRecordExporter(configProperties);
}
return logRecordExporter;
});
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterBuilder.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterOptions.java
similarity index 85%
rename from sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterBuilder.java
rename to sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterOptions.java
index ce2aaab616fcf..0d952e4a09180 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterBuilder.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterOptions.java
@@ -4,9 +4,6 @@
package com.azure.monitor.opentelemetry.exporter;
import com.azure.core.annotation.Fluent;
-import com.azure.core.client.traits.ConnectionStringTrait;
-import com.azure.core.client.traits.HttpTrait;
-import com.azure.core.client.traits.TokenCredentialTrait;
import com.azure.core.credential.TokenCredential;
import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpPipeline;
@@ -42,7 +39,6 @@
import com.azure.monitor.opentelemetry.exporter.implementation.utils.TempDirs;
import com.azure.monitor.opentelemetry.exporter.implementation.utils.VersionGenerator;
import com.azure.monitor.opentelemetry.exporter.implementation.utils.ResourceParser;
-import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
@@ -62,13 +58,12 @@
import static java.util.concurrent.TimeUnit.MINUTES;
/**
- * Low level API to create OpenTelemetry span, log record and metric exporters for Azure. With OpenTelemetry autoconfiguration ({@link AutoConfiguredOpenTelemetrySdkBuilder}), we recommend using {@link com.azure.monitor.opentelemetry.AzureMonitor}.
+ * Providers configuration options for Azure Monitor exporter..
*/
@Fluent
-public final class AzureMonitorExporterBuilder implements ConnectionStringTrait,
- TokenCredentialTrait, HttpTrait {
+public final class AzureMonitorExporterOptions {
- private static final ClientLogger LOGGER = new ClientLogger(AzureMonitorExporterBuilder.class);
+ private static final ClientLogger LOGGER = new ClientLogger(AzureMonitorExporterOptions.class);
private static final String APPLICATIONINSIGHTS_CONNECTION_STRING = "APPLICATIONINSIGHTS_CONNECTION_STRING";
private static final String APPLICATIONINSIGHTS_AUTHENTICATION_SCOPE = "https://monitor.azure.com//.default";
@@ -100,9 +95,9 @@ public final class AzureMonitorExporterBuilder implements ConnectionStringTrait<
private StatsbeatModule statsbeatModule;
/**
- * Creates an instance of {@link AzureMonitorExporterBuilder}.
+ * Creates an instance of {@link AzureMonitorExporterOptions}.
*/
- public AzureMonitorExporterBuilder() {
+ public AzureMonitorExporterOptions() {
}
/**
@@ -116,10 +111,9 @@ public AzureMonitorExporterBuilder() {
* documentation of types that implement this trait to understand the full set of implications.
*
* @param pipeline {@link HttpPipeline} to use for sending service requests and receiving responses.
- * @return The updated {@link AzureMonitorExporterBuilder} object.
+ * @return The updated {@link AzureMonitorExporterOptions} object.
*/
- @Override
- public AzureMonitorExporterBuilder pipeline(HttpPipeline pipeline) {
+ public AzureMonitorExporterOptions pipeline(HttpPipeline pipeline) {
if (frozen) {
throw LOGGER.logExceptionAsError(new IllegalStateException(
"httpPipeline cannot be changed after any of the build methods have been called"));
@@ -139,10 +133,9 @@ public AzureMonitorExporterBuilder pipeline(HttpPipeline pipeline) {
* documentation of types that implement this trait to understand the full set of implications.
*
* @param httpClient The {@link HttpClient} to use for requests.
- * @return The updated {@link AzureMonitorExporterBuilder} object.
+ * @return The updated {@link AzureMonitorExporterOptions} object.
*/
- @Override
- public AzureMonitorExporterBuilder httpClient(HttpClient httpClient) {
+ public AzureMonitorExporterOptions httpClient(HttpClient httpClient) {
if (frozen) {
throw LOGGER.logExceptionAsError(new IllegalStateException(
"httpClient cannot be changed after any of the build methods have been called"));
@@ -164,10 +157,9 @@ public AzureMonitorExporterBuilder httpClient(HttpClient httpClient) {
*
* @param logOptions The {@link HttpLogOptions logging configuration} to use when sending and receiving requests to
* and from the service.
- * @return The updated {@link AzureMonitorExporterBuilder} object.
+ * @return The updated {@link AzureMonitorExporterOptions} object.
*/
- @Override
- public AzureMonitorExporterBuilder httpLogOptions(HttpLogOptions logOptions) {
+ public AzureMonitorExporterOptions httpLogOptions(HttpLogOptions logOptions) {
if (frozen) {
throw LOGGER.logExceptionAsError(new IllegalStateException(
"httpLogOptions cannot be changed after any of the build methods have been called"));
@@ -188,10 +180,9 @@ public AzureMonitorExporterBuilder httpLogOptions(HttpLogOptions logOptions) {
*
* @param pipelinePolicy A {@link HttpPipelinePolicy pipeline policy}.
* @throws NullPointerException If {@code pipelinePolicy} is {@code null}.
- * @return The updated {@link AzureMonitorExporterBuilder} object.
+ * @return The updated {@link AzureMonitorExporterOptions} object.
*/
- @Override
- public AzureMonitorExporterBuilder addPolicy(HttpPipelinePolicy pipelinePolicy) {
+ public AzureMonitorExporterOptions addPolicy(HttpPipelinePolicy pipelinePolicy) {
if (frozen) {
throw LOGGER.logExceptionAsError(new IllegalStateException(
"httpPipelinePolicy cannot be added after any of the build methods have been called"));
@@ -211,10 +202,9 @@ public AzureMonitorExporterBuilder addPolicy(HttpPipelinePolicy pipelinePolicy)
* documentation of types that implement this trait to understand the full set of implications.
*
* @param retryOptions The {@link RetryOptions} to use for all the requests made through the client.
- * @return The updated {@link AzureMonitorExporterBuilder} object.
+ * @return The updated {@link AzureMonitorExporterOptions} object.
*/
- @Override
- public AzureMonitorExporterBuilder retryOptions(RetryOptions retryOptions) {
+ public AzureMonitorExporterOptions retryOptions(RetryOptions retryOptions) {
if (frozen) {
throw LOGGER.logExceptionAsError(new IllegalStateException(
"retryOptions cannot be changed after any of the build methods have been called"));
@@ -238,11 +228,10 @@ public AzureMonitorExporterBuilder retryOptions(RetryOptions retryOptions) {
* documentation of types that implement this trait to understand the full set of implications.
*
* @param clientOptions A configured instance of {@link HttpClientOptions}.
- * @return The updated {@link AzureMonitorExporterBuilder} object.
+ * @return The updated {@link AzureMonitorExporterOptions} object.
* @see HttpClientOptions
*/
- @Override
- public AzureMonitorExporterBuilder clientOptions(ClientOptions clientOptions) {
+ public AzureMonitorExporterOptions clientOptions(ClientOptions clientOptions) {
if (frozen) {
throw LOGGER.logExceptionAsError(new IllegalStateException(
"clientOptions cannot be changed after any of the build methods have been called"));
@@ -255,12 +244,11 @@ public AzureMonitorExporterBuilder clientOptions(ClientOptions clientOptions) {
* Sets the connection string to use for exporting telemetry events to Azure Monitor.
*
* @param connectionString The connection string for the Azure Monitor resource.
- * @return The updated {@link AzureMonitorExporterBuilder} object.
+ * @return The updated {@link AzureMonitorExporterOptions} object.
* @throws NullPointerException If the connection string is {@code null}.
* @throws IllegalArgumentException If the connection string is invalid.
*/
- @Override
- public AzureMonitorExporterBuilder connectionString(String connectionString) {
+ public AzureMonitorExporterOptions connectionString(String connectionString) {
if (frozen) {
throw LOGGER.logExceptionAsError(new IllegalStateException(
"connectionString cannot be changed after any of the build methods have been called"));
@@ -273,10 +261,9 @@ public AzureMonitorExporterBuilder connectionString(String connectionString) {
* Sets the token credential required for authentication with the ingestion endpoint service.
*
* @param credential The Azure Identity TokenCredential.
- * @return The updated {@link AzureMonitorExporterBuilder} object.
+ * @return The updated {@link AzureMonitorExporterOptions} object.
*/
- @Override
- public AzureMonitorExporterBuilder credential(TokenCredential credential) {
+ public AzureMonitorExporterOptions credential(TokenCredential credential) {
if (frozen) {
throw LOGGER.logExceptionAsError(new IllegalStateException(
"credential cannot be changed after any of the build methods have been called"));
@@ -285,31 +272,13 @@ public AzureMonitorExporterBuilder credential(TokenCredential credential) {
return this;
}
- /**
- * Creates an Azure Monitor span exporter based on the options set in the builder. This
- * exporter is an implementation of OpenTelemetry {@link SpanExporter}.
- *
- * @param configProperties The OpenTelemetry configuration properties.
- * @return An instance of {@link SpanExporter}.
- * @throws NullPointerException if the connection string is not set on this builder or if the
- * environment variable "APPLICATIONINSIGHTS_CONNECTION_STRING" is not set.
- */
- public SpanExporter buildSpanExporter(ConfigProperties configProperties) {
+ SpanExporter buildSpanExporter(ConfigProperties configProperties) {
internalBuildAndFreeze(configProperties);
return new AzureMonitorTraceExporter(createSpanDataMapper(configProperties), builtTelemetryItemExporter,
statsbeatModule);
}
- /**
- * Creates an Azure Monitor log record exporter based on the options set in the builder. This
- * exporter is an implementation of OpenTelemetry {@link LogRecordExporter}.
- *
- * @param configProperties The OpenTelemetry configuration properties.
- * @return An instance of {@link LogRecordExporter}.
- * @throws NullPointerException if the connection string is not set on this builder or if the
- * environment variable "APPLICATIONINSIGHTS_CONNECTION_STRING" is not set.
- */
- public LogRecordExporter buildLogRecordExporter(ConfigProperties configProperties) {
+ LogRecordExporter buildLogRecordExporter(ConfigProperties configProperties) {
internalBuildAndFreeze(configProperties);
return new AzureMonitorLogRecordExporter(
new LogDataMapper(true, false, createDefaultsPopulator(configProperties)), builtTelemetryItemExporter);
@@ -333,19 +302,7 @@ void internalBuildAndFreeze(ConfigProperties configProperties) {
}
}
- /**
- * Creates an Azure monitor metric exporter based on the options set in the builder. This
- * exporter is an implementation of OpenTelemetry {@link MetricExporter}.
- *
- * When a new {@link MetricExporter} is created, it will automatically start {@link
- * HeartbeatExporter}.
- *
- * @param configProperties The OpenTelemetry configuration properties.
- * @return An instance of {@link MetricExporter}.
- * @throws NullPointerException if the connection string is not set on this builder or if the
- * environment variable "APPLICATIONINSIGHTS_CONNECTION_STRING" is not set.
- */
- public MetricExporter buildMetricExporter(ConfigProperties configProperties) {
+ MetricExporter buildMetricExporter(ConfigProperties configProperties) {
internalBuildAndFreeze(configProperties);
HeartbeatExporter.start(MINUTES.toSeconds(15), createDefaultsPopulator(configProperties),
builtTelemetryItemExporter::send);
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorLogRecordExporterProvider.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorLogRecordExporterProvider.java
index 4b339cf18f647..46a61ad59ffaa 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorLogRecordExporterProvider.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorLogRecordExporterProvider.java
@@ -3,7 +3,7 @@
package com.azure.monitor.opentelemetry.exporter.implementation;
-import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporterBuilder;
+import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporter;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider;
import io.opentelemetry.sdk.common.CompletableResultCode;
@@ -20,7 +20,7 @@ public LogRecordExporter createExporter(ConfigProperties configProperties) {
return AzureMonitorLogRecordExporterProvider.MarkerLogRecordExporter.INSTANCE;
}
throw new IllegalStateException(
- getName() + " currently only supports usage via " + AzureMonitorExporterBuilder.class.getName());
+ getName() + " currently only supports usage via " + AzureMonitorExporter.class.getName());
}
@Override
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorMetricExporterProvider.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorMetricExporterProvider.java
index 72718b459dea3..f9521b287ba95 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorMetricExporterProvider.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorMetricExporterProvider.java
@@ -3,7 +3,7 @@
package com.azure.monitor.opentelemetry.exporter.implementation;
-import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporterBuilder;
+import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporter;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.common.CompletableResultCode;
@@ -22,7 +22,7 @@ public MetricExporter createExporter(ConfigProperties configProperties) {
return AzureMonitorMetricExporterProvider.MarkerMetricExporter.INSTANCE;
}
throw new IllegalStateException(
- getName() + " currently only supports usage via " + AzureMonitorExporterBuilder.class.getName());
+ getName() + " currently only supports usage via " + AzureMonitorExporter.class.getName());
}
@Override
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorSpanExporterProvider.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorSpanExporterProvider.java
index 35cfe9476e3de..406a3411f6757 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorSpanExporterProvider.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/AzureMonitorSpanExporterProvider.java
@@ -3,7 +3,7 @@
package com.azure.monitor.opentelemetry.exporter.implementation;
-import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporterBuilder;
+import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporter;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider;
import io.opentelemetry.sdk.common.CompletableResultCode;
@@ -20,7 +20,7 @@ public SpanExporter createExporter(ConfigProperties configProperties) {
return MarkerSpanExporter.INSTANCE;
}
throw new IllegalStateException(
- getName() + " currently only supports usage via " + AzureMonitorExporterBuilder.class.getName());
+ getName() + " currently only supports usage via " + AzureMonitorExporter.class.getName());
}
@Override
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/package-info.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/package-info.java
deleted file mode 100644
index 090354228832c..0000000000000
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/package-info.java
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-/**
- * Package containing classes for configuring the OpenTelemetry autoconfiguration with the telemetry data export to Azure Monitor.
- */
-package com.azure.monitor.opentelemetry;
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/AppConfigurationAzureMonitorExporterSample.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/AppConfigurationAzureMonitorExporterSample.java
index 0e07e883032fd..a7d84d3c586f8 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/AppConfigurationAzureMonitorExporterSample.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/AppConfigurationAzureMonitorExporterSample.java
@@ -5,7 +5,6 @@
import com.azure.data.appconfiguration.ConfigurationClient;
import com.azure.data.appconfiguration.ConfigurationClientBuilder;
-import com.azure.monitor.opentelemetry.AzureMonitor;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
@@ -40,7 +39,7 @@ public static void main(String[] args) {
private static Tracer configureAzureMonitorExporter() {
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(sdkBuilder, "{connection-string}");
+ AzureMonitorExporter.customize(sdkBuilder, "{connection-string}");
OpenTelemetry openTelemetry = sdkBuilder.build().getOpenTelemetrySdk();
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorMetricExporterSample.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorMetricExporterSample.java
index f3fdbe1d644e1..7e02bab7e70e8 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorMetricExporterSample.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorMetricExporterSample.java
@@ -3,7 +3,6 @@
package com.azure.monitor.opentelemetry.exporter;
-import com.azure.monitor.opentelemetry.AzureMonitor;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
@@ -27,7 +26,7 @@ private static void sendDoubleHistogram() {
try {
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(sdkBuilder, APPINSIGHTS_CONNECTION_STRING);
+ AzureMonitorExporter.customize(sdkBuilder, APPINSIGHTS_CONNECTION_STRING);
OpenTelemetry openTelemetry = sdkBuilder.build().getOpenTelemetrySdk();
Meter meter = openTelemetry.meterBuilder("OTEL.AzureMonitor.Demo").build();
@@ -48,7 +47,7 @@ private static void sendLongCounter() {
try {
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(sdkBuilder, APPINSIGHTS_CONNECTION_STRING);
+ AzureMonitorExporter.customize(sdkBuilder, APPINSIGHTS_CONNECTION_STRING);
OpenTelemetry openTelemetry = sdkBuilder.build().getOpenTelemetrySdk();
Meter meter = openTelemetry.meterBuilder("OTEL.AzureMonitor.Demo").build();
@@ -72,7 +71,7 @@ private static void sendGaugeMetric() {
try {
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(sdkBuilder, APPINSIGHTS_CONNECTION_STRING);
+ AzureMonitorExporter.customize(sdkBuilder, APPINSIGHTS_CONNECTION_STRING);
OpenTelemetry openTelemetry = sdkBuilder.build().getOpenTelemetrySdk();
Meter meter = openTelemetry.getMeter("OTEL.AzureMonitor.Demo");
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/EventHubsAzureMonitorExporterSample.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/EventHubsAzureMonitorExporterSample.java
index b1ac4116950de..11b08c6e268d5 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/EventHubsAzureMonitorExporterSample.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/EventHubsAzureMonitorExporterSample.java
@@ -8,7 +8,6 @@
import com.azure.messaging.eventhubs.EventHubClientBuilder;
import com.azure.messaging.eventhubs.EventHubProducerAsyncClient;
import com.azure.messaging.eventhubs.models.CreateBatchOptions;
-import com.azure.monitor.opentelemetry.AzureMonitor;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
@@ -51,7 +50,7 @@ public static void main(String[] args) {
private static Tracer configureAzureMonitorExporter() {
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(sdkBuilder, "{connection-string}");
+ AzureMonitorExporter.customize(sdkBuilder, "{connection-string}");
OpenTelemetry openTelemetry = sdkBuilder.build().getOpenTelemetrySdk();
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/ReadmeSamples.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/ReadmeSamples.java
index 39edba7ed7e96..a6d84a1581653 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/ReadmeSamples.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/samples/java/com/azure/monitor/opentelemetry/exporter/ReadmeSamples.java
@@ -6,7 +6,6 @@
import com.azure.data.appconfiguration.ConfigurationClient;
import com.azure.data.appconfiguration.ConfigurationClientBuilder;
-import com.azure.monitor.opentelemetry.AzureMonitor;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.Span;
@@ -39,7 +38,7 @@ public void setupExporter() {
// This should be done just once when application starts up
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(sdkBuilder, "{connection-string}");
+ AzureMonitorExporter.customize(sdkBuilder, "{connection-string}");
OpenTelemetry openTelemetry = sdkBuilder.build().getOpenTelemetrySdk();
@@ -71,7 +70,7 @@ public void setupExporter() {
public void exporterAndOpenTelemetryAutoconfigurationEnvVariable() {
// BEGIN: readme-sample-autoconfigure-env-variable
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(sdkBuilder);
+ AzureMonitorExporter.customize(sdkBuilder);
OpenTelemetry openTelemetry = sdkBuilder.build().getOpenTelemetrySdk();
// END: readme-sample-autoconfigure-env-variable
}
@@ -82,7 +81,7 @@ public void exporterAndOpenTelemetryAutoconfigurationEnvVariable() {
public void exporterAndOpenTelemetryAutoconfiguration() {
// BEGIN: readme-sample-autoconfigure
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(sdkBuilder, "{connection-string}");
+ AzureMonitorExporter.customize(sdkBuilder, "{connection-string}");
OpenTelemetry openTelemetry = sdkBuilder.build().getOpenTelemetrySdk();
// END: readme-sample-autoconfigure
}
@@ -95,7 +94,7 @@ public void createSpan() {
// BEGIN: readme-sample-create-span
AutoConfiguredOpenTelemetrySdkBuilder otelSdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(otelSdkBuilder, "{connection-string}");
+ AzureMonitorExporter.customize(otelSdkBuilder, "{connection-string}");
OpenTelemetry openTelemetry = otelSdkBuilder.build().getOpenTelemetrySdk();
Tracer tracer = openTelemetry.getTracer("Sample");
@@ -124,7 +123,7 @@ private void applicationLogic() {
public void spanProcessor() {
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(sdkBuilder);
+ AzureMonitorExporter.customize(sdkBuilder);
SpanProcessor spanProcessor = new SpanProcessor() {
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterBuilderTest.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterTest.java
similarity index 88%
rename from sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterBuilderTest.java
rename to sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterTest.java
index cbb336856b319..2467b2965202f 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterBuilderTest.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorExporterTest.java
@@ -3,7 +3,6 @@
package com.azure.monitor.opentelemetry.exporter;
-import com.azure.monitor.opentelemetry.AzureMonitor;
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder;
import org.junit.jupiter.api.Assertions;
@@ -14,16 +13,16 @@
import java.util.stream.Stream;
/**
- * Unit tests for {@link AzureMonitorExporterBuilder}.
+ * Unit tests for {@link AzureMonitorExporterOptions}.
*/
-public class AzureMonitorExporterBuilderTest {
+public class AzureMonitorExporterTest {
@ParameterizedTest
@MethodSource("getInvalidConnectionStrings")
public void testInvalidConnectionStrings(String connectionString,
Class exceptionExpected) {
Assertions.assertThrows(exceptionExpected, () -> {
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitor.customize(sdkBuilder, connectionString);
+ AzureMonitorExporter.customize(sdkBuilder, connectionString);
sdkBuilder.build();
});
}
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/MonitorExporterClientTestBase.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/MonitorExporterClientTestBase.java
index 9c666fe655f68..b5b72e5f34b29 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/MonitorExporterClientTestBase.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/MonitorExporterClientTestBase.java
@@ -32,8 +32,8 @@
*/
public class MonitorExporterClientTestBase extends TestProxyTestBase {
- AzureMonitorExporterBuilder getClientBuilder() {
- return new AzureMonitorExporterBuilder().pipeline(getHttpPipeline(null));
+ AzureMonitorExporterOptions getClientBuilder() {
+ return new AzureMonitorExporterOptions().pipeline(getHttpPipeline(null));
}
HttpPipeline getHttpPipeline(@Nullable HttpPipelinePolicy policy, HttpClient httpClient) {
diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/implementation/utils/TestUtils.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/implementation/utils/TestUtils.java
index 5d753c63c50b1..c08edcb00ed99 100644
--- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/implementation/utils/TestUtils.java
+++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/test/java/com/azure/monitor/opentelemetry/exporter/implementation/utils/TestUtils.java
@@ -7,8 +7,8 @@
import com.azure.json.JsonProviders;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
-import com.azure.monitor.opentelemetry.AzureMonitor;
-import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporterBuilder;
+import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporter;
+import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporterOptions;
import com.azure.monitor.opentelemetry.exporter.implementation.models.MessageData;
import com.azure.monitor.opentelemetry.exporter.implementation.models.MetricDataPoint;
import com.azure.monitor.opentelemetry.exporter.implementation.models.MetricsData;
@@ -89,9 +89,9 @@ public static OpenTelemetrySdk createOpenTelemetrySdk(HttpPipeline httpPipeline,
String connectionString) {
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
- AzureMonitorExporterBuilder azureMonitorExporterBuilder
- = new AzureMonitorExporterBuilder().connectionString(connectionString).pipeline(httpPipeline);
- AzureMonitor.customize(sdkBuilder, azureMonitorExporterBuilder);
+ AzureMonitorExporterOptions exporterOptions
+ = new AzureMonitorExporterOptions().connectionString(connectionString).pipeline(httpPipeline);
+ AzureMonitorExporter.customize(sdkBuilder, exporterOptions);
return sdkBuilder.addPropertiesSupplier(() -> configuration).build().getOpenTelemetrySdk();
}
diff --git a/sdk/servicebus/azure-messaging-servicebus-stress/src/main/java/com/azure/messaging/servicebus/stress/util/TelemetryHelper.java b/sdk/servicebus/azure-messaging-servicebus-stress/src/main/java/com/azure/messaging/servicebus/stress/util/TelemetryHelper.java
index 8dcf19ffc0cfe..f008c666ce04a 100644
--- a/sdk/servicebus/azure-messaging-servicebus-stress/src/main/java/com/azure/messaging/servicebus/stress/util/TelemetryHelper.java
+++ b/sdk/servicebus/azure-messaging-servicebus-stress/src/main/java/com/azure/messaging/servicebus/stress/util/TelemetryHelper.java
@@ -7,7 +7,7 @@
import com.azure.core.util.logging.LoggingEventBuilder;
import com.azure.messaging.servicebus.ServiceBusClientBuilder;
import com.azure.messaging.servicebus.ServiceBusException;
-import com.azure.monitor.opentelemetry.AzureMonitor;
+import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporter;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
@@ -75,7 +75,7 @@ private static OpenTelemetry init() {
}
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
if (applicationInsightsConnectionString != null) {
- AzureMonitor.customize(sdkBuilder, applicationInsightsConnectionString);
+ AzureMonitorExporter.customize(sdkBuilder, applicationInsightsConnectionString);
}
String instanceId = System.getenv("CONTAINER_NAME");
diff --git a/sdk/spring/spring-cloud-azure-starter-monitor/src/main/java/com/azure/spring/cloud/autoconfigure/monitor/AzureSpringMonitorAutoConfiguration.java b/sdk/spring/spring-cloud-azure-starter-monitor/src/main/java/com/azure/spring/cloud/autoconfigure/monitor/AzureSpringMonitorAutoConfiguration.java
index 5a49e10d3dace..274a9e7400a4a 100644
--- a/sdk/spring/spring-cloud-azure-starter-monitor/src/main/java/com/azure/spring/cloud/autoconfigure/monitor/AzureSpringMonitorAutoConfiguration.java
+++ b/sdk/spring/spring-cloud-azure-starter-monitor/src/main/java/com/azure/spring/cloud/autoconfigure/monitor/AzureSpringMonitorAutoConfiguration.java
@@ -4,8 +4,8 @@
package com.azure.spring.cloud.autoconfigure.monitor;
import com.azure.core.http.HttpPipeline;
-import com.azure.monitor.opentelemetry.AzureMonitor;
-import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporterBuilder;
+import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporter;
+import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporterOptions;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
@@ -109,10 +109,10 @@ public void customize(AutoConfigurationCustomizer autoConfigurationCustomizer) {
HttpPipeline providedHttpPipeline = httpPipeline.getIfAvailable();
if (providedHttpPipeline != null) {
- AzureMonitorExporterBuilder azureMonitorExporterBuilder = new AzureMonitorExporterBuilder().connectionString(connectionString).pipeline(providedHttpPipeline);
- AzureMonitor.customize(sdkBuilder, azureMonitorExporterBuilder);
+ AzureMonitorExporterOptions exporterOptions = new AzureMonitorExporterOptions().connectionString(connectionString).pipeline(providedHttpPipeline);
+ AzureMonitorExporter.customize(sdkBuilder, exporterOptions);
} else {
- AzureMonitor.customize(sdkBuilder, connectionString);
+ AzureMonitorExporter.customize(sdkBuilder, connectionString);
}
}
diff --git a/sdk/template/azure-template-stress/src/main/java/com/azure/sdk/template/stress/util/TelemetryHelper.java b/sdk/template/azure-template-stress/src/main/java/com/azure/sdk/template/stress/util/TelemetryHelper.java
index f7d0873779aa7..02e6bf2211bc2 100644
--- a/sdk/template/azure-template-stress/src/main/java/com/azure/sdk/template/stress/util/TelemetryHelper.java
+++ b/sdk/template/azure-template-stress/src/main/java/com/azure/sdk/template/stress/util/TelemetryHelper.java
@@ -5,7 +5,7 @@
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
-import com.azure.monitor.opentelemetry.AzureMonitor;
+import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporter;
import com.azure.perf.test.core.PerfStressOptions;
import com.azure.sdk.template.stress.StressOptions;
import io.opentelemetry.api.GlobalOpenTelemetry;
@@ -87,7 +87,7 @@ public static void init() {
AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = AutoConfiguredOpenTelemetrySdk.builder();
String applicationInsightsConnectionString = System.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING");
if (applicationInsightsConnectionString != null) {
- AzureMonitor.customize(sdkBuilder, applicationInsightsConnectionString);
+ AzureMonitorExporter.customize(sdkBuilder, applicationInsightsConnectionString);
} else {
System.setProperty("otel.traces.exporter", "none");
System.setProperty("otel.logs.exporter", "none");