diff --git a/docs/modules/ROOT/pages/quarkus-opentelemetry-exporter-azure.adoc b/docs/modules/ROOT/pages/quarkus-opentelemetry-exporter-azure.adoc index c738584..f75e544 100644 --- a/docs/modules/ROOT/pages/quarkus-opentelemetry-exporter-azure.adoc +++ b/docs/modules/ROOT/pages/quarkus-opentelemetry-exporter-azure.adoc @@ -44,16 +44,6 @@ If you want to use the Azure Application Insights way of specifying the connecti applicationinsights.connection.string=your_connection_string ---- -* With the `APPLICATIONINSIGHTS_CONNECTION_STRING=your_connection_string` environment variable - - -You can disable the Azure export in this way: - -[source] ----- -quarkus.opentelemetry.tracer.exporter.azure.enabled=false ----- - Read https://quarkus.io/guides/opentelemetry#configuration-reference[this page] to learn more configuration options. == Enable more instrumentation @@ -67,4 +57,8 @@ Read https://quarkus.io/guides/opentelemetry#configuration-reference[this page] [[extension-configuration-reference]] == Extension Configuration Reference -include::includes/quarkus-opentelemetry-tracer-exporter-azure.adoc[leveloffset=+1, opts=optional] +include::includes/quarkus-opentelemetry-exporter-azure_quarkus.otel.adoc[leveloffset=+1, opts=optional] + +Configurations using the Azure semantics: + +include::includes/quarkus-opentelemetry-exporter-azure_applicationinsights.adoc[leveloffset=+1, opts=optional] diff --git a/docs/pom.xml b/docs/pom.xml index 057b600..eac3b7f 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 io.quarkiverse.opentelemetry.exporter @@ -12,11 +13,48 @@ Quarkus Opentelemetry Exporter - Documentation + + io.quarkiverse.opentelemetry.exporter + quarkus-opentelemetry-exporter-common + ${project.version} + + + io.quarkiverse.opentelemetry.exporter + quarkus-opentelemetry-exporter-gcp + ${project.version} + + + io.quarkiverse.opentelemetry.exporter + quarkus-opentelemetry-exporter-azure + ${project.version} + + + + io.quarkiverse.opentelemetry.exporter + quarkus-opentelemetry-exporter-gcp-deployment + ${project.version} + pom + test + + + * + * + + + io.quarkiverse.opentelemetry.exporter quarkus-opentelemetry-exporter-azure ${project.version} + pom + test + + + * + * + + @@ -51,6 +89,14 @@ + + io.quarkus + quarkus-config-doc-maven-plugin + true + + ${project.basedir}/modules/ROOT/pages/includes/ + + maven-resources-plugin @@ -63,11 +109,6 @@ modules/ROOT/pages/includes - - ${project.basedir}/../target/asciidoc/generated/config/ - quarkus-opentelemetry-tracer-exporter-*.adoc - false - ${project.basedir}/templates/includes attributes.adoc diff --git a/pom.xml b/pom.xml index 52e7f2b..d768fc3 100644 --- a/pom.xml +++ b/pom.xml @@ -116,6 +116,11 @@ + + io.quarkus + quarkus-config-doc-maven-plugin + ${quarkus.version} + diff --git a/quarkus-opentelemetry-exporter-azure/deployment/src/test/java/io/quarkiverse/opentelemetry/exporter/azure/deployment/AzureExporterDisabledTest.java b/quarkus-opentelemetry-exporter-azure/deployment/src/test/java/io/quarkiverse/opentelemetry/exporter/azure/deployment/AzureExporterDisabledTest.java new file mode 100644 index 0000000..2a971b3 --- /dev/null +++ b/quarkus-opentelemetry-exporter-azure/deployment/src/test/java/io/quarkiverse/opentelemetry/exporter/azure/deployment/AzureExporterDisabledTest.java @@ -0,0 +1,35 @@ +package io.quarkiverse.opentelemetry.exporter.azure.deployment; + +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.opentelemetry.api.OpenTelemetry; +import io.quarkiverse.opentelemetry.exporter.azure.runtime.AzureEndpointSampler; +import io.quarkus.test.QuarkusUnitTest; + +public class AzureExporterDisabledTest { + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest() + .withEmptyApplication() + .overrideConfigKey("quarkus.otel.azure.enabled", "false") + .overrideConfigKey("applicationinsights.connection.string", + "InstrumentationKey=bla;IngestionEndpoint=http://127.0.0.1:53602/export"); + + @Inject + OpenTelemetry openTelemetry; + + // just some class that will be available if the Azure exporter is enabled. + @Inject + Instance azureEndpointSamplers; + + @Test + void testOpenTelemetryButNoBatchSpanProcessor() { + Assertions.assertNotNull(openTelemetry); + Assertions.assertFalse(azureEndpointSamplers.isResolvable()); + } +} diff --git a/quarkus-opentelemetry-exporter-azure/deployment/src/test/java/io/quarkiverse/opentelemetry/exporter/azure/deployment/AzureExporterEnabledTest.java b/quarkus-opentelemetry-exporter-azure/deployment/src/test/java/io/quarkiverse/opentelemetry/exporter/azure/deployment/AzureExporterEnabledTest.java new file mode 100644 index 0000000..61bf20d --- /dev/null +++ b/quarkus-opentelemetry-exporter-azure/deployment/src/test/java/io/quarkiverse/opentelemetry/exporter/azure/deployment/AzureExporterEnabledTest.java @@ -0,0 +1,37 @@ +package io.quarkiverse.opentelemetry.exporter.azure.deployment; + +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.opentelemetry.api.OpenTelemetry; +import io.quarkiverse.opentelemetry.exporter.azure.runtime.AzureEndpointSampler; +import io.quarkus.test.QuarkusUnitTest; + +public class AzureExporterEnabledTest { + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest() + .withEmptyApplication() + .overrideConfigKey("quarkus.otel.azure.enabled", "true") + .overrideConfigKey("applicationinsights.connection.string", + "InstrumentationKey=bla;IngestionEndpoint=http://127.0.0.1:53602/export"); + + @Inject + OpenTelemetry openTelemetry; + + // just some class that will be available if the Azure exporter is enabled. + @Inject + Instance azureEndpointSamplers; + + @Test + void testOpenTelemetryButNoBatchSpanProcessor() { + Assertions.assertNotNull(openTelemetry); + Assertions.assertTrue(azureEndpointSamplers.isResolvable()); + Assertions.assertEquals(1, azureEndpointSamplers.stream().count()); + Assertions.assertEquals(AzureEndpointSampler.class.getName(), azureEndpointSamplers.get().getClass().getName()); + } +} diff --git a/quarkus-opentelemetry-exporter-azure/deployment/src/test/java/io/quarkiverse/opentelemetry/exporter/azure/deployment/AzureExporterLegacyDisabledTest.java b/quarkus-opentelemetry-exporter-azure/deployment/src/test/java/io/quarkiverse/opentelemetry/exporter/azure/deployment/AzureExporterLegacyDisabledTest.java new file mode 100644 index 0000000..3a684f4 --- /dev/null +++ b/quarkus-opentelemetry-exporter-azure/deployment/src/test/java/io/quarkiverse/opentelemetry/exporter/azure/deployment/AzureExporterLegacyDisabledTest.java @@ -0,0 +1,35 @@ +package io.quarkiverse.opentelemetry.exporter.azure.deployment; + +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.opentelemetry.api.OpenTelemetry; +import io.quarkiverse.opentelemetry.exporter.azure.runtime.AzureEndpointSampler; +import io.quarkus.test.QuarkusUnitTest; + +public class AzureExporterLegacyDisabledTest { + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest() + .withEmptyApplication() + .overrideConfigKey("quarkus.opentelemetry.tracer.exporter.azure.enabled", "false") + .overrideConfigKey("applicationinsights.connection.string", + "InstrumentationKey=bla;IngestionEndpoint=http://127.0.0.1:53602/export"); + + @Inject + OpenTelemetry openTelemetry; + + // just some class that will be available if the Azure exporter is enabled. + @Inject + Instance azureEndpointSamplers; + + @Test + void testOpenTelemetryButNoBatchSpanProcessor() { + Assertions.assertNotNull(openTelemetry); + Assertions.assertFalse(azureEndpointSamplers.isResolvable()); + } +} diff --git a/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureEndpointSampler.java b/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureEndpointSampler.java index 55108d1..eb8dab3 100644 --- a/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureEndpointSampler.java +++ b/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureEndpointSampler.java @@ -2,6 +2,8 @@ import java.util.List; +import jakarta.inject.Singleton; + import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.context.Context; @@ -14,6 +16,7 @@ * Sampler that drops spans based on the target of the request. * Inspired by {@link io.quarkus.opentelemetry.runtime.tracing.DropTargetsSampler} */ +@Singleton public class AzureEndpointSampler implements Sampler { private final List dropTargets; diff --git a/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureExporterBuildConfig.java b/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureExporterBuildConfig.java index 8bd0b87..9d2d3cb 100644 --- a/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureExporterBuildConfig.java +++ b/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureExporterBuildConfig.java @@ -5,14 +5,15 @@ import io.smallrye.config.ConfigMapping; import io.smallrye.config.WithDefault; -@ConfigMapping(prefix = "opentelemetry.tracer.exporter.azure") +@ConfigMapping(prefix = "quarkus.otel.azure") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) public interface AzureExporterBuildConfig { /** * Azure Span Exporter support. *

* Azure Span Exporter support is enabled by default. + * The legacy quarkus.opentelemetry.tracer.exporter.azure.enabled property, maps to this property. */ - @WithDefault("true") + @WithDefault("${quarkus.opentelemetry.tracer.exporter.azure.enabled:true}") Boolean enabled(); } diff --git a/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureMonitorCustomizer.java b/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureMonitorCustomizer.java index 8134cbd..3d86503 100644 --- a/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureMonitorCustomizer.java +++ b/quarkus-opentelemetry-exporter-azure/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/azure/runtime/AzureMonitorCustomizer.java @@ -1,10 +1,13 @@ package io.quarkiverse.opentelemetry.exporter.azure.runtime; +import jakarta.inject.Singleton; + import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporterBuilder; import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder; import io.quarkus.opentelemetry.runtime.AutoConfiguredOpenTelemetrySdkBuilderCustomizer; +@Singleton public class AzureMonitorCustomizer implements AutoConfiguredOpenTelemetrySdkBuilderCustomizer { private final String azureConnectionString;