From 10c335d2dde67a58d2fff4155de9ce62a130b55c Mon Sep 17 00:00:00 2001 From: brunobat Date: Mon, 17 Jun 2024 09:04:14 +0100 Subject: [PATCH] Set extension properties directly --- .../observability-devservices-lgtm.adoc | 79 ++++++++--------- .../ObservabilityDevServiceProcessor.java | 87 +++++++++++++------ .../DevResourceLifecycleManager.java | 10 +++ .../devresource/ExtensionsCatalog.java | 8 ++ .../devresource/lgtm/LgtmResource.java | 35 ++++++-- integration-tests/observability-lgtm/pom.xml | 17 ---- .../observability/test/LgtmLifecycleTest.java | 18 +++- .../observability/test/LgtmResourcesTest.java | 21 ++++- .../observability/test/LgtmTestBase.java | 6 +- .../test/support/DevResourcesTestProfile.java | 14 --- .../QuarkusTestResourceTestProfile.java | 14 --- .../src/test/resources/application.properties | 6 -- 12 files changed, 185 insertions(+), 130 deletions(-) create mode 100644 extensions/observability-devservices/testlibs/devresource-common/src/main/java/io/quarkus/observability/devresource/ExtensionsCatalog.java delete mode 100644 integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/support/DevResourcesTestProfile.java delete mode 100644 integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/support/QuarkusTestResourceTestProfile.java diff --git a/docs/src/main/asciidoc/observability-devservices-lgtm.adoc b/docs/src/main/asciidoc/observability-devservices-lgtm.adoc index e906607d41062..198871bbc2cc6 100644 --- a/docs/src/main/asciidoc/observability-devservices-lgtm.adoc +++ b/docs/src/main/asciidoc/observability-devservices-lgtm.adoc @@ -35,32 +35,28 @@ implementation("quarkus-observability-devservices-lgtm") === Metrics -If you're using https://micrometer.io/[MicroMeter's] Quarkiverse OTLP registry to push metrics to Grafana OTel LGTM, this is how you would define the export endpoint url; where `quarkus.otel-collector.url` is provided by the Observability Dev Services extension. +If you need metrics, add the Micrometer OTLP registry to your build file: -[source,properties] +[source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"] +.pom.xml ---- -# Micrometer OTLP registry -%test.quarkus.micrometer.export.otlp.url=http://${quarkus.otel-collector.url}/v1/metrics -%dev.quarkus.micrometer.export.otlp.url=http://${quarkus.otel-collector.url}/v1/metrics -%prod.quarkus.micrometer.export.otlp.url=http://localhost:4318/v1/metrics + + io.quarkiverse.micrometer.registry + quarkus-micrometer-registry-otlp + ---- -Please note that the `${quarkus.otel-collector.url}` value is generated by quarkus when it starts the Grafana OTel LGTM Dev Resource. - -Along OTel collector enpoint url, LGTM Dev Resource also provides a Grafana endpoint url - under `quarkus.grafana.url` property. - -In this case LGTM Dev Resource would be automatically started and used by Observability Dev Services. - -If you don't want all the hassle with Dev Services (e.g. lookup and re-use of existing running containers, etc) you can simply disable Dev Services and enable just Dev Resource usage: -[source,properties] +[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"] +.build.gradle ---- -quarkus.observability.enabled=false -quarkus.observability.dev-resources=true +implementation("io.quarkiverse.micrometer.registry:quarkus-micrometer-registry-otlp") ---- +When using the https://micrometer.io/[MicroMeter's] Quarkiverse OTLP registry to push metrics to Grafana OTel LGTM, the `quarkus.micrometer.export.otlp.url` property is automatically set to OTel collector endpoint as seen from the outside of the docker container. + === Tracing -Just add the quarkus-opentelemetry extension to your build file: +For Tracing add the `quarkus-opentelemetry` extension to your build file: [source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"] .pom.xml ---- @@ -76,34 +72,43 @@ Just add the quarkus-opentelemetry extension to your build file: implementation("io.quarkus:quarkus-opentelemetry") ---- -On the `application.properties` file, you can define: -[source,properties] ----- -# OpenTelemetry -quarkus.otel.exporter.otlp.traces.protocol=http/protobuf -%test.quarkus.otel.exporter.otlp.traces.endpoint=http://${quarkus.otel-collector.url} -%dev.quarkus.otel.exporter.otlp.traces.endpoint=http://${quarkus.otel-collector.url} -%prod.quarkus.otel.exporter.otlp.traces.endpoint=http://localhost:4318 ----- +The `quarkus.otel.exporter.otlp.traces.endpoint` property is automatically set to OTel collector endpoint as seen from the outside of the docker container. + +The `quarkus.otel.exporter.otlp.traces.protocol` is set to `http/protobuf`. + === Access Grafana Once you start your app in dev mode: include::{includes}/devtools/dev.adoc[] -You will see a message like this: +You will see a log entry like this: [source, log] ---- -Lgtm Dev Services Starting: 2024-02-20 11:15:24,540 INFO [org.tes.con.wai.str.HttpWaitStrategy] (build-32) /loving_chatelet: Waiting for 60 seconds for URL: http://localhost:61907/ (where port 61907 maps to container port 3000) +[io.qu.ob.de.ObservabilityDevServiceProcessor] (build-35) Dev Service Lgtm started, config: {grafana.endpoint=http://localhost:42797, quarkus.otel.exporter.otlp.traces.endpoint=http://localhost:34711, otel-collector.url=localhost:34711, quarkus.micrometer.export.otlp.url=http://localhost:34711/v1/metrics, quarkus.otel.exporter.otlp.traces.protocol=http/protobuf} + ---- -Remember that Grafana is accessible in an ephemeral port, so you need to check the logs to see which port is being used. In this example, it's port 61907. +Remember that Grafana is accessible in an ephemeral port, so you need to check the logs to see which port is being used. In this example, the grafana endpoint is `grafana.endpoint=http://localhost:42797`. If you miss the message you can always check the port with this Docker command: [source, bash] ---- docker ps | grep grafana ---- + +=== Additional configuration + +This extension will configure your `quarkus-opentelemetry` and `quarkus-micrometer-registry-otlp` extensions to send data to the OTel Collector bundled with the Grafana OTel LGTM image. + +If you don't want all the hassle with Dev Services (e.g. lookup and re-use of existing running containers, etc) you can simply disable Dev Services and enable just Dev Resource usage: + +[source,properties] +---- +quarkus.observability.enabled=false +quarkus.observability.dev-resources=true +---- + === Tests And for the least 'auto-magical' usage in the tests, simply disable both (Dev Resources are already disabled by default): @@ -142,16 +147,6 @@ Use existing Quarkus MicroMeter OTLP registry implementation("io.quarkiverse.micrometer.registry:quarkus-micrometer-registry-otlp") ---- -On the test `application.properties` file, you need to define: -[source,properties] ----- -# Micrometer OTLP registry -quarkus.micrometer.export.otlp.url=http://${quarkus.otel-collector.url}/v1/metrics -# OpenTelemetry -quarkus.otel.exporter.otlp.traces.protocol=http/protobuf -quarkus.otel.exporter.otlp.traces.endpoint=http://${quarkus.otel-collector.url} ----- - Simply inject the Meter registry into your code -- it will periodically push metrics to Grafana LGTM's OTLP HTTP endpoint. [source, java] @@ -182,14 +177,14 @@ Where you can then check Grafana's datasource API for existing metrics data. ---- public class LgtmTestBase { - @ConfigProperty(name = "quarkus.grafana.url") - String url; // NOTE -- injected Grafana endpoint url! + @ConfigProperty(name = "grafana.endpoint") + String endpoint; // NOTE -- injected Grafana endpoint! @Test public void testTracing() { String response = RestAssured.get("/api/poke?f=100").body().asString(); System.out.println(response); - GrafanaClient client = new GrafanaClient("http://" + url, "admin", "admin"); + GrafanaClient client = new GrafanaClient(endpoint, "admin", "admin"); Awaitility.await().atMost(61, TimeUnit.SECONDS).until( client::user, u -> "admin".equals(u.login)); 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..9061d75d6789b 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 @@ -12,8 +12,13 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.jboss.jandex.ClassInfo; +import org.jboss.jandex.DotName; import org.jboss.logging.Logger; +import io.quarkus.arc.deployment.BeanArchiveIndexBuildItem; +import io.quarkus.deployment.Capabilities; +import io.quarkus.deployment.Capability; import io.quarkus.deployment.Feature; import io.quarkus.deployment.IsNormal; import io.quarkus.deployment.annotations.BuildProducer; @@ -28,6 +33,7 @@ import io.quarkus.deployment.console.StartupLogCompressor; import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig; import io.quarkus.deployment.logging.LoggingSetupBuildItem; +import io.quarkus.deployment.metrics.MetricsCapabilityBuildItem; import io.quarkus.devservices.common.ContainerLocator; import io.quarkus.observability.common.config.ContainerConfig; import io.quarkus.observability.common.config.ContainerConfigUtil; @@ -35,8 +41,10 @@ import io.quarkus.observability.devresource.Container; import io.quarkus.observability.devresource.DevResourceLifecycleManager; import io.quarkus.observability.devresource.DevResources; +import io.quarkus.observability.devresource.ExtensionsCatalog; import io.quarkus.observability.runtime.config.ObservabilityConfiguration; import io.quarkus.runtime.LaunchMode; +import io.quarkus.runtime.metrics.MetricsFactory; @BuildSteps(onlyIfNot = IsNormal.class, onlyIf = { GlobalDevServicesConfig.Enabled.class, ObservabilityDevServiceProcessor.IsEnabled.class }) @@ -46,6 +54,7 @@ class ObservabilityDevServiceProcessor { private static final Map devServices = new ConcurrentHashMap<>(); private static final Map capturedDevServicesConfigurations = new ConcurrentHashMap<>(); private static final Map firstStart = new ConcurrentHashMap<>(); + public static final DotName OTLP_REGISTRY = DotName.createSimple("io.micrometer.registry.otlp.OtlpMeterRegistry"); public static class IsEnabled implements BooleanSupplier { ObservabilityConfiguration config; @@ -74,7 +83,10 @@ public void startContainers(LaunchModeBuildItem launchMode, CuratedApplicationShutdownBuildItem closeBuildItem, LoggingSetupBuildItem loggingSetupBuildItem, GlobalDevServicesConfig devServicesConfig, - BuildProducer services) { + BuildProducer services, + BeanArchiveIndexBuildItem indexBuildItem, + Capabilities capabilities, + Optional metricsConfiguration) { if (!configuration.enabled()) { log.infof("Observability dev services are disabled in config"); @@ -103,7 +115,11 @@ public void startContainers(LaunchModeBuildItem launchMode, // only do get, not remove, so it can be re-used DevServicesResultBuildItem.RunningDevService devService = devServices.get(devId); - ContainerConfig currentDevServicesConfiguration = dev.config(configuration); + ContainerConfig currentDevServicesConfiguration = dev.config( + configuration, + new ExtensionsCatalog( + capabilities.isPresent(Capability.OPENTELEMETRY_TRACER), + hasMicrometerOtlp(metricsConfiguration, indexBuildItem))); if (devService != null) { ContainerConfig capturedDevServicesConfiguration = capturedDevServicesConfigurations.get(devId); @@ -152,19 +168,22 @@ public void startContainers(LaunchModeBuildItem launchMode, } if (firstStart.computeIfAbsent(devId, x -> true)) { - Runnable closeTask = () -> { - DevServicesResultBuildItem.RunningDevService current = devServices.get(devId); - if (current != null) { - try { - current.close(); - } catch (Throwable t) { - log.errorf("Failed to stop %s container", devId, t); + Runnable closeTask = new Runnable() { + @Override + public void run() { + DevServicesResultBuildItem.RunningDevService current = devServices.get(devId); + if (current != null) { + try { + current.close(); + } catch (Throwable t) { + log.errorf("Failed to stop %s container", devId, t); + } } + firstStart.remove(devId); + //noinspection resource + devServices.remove(devId); + capturedDevServicesConfigurations.remove(devId); } - firstStart.remove(devId); - //noinspection resource - devServices.remove(devId); - capturedDevServicesConfigurations.remove(devId); }; closeBuildItem.addCloseTask(closeTask, true); } @@ -173,6 +192,18 @@ public void startContainers(LaunchModeBuildItem launchMode, }); } + private static boolean hasMicrometerOtlp(Optional metricsConfiguration, + BeanArchiveIndexBuildItem indexBuildItem) { + if (metricsConfiguration.isPresent() && + metricsConfiguration.get().metricsSupported(MetricsFactory.MICROMETER)) { + ClassInfo clazz = indexBuildItem.getIndex().getClassByName(OTLP_REGISTRY); + if (clazz != null) { + return true; + } + } + return false; + } + private DevServicesResultBuildItem.RunningDevService startContainer( String devId, DevResourceLifecycleManager dev, @@ -190,14 +221,17 @@ private DevServicesResultBuildItem.RunningDevService startContainer( return null; } - final Supplier defaultContainerSupplier = () -> { - Container container = dev.container(capturedDevServicesConfiguration, root); - timeout.ifPresent(container::withStartupTimeout); - Map config = dev.start(); - log.infof("Dev Service %s started, config: %s", devId, config); - return new DevServicesResultBuildItem.RunningDevService( - Feature.OBSERVABILITY.getName(), container.getContainerId(), - container.closeableCallback(capturedDevServicesConfiguration.serviceName()), config); + final Supplier defaultContainerSupplier = new Supplier() { + @Override + public DevServicesResultBuildItem.RunningDevService get() { + Container container = dev.container(capturedDevServicesConfiguration, root); + timeout.ifPresent(container::withStartupTimeout); + Map config = dev.start(); + log.infof("Dev Service %s started, config: %s", devId, config); + return new DevServicesResultBuildItem.RunningDevService( + Feature.OBSERVABILITY.getName(), container.getContainerId(), + container.closeableCallback(capturedDevServicesConfiguration.serviceName()), config); + } }; Map config = new LinkedHashMap<>(); // old config @@ -206,10 +240,13 @@ private DevServicesResultBuildItem.RunningDevService startContainer( .locateContainer( capturedDevServicesConfiguration.serviceName(), capturedDevServicesConfiguration.shared(), LaunchMode.current(), (p, ca) -> config.putAll(dev.config(p, ca.getHost(), ca.getPort()))) - .map(cid -> { - log.infof("Dev Service %s re-used, config: %s", devId, config); - return new DevServicesResultBuildItem.RunningDevService(Feature.OBSERVABILITY.getName(), cid, - null, config); + .map(new Function() { + @Override + public DevServicesResultBuildItem.RunningDevService apply(String cid) { + log.infof("Dev Service %s re-used, config: %s", devId, config); + return new DevServicesResultBuildItem.RunningDevService(Feature.OBSERVABILITY.getName(), cid, + null, config); + } }) .orElseGet(defaultContainerSupplier); } diff --git a/extensions/observability-devservices/testlibs/devresource-common/src/main/java/io/quarkus/observability/devresource/DevResourceLifecycleManager.java b/extensions/observability-devservices/testlibs/devresource-common/src/main/java/io/quarkus/observability/devresource/DevResourceLifecycleManager.java index be32e44084607..069bac13510ad 100644 --- a/extensions/observability-devservices/testlibs/devresource-common/src/main/java/io/quarkus/observability/devresource/DevResourceLifecycleManager.java +++ b/extensions/observability-devservices/testlibs/devresource-common/src/main/java/io/quarkus/observability/devresource/DevResourceLifecycleManager.java @@ -28,8 +28,18 @@ public interface DevResourceLifecycleManager extends * @param configuration main observability configuration * @return module's config */ + @Deprecated T config(ModulesConfiguration configuration); + /** + * Get resource's config from main observability configuration and extension catalog + * + * @param configuration main observability configuration + * @param catalog observability catalog. If OpenTelemetry or Micrometer are enabled. + * @return module's config + */ + T config(ModulesConfiguration configuration, ExtensionsCatalog catalog); + /** * Should we enable / start this dev resource. * e.g. we could already have actual service running diff --git a/extensions/observability-devservices/testlibs/devresource-common/src/main/java/io/quarkus/observability/devresource/ExtensionsCatalog.java b/extensions/observability-devservices/testlibs/devresource-common/src/main/java/io/quarkus/observability/devresource/ExtensionsCatalog.java new file mode 100644 index 0000000000000..00af2105c6c0b --- /dev/null +++ b/extensions/observability-devservices/testlibs/devresource-common/src/main/java/io/quarkus/observability/devresource/ExtensionsCatalog.java @@ -0,0 +1,8 @@ +package io.quarkus.observability.devresource; + +/** + * Relevant Observability extensions present. + */ +public record ExtensionsCatalog(boolean hasOpenTelemetry, + boolean hasMicrometerOtlp) { +} 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..4fab76355a1ed 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 @@ -1,5 +1,6 @@ package io.quarkus.observability.devresource.lgtm; +import java.util.HashMap; import java.util.Map; import io.quarkus.observability.common.ContainerConstants; @@ -7,29 +8,39 @@ import io.quarkus.observability.common.config.ModulesConfiguration; import io.quarkus.observability.devresource.Container; import io.quarkus.observability.devresource.DevResourceLifecycleManager; +import io.quarkus.observability.devresource.ExtensionsCatalog; import io.quarkus.observability.devresource.testcontainers.ContainerResource; import io.quarkus.observability.testcontainers.LgtmContainer; public class LgtmResource extends ContainerResource { + private ExtensionsCatalog catalog; + @Override public LgtmConfig config(ModulesConfiguration configuration) { return configuration.lgtm(); } + @Override + public LgtmConfig config(ModulesConfiguration configuration, ExtensionsCatalog catalog) { + this.catalog = catalog; + return config(configuration); + } + @Override public Container container(LgtmConfig config, ModulesConfiguration root) { return set(new LgtmContainer(config)); } + // FIXME consolidate config methods. @Override 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.endpoint", String.format("http://%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("otel-collector.url", String.format("%s:%s", host, publicPort)); } return Map.of(); } @@ -42,9 +53,23 @@ protected LgtmContainer defaultContainer() { @Override 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())); + + //Set non Quarkus properties for convenience and testing. + Map containerConfigs = new HashMap<>(); + containerConfigs.put("grafana.endpoint", String.format("http://%s:%s", host, container.getGrafanaPort())); + containerConfigs.put("otel-collector.url", String.format("%s:%s", host, container.getOtlpPort())); + + // set relevant properties for Quarkus extensions directly + if (catalog != null && catalog.hasOpenTelemetry()) { + containerConfigs.put("quarkus.otel.exporter.otlp.traces.endpoint", + String.format("http://%s:%s", host, container.getOtlpPort())); + containerConfigs.put("quarkus.otel.exporter.otlp.traces.protocol", "http/protobuf"); + } + if (catalog != null && catalog.hasMicrometerOtlp()) { + containerConfigs.put("quarkus.micrometer.export.otlp.url", + String.format("http://%s:%s/v1/metrics", host, container.getOtlpPort())); + } + return containerConfigs; } @Override diff --git a/integration-tests/observability-lgtm/pom.xml b/integration-tests/observability-lgtm/pom.xml index 0abc8789677cb..ac48beae5ef5b 100644 --- a/integration-tests/observability-lgtm/pom.xml +++ b/integration-tests/observability-lgtm/pom.xml @@ -28,10 +28,6 @@ quarkus-micrometer-registry-otlp 3.2.4 - - io.quarkus - quarkus-micrometer - io.quarkus quarkus-opentelemetry @@ -88,19 +84,6 @@ - - io.quarkus - quarkus-micrometer-deployment - ${project.version} - pom - test - - - * - * - - - diff --git a/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmLifecycleTest.java b/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmLifecycleTest.java index 17a1b4488aec5..b6c476eec06e3 100644 --- a/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmLifecycleTest.java +++ b/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmLifecycleTest.java @@ -1,17 +1,31 @@ package io.quarkus.observability.test; +import java.util.Map; + import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.OS; import io.quarkus.observability.devresource.lgtm.LgtmResource; -import io.quarkus.observability.test.support.QuarkusTestResourceTestProfile; import io.quarkus.test.common.WithTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; @QuarkusTest @WithTestResource(LgtmResource.class) -@TestProfile(QuarkusTestResourceTestProfile.class) +@TestProfile(LgtmLifecycleTest.TestResourceTestProfileOff.class) @DisabledOnOs(OS.WINDOWS) public class LgtmLifecycleTest extends LgtmTestBase { + + public static class TestResourceTestProfileOff implements QuarkusTestProfile { + @Override + public Map getConfigOverrides() { + return Map.of( + "quarkus.micrometer.export.otlp.url", "http://${otel-collector.url}/v1/metrics", + "quarkus.otel.exporter.otlp.traces.protocol", "http/protobuf", + "quarkus.otel.exporter.otlp.traces.endpoint", "http://${otel-collector.url}", + "quarkus.observability.dev-resources", "false", + "quarkus.observability.enabled", "false"); + } + } } diff --git a/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmResourcesTest.java b/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmResourcesTest.java index 6cd232235b38f..8383556181e5b 100644 --- a/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmResourcesTest.java +++ b/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmResourcesTest.java @@ -1,14 +1,31 @@ package io.quarkus.observability.test; +import java.util.Map; + import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.OS; -import io.quarkus.observability.test.support.DevResourcesTestProfile; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; +/** + * Simple case were you have to provide your own configuration + */ @QuarkusTest -@TestProfile(DevResourcesTestProfile.class) +@TestProfile(LgtmResourcesTest.DevResourcesTestProfileOnly.class) @DisabledOnOs(OS.WINDOWS) public class LgtmResourcesTest extends LgtmTestBase { + + public static class DevResourcesTestProfileOnly implements QuarkusTestProfile { + @Override + public Map getConfigOverrides() { + return Map.of( + "quarkus.micrometer.export.otlp.url", "http://${otel-collector.url}/v1/metrics", + "quarkus.otel.exporter.otlp.traces.protocol", "http/protobuf", + "quarkus.otel.exporter.otlp.traces.endpoint", "http://${otel-collector.url}", + "quarkus.observability.dev-resources", "true", + "quarkus.observability.enabled", "false"); + } + } } diff --git a/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmTestBase.java b/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmTestBase.java index 6223f25763584..ee49956a5a296 100644 --- a/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmTestBase.java +++ b/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmTestBase.java @@ -13,15 +13,15 @@ public abstract class LgtmTestBase { private final Logger log = Logger.getLogger(getClass()); - @ConfigProperty(name = "quarkus.grafana.url") - String url; + @ConfigProperty(name = "grafana.endpoint") + String endpoint; @Test public void testTracing() { log.info("Testing Grafana ..."); String response = RestAssured.get("/api/poke?f=100").body().asString(); log.info("Response: " + response); - GrafanaClient client = new GrafanaClient("http://" + url, "admin", "admin"); + GrafanaClient client = new GrafanaClient(endpoint, "admin", "admin"); Awaitility.await().atMost(61, TimeUnit.SECONDS).until( client::user, u -> "admin".equals(u.login)); diff --git a/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/support/DevResourcesTestProfile.java b/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/support/DevResourcesTestProfile.java deleted file mode 100644 index 1110a11073098..0000000000000 --- a/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/support/DevResourcesTestProfile.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.quarkus.observability.test.support; - -import java.util.Map; - -import io.quarkus.test.junit.QuarkusTestProfile; - -public class DevResourcesTestProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of( - "quarkus.observability.dev-resources", "true", - "quarkus.observability.enabled", "false"); - } -} diff --git a/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/support/QuarkusTestResourceTestProfile.java b/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/support/QuarkusTestResourceTestProfile.java deleted file mode 100644 index b60772d61d550..0000000000000 --- a/integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/support/QuarkusTestResourceTestProfile.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.quarkus.observability.test.support; - -import java.util.Map; - -import io.quarkus.test.junit.QuarkusTestProfile; - -public class QuarkusTestResourceTestProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of( - "quarkus.observability.dev-resources", "false", - "quarkus.observability.enabled", "false"); - } -} diff --git a/integration-tests/observability-lgtm/src/test/resources/application.properties b/integration-tests/observability-lgtm/src/test/resources/application.properties index d3f0cfca1f442..e1e468769a002 100644 --- a/integration-tests/observability-lgtm/src/test/resources/application.properties +++ b/integration-tests/observability-lgtm/src/test/resources/application.properties @@ -8,9 +8,3 @@ quarkus.log.category."io.quarkus.devservices".level=DEBUG quarkus.micrometer.export.otlp.enabled=true quarkus.micrometer.export.otlp.publish=true quarkus.micrometer.export.otlp.step=PT5S -quarkus.micrometer.export.otlp.default-registry=true -quarkus.micrometer.export.otlp.url=http://${quarkus.otel-collector.url}/v1/metrics - -#opentelemetry -quarkus.otel.exporter.otlp.traces.protocol=http/protobuf -quarkus.otel.exporter.otlp.traces.endpoint=http://${quarkus.otel-collector.url}