diff --git a/bom/application/pom.xml b/bom/application/pom.xml index e6f8ae173286f..2d51bacc5cb9b 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -3081,6 +3081,11 @@ quarkus-observability-devservices ${project.version} + + io.quarkus + quarkus-observability-devservices-deployment + ${project.version} + io.quarkus quarkus-observability-devservices-lgtm diff --git a/extensions/observability-devservices/deployment/src/main/java/io/quarkus/observability/deployment/ObservabilityDevServiceProcessor.java b/extensions/observability-devservices/deployment/src/main/java/io/quarkus/observability/deployment/ObservabilityDevServiceProcessor.java index 48c5932448d18..cb391de7ec138 100644 --- a/extensions/observability-devservices/deployment/src/main/java/io/quarkus/observability/deployment/ObservabilityDevServiceProcessor.java +++ b/extensions/observability-devservices/deployment/src/main/java/io/quarkus/observability/deployment/ObservabilityDevServiceProcessor.java @@ -1,6 +1,7 @@ package io.quarkus.observability.deployment; import java.time.Duration; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -12,6 +13,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.eclipse.microprofile.config.ConfigProvider; import org.jboss.logging.Logger; import io.quarkus.deployment.Feature; @@ -37,12 +39,17 @@ import io.quarkus.observability.devresource.DevResources; import io.quarkus.observability.runtime.config.ObservabilityConfiguration; import io.quarkus.runtime.LaunchMode; +import io.quarkus.runtime.configuration.ConfigUtils; +import io.smallrye.config.SmallRyeConfig; @BuildSteps(onlyIfNot = IsNormal.class, onlyIf = { GlobalDevServicesConfig.Enabled.class, ObservabilityDevServiceProcessor.IsEnabled.class }) class ObservabilityDevServiceProcessor { private static final Logger log = Logger.getLogger(ObservabilityDevServiceProcessor.class); + private static final String OTEL_COLLECTOR_URL = "quarkus.otel-collector.url"; + private static final String OTEL_COLLECTOR_URL_EXPRESSION = "http://${%s}".formatted(OTEL_COLLECTOR_URL); + private static final String OTLP_TRACES_ENDPOINT = "quarkus.otel.exporter.otlp.traces.endpoint"; private static final Map devServices = new ConcurrentHashMap<>(); private static final Map capturedDevServicesConfigurations = new ConcurrentHashMap<>(); private static final Map firstStart = new ConcurrentHashMap<>(); @@ -76,6 +83,14 @@ public void startContainers(LaunchModeBuildItem launchMode, GlobalDevServicesConfig devServicesConfig, BuildProducer services) { + // To keep backwards compatibility we want to allow "http://${quarkus.otel-collector.url}" expression as a value + if (ConfigUtils.isPropertyPresent(OTLP_TRACES_ENDPOINT) && + !ConfigProvider.getConfig().unwrap(SmallRyeConfig.class).getConfigValue(OTLP_TRACES_ENDPOINT).getRawValue() + .equals(OTEL_COLLECTOR_URL_EXPRESSION)) { + log.infof("Observability dev services won't start due to property [%s] being defined", OTLP_TRACES_ENDPOINT); + return; + } + if (!configuration.enabled()) { log.infof("Observability dev services are disabled in config"); return; @@ -193,7 +208,8 @@ private DevServicesResultBuildItem.RunningDevService startContainer( final Supplier defaultContainerSupplier = () -> { Container container = dev.container(capturedDevServicesConfiguration, root); timeout.ifPresent(container::withStartupTimeout); - Map config = dev.start(); + Map config = new HashMap<>(dev.start()); + addCollectorUrlProperty(config); log.infof("Dev Service %s started, config: %s", devId, config); return new DevServicesResultBuildItem.RunningDevService( Feature.OBSERVABILITY.getName(), container.getContainerId(), @@ -205,7 +221,10 @@ private DevServicesResultBuildItem.RunningDevService startContainer( return containerLocator .locateContainer( capturedDevServicesConfiguration.serviceName(), capturedDevServicesConfiguration.shared(), - LaunchMode.current(), (p, ca) -> config.putAll(dev.config(p, ca.getHost(), ca.getPort()))) + LaunchMode.current(), (p, ca) -> { + config.putAll(dev.config(p, ca.getHost(), ca.getPort())); + addCollectorUrlProperty(config); + }) .map(cid -> { log.infof("Dev Service %s re-used, config: %s", devId, config); return new DevServicesResultBuildItem.RunningDevService(Feature.OBSERVABILITY.getName(), cid, @@ -213,4 +232,20 @@ private DevServicesResultBuildItem.RunningDevService startContainer( }) .orElseGet(defaultContainerSupplier); } + + /** + * Adds property {@code OTEL_COLLECTOR_URL} to keep backwards compatibility if {@code OTLP_TRACES_ENDPOINT} is defined + * i.e. previously this was possible "quarkus.otel.exporter.otlp.traces.endpoint=http://${quarkus.otel-collector.url}" + * and now we set {@code OTLP_TRACES_ENDPOINT} directly and we set {@code OTEL_COLLECTOR_URL} in case this is still + * referenced. + * + * @param config + * @return + */ + private static void addCollectorUrlProperty(Map config) { + // Remove leading http:// from the variable + if (config.containsKey(OTLP_TRACES_ENDPOINT)) { + config.put(OTEL_COLLECTOR_URL, config.get(OTLP_TRACES_ENDPOINT).substring("http://".length())); + } + } } diff --git a/extensions/observability-devservices/testlibs/devresource-lgtm/src/main/java/io/quarkus/observability/devresource/lgtm/LgtmResource.java b/extensions/observability-devservices/testlibs/devresource-lgtm/src/main/java/io/quarkus/observability/devresource/lgtm/LgtmResource.java index 6273380d805ba..c2e8ad75794b2 100644 --- a/extensions/observability-devservices/testlibs/devresource-lgtm/src/main/java/io/quarkus/observability/devresource/lgtm/LgtmResource.java +++ b/extensions/observability-devservices/testlibs/devresource-lgtm/src/main/java/io/quarkus/observability/devresource/lgtm/LgtmResource.java @@ -12,6 +12,12 @@ public class LgtmResource extends ContainerResource { + private static final String OTLP_TRACES_PROTOCOL = "quarkus.otel.exporter.otlp.traces.protocol"; + private static final String HTTP_PROTOBUF = "http/protobuf"; + private static final String OTLP_TRACES_ENDPOINT = "quarkus.otel.exporter.otlp.traces.endpoint"; + private static final String OTLP_TRACES_ENDPOINT_CONVERTER = "http://%s:%s"; + private static final String GRAFANA_URL = "quarkus.grafana.url"; + @Override public LgtmConfig config(ModulesConfiguration configuration) { return configuration.lgtm(); @@ -26,10 +32,11 @@ public Container container(LgtmConfig config, ModulesConfiguration r public Map config(int privatePort, String host, int publicPort) { switch (privatePort) { case ContainerConstants.GRAFANA_PORT: - return Map.of("quarkus.grafana.url", String.format("%s:%s", host, publicPort)); + return Map.of(GRAFANA_URL, String.format("%s:%s", host, publicPort)); case ContainerConstants.OTEL_GRPC_EXPORTER_PORT: case ContainerConstants.OTEL_HTTP_EXPORTER_PORT: - return Map.of("quarkus.otel-collector.url", String.format("%s:%s", host, publicPort)); + return Map.of(OTLP_TRACES_ENDPOINT, OTLP_TRACES_ENDPOINT_CONVERTER.formatted(host, publicPort), + OTLP_TRACES_PROTOCOL, HTTP_PROTOBUF); } return Map.of(); } @@ -43,8 +50,9 @@ protected LgtmContainer defaultContainer() { public Map doStart() { String host = container.getHost(); return Map.of( - "quarkus.grafana.url", String.format("%s:%s", host, container.getGrafanaPort()), - "quarkus.otel-collector.url", String.format("%s:%s", host, container.getOtlpPort())); + GRAFANA_URL, String.format("%s:%s", host, container.getGrafanaPort()), + OTLP_TRACES_ENDPOINT, OTLP_TRACES_ENDPOINT_CONVERTER.formatted(host, container.getOtlpPort()), + OTLP_TRACES_PROTOCOL, HTTP_PROTOBUF); } @Override diff --git a/extensions/opentelemetry/deployment/pom.xml b/extensions/opentelemetry/deployment/pom.xml index 6bdba442a7377..d133a5ca9d0a5 100644 --- a/extensions/opentelemetry/deployment/pom.xml +++ b/extensions/opentelemetry/deployment/pom.xml @@ -17,6 +17,12 @@ io.quarkus quarkus-opentelemetry + + + io.quarkus + quarkus-observability-devservices-deployment + + io.quarkus quarkus-core-deployment diff --git a/extensions/opentelemetry/deployment/src/test/resources/application-default.properties b/extensions/opentelemetry/deployment/src/test/resources/application-default.properties index 3284a760fc5eb..523f28389e83b 100644 --- a/extensions/opentelemetry/deployment/src/test/resources/application-default.properties +++ b/extensions/opentelemetry/deployment/src/test/resources/application-default.properties @@ -1,3 +1,4 @@ quarkus.otel.traces.exporter=test-span-exporter quarkus.otel.bsp.schedule.delay=50 -quarkus.otel.bsp.export.timeout=1s \ No newline at end of file +quarkus.otel.bsp.export.timeout=1s +quarkus.observability.enabled=false \ No newline at end of file diff --git a/extensions/opentelemetry/runtime/pom.xml b/extensions/opentelemetry/runtime/pom.xml index 833cc2d93eb6b..62cc83d40f591 100644 --- a/extensions/opentelemetry/runtime/pom.xml +++ b/extensions/opentelemetry/runtime/pom.xml @@ -18,6 +18,22 @@ io.quarkus quarkus-core + + + io.quarkus + quarkus-observability-devservices + + + io.quarkus + quarkus-test-common + + + + + io.quarkus + quarkus-observability-devresource-lgtm + + io.quarkus quarkus-tls-registry diff --git a/integration-tests/jfr-opentelemetry/src/main/resources/application.properties b/integration-tests/jfr-opentelemetry/src/main/resources/application.properties index 82aef9fed0a3b..4dc5d21e94ef1 100644 --- a/integration-tests/jfr-opentelemetry/src/main/resources/application.properties +++ b/integration-tests/jfr-opentelemetry/src/main/resources/application.properties @@ -1 +1,3 @@ -quarkus.native.monitoring=jfr \ No newline at end of file +quarkus.native.monitoring=jfr + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry-grpc/src/main/resources/application.properties b/integration-tests/opentelemetry-grpc/src/main/resources/application.properties index 390c2a12ae4a7..fdb192e62082f 100644 --- a/integration-tests/opentelemetry-grpc/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-grpc/src/main/resources/application.properties @@ -2,4 +2,6 @@ quarkus.grpc.clients.hello.host=localhost %test.quarkus.grpc.clients.hello.port=9001 quarkus.otel.bsp.schedule.delay=100 -quarkus.otel.bsp.export.timeout=5s \ No newline at end of file +quarkus.otel.bsp.export.timeout=5s + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry-jaeger-remote/src/main/resources/application.properties b/integration-tests/opentelemetry-jaeger-remote/src/main/resources/application.properties index 597559277c1a8..951401ce6ec3c 100644 --- a/integration-tests/opentelemetry-jaeger-remote/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-jaeger-remote/src/main/resources/application.properties @@ -5,3 +5,5 @@ quarkus.application.version=999-SNAPSHOT quarkus.otel.traces.sampler=jaeger_remote quarkus.otel.traces.sampler.arg=endpoint=http://localhost:14250,pollingInterval=5000,initialSamplingRate=1.0 quarkus.otel.traces.exporter=jaeger + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry-quartz/src/main/resources/application.properties b/integration-tests/opentelemetry-quartz/src/main/resources/application.properties index b32b9f635240d..d6de887345254 100644 --- a/integration-tests/opentelemetry-quartz/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-quartz/src/main/resources/application.properties @@ -2,4 +2,6 @@ quarkus.otel.bsp.schedule.delay=100 quarkus.otel.bsp.export.timeout=5s -quarkus.scheduler.tracing.enabled=true \ No newline at end of file +quarkus.scheduler.tracing.enabled=true + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry-quickstart/src/main/resources/application.properties b/integration-tests/opentelemetry-quickstart/src/main/resources/application.properties index 5a8972253198d..d7da6c90b7eee 100644 --- a/integration-tests/opentelemetry-quickstart/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-quickstart/src/main/resources/application.properties @@ -1,3 +1,5 @@ # speed up build quarkus.otel.bsp.schedule.delay=0 quarkus.otel.bsp.export.timeout=5s + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry-reactive-messaging/src/main/resources/application.properties b/integration-tests/opentelemetry-reactive-messaging/src/main/resources/application.properties index b87b830bcc721..0804b245f71ba 100644 --- a/integration-tests/opentelemetry-reactive-messaging/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-reactive-messaging/src/main/resources/application.properties @@ -8,4 +8,6 @@ mp.messaging.incoming.traces-in2.topic=traces2 mp.messaging.incoming.traces-in2.auto.offset.reset=earliest quarkus.otel.bsp.schedule.delay=100 -quarkus.otel.bsp.export.timeout=5s \ No newline at end of file +quarkus.otel.bsp.export.timeout=5s + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry-reactive/src/main/resources/application.properties b/integration-tests/opentelemetry-reactive/src/main/resources/application.properties index 0518dd1e503eb..b6506f0dc2821 100644 --- a/integration-tests/opentelemetry-reactive/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-reactive/src/main/resources/application.properties @@ -13,3 +13,5 @@ quarkus.http.auth.permission.secured.policy=authenticated quarkus.http.auth.permission.secured.paths=/secured/* quarkus.otel.security-events.enabled=true + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry-redis-instrumentation/src/main/resources/application.properties b/integration-tests/opentelemetry-redis-instrumentation/src/main/resources/application.properties index ed666d4a38ae3..eb8a194291f5a 100644 --- a/integration-tests/opentelemetry-redis-instrumentation/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-redis-instrumentation/src/main/resources/application.properties @@ -8,3 +8,5 @@ quarkus.redis.devservices.port=16379 # speed up build quarkus.otel.bsp.schedule.delay=100 quarkus.otel.bsp.export.timeout=5s + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry-scheduler/src/main/resources/application.properties b/integration-tests/opentelemetry-scheduler/src/main/resources/application.properties index b32b9f635240d..d6de887345254 100644 --- a/integration-tests/opentelemetry-scheduler/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-scheduler/src/main/resources/application.properties @@ -2,4 +2,6 @@ quarkus.otel.bsp.schedule.delay=100 quarkus.otel.bsp.export.timeout=5s -quarkus.scheduler.tracing.enabled=true \ No newline at end of file +quarkus.scheduler.tracing.enabled=true + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry-spi/src/main/resources/application.properties b/integration-tests/opentelemetry-spi/src/main/resources/application.properties index b08e1cd0930c4..10cd4e5b77515 100644 --- a/integration-tests/opentelemetry-spi/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-spi/src/main/resources/application.properties @@ -11,3 +11,5 @@ quarkus.otel.bsp.export.timeout=5s pingpong/mp-rest/url=${test.url} simple/mp-rest/url=${test.url} + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry-vertx-exporter/src/main/resources/application.properties b/integration-tests/opentelemetry-vertx-exporter/src/main/resources/application.properties index edb424258ea0a..93230730e437e 100644 --- a/integration-tests/opentelemetry-vertx-exporter/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-vertx-exporter/src/main/resources/application.properties @@ -1 +1,3 @@ quarkus.application.name=integration test + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry-vertx/src/main/resources/application.properties b/integration-tests/opentelemetry-vertx/src/main/resources/application.properties index 1b1e906a64aa0..ff52f53249d71 100644 --- a/integration-tests/opentelemetry-vertx/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-vertx/src/main/resources/application.properties @@ -2,4 +2,6 @@ quarkus.micrometer.enabled=true quarkus.micrometer.binder-enabled-default=false quarkus.otel.bsp.schedule.delay=100 -quarkus.otel.bsp.export.timeout=5s \ No newline at end of file +quarkus.otel.bsp.export.timeout=5s + +quarkus.observability.enabled=false \ No newline at end of file diff --git a/integration-tests/opentelemetry/src/main/resources/application.properties b/integration-tests/opentelemetry/src/main/resources/application.properties index 514f563c31933..01785cb0a49ea 100644 --- a/integration-tests/opentelemetry/src/main/resources/application.properties +++ b/integration-tests/opentelemetry/src/main/resources/application.properties @@ -16,3 +16,5 @@ quarkus.security.users.embedded.users.scott=reader quarkus.security.users.embedded.plain-text=true quarkus.security.users.embedded.enabled=true quarkus.http.auth.basic=true + +quarkus.observability.enabled=false \ No newline at end of file