diff --git a/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/microprofile/telemetry/main/module.xml b/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/microprofile/telemetry/main/module.xml
index 437e23a13049..48d493880732 100644
--- a/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/microprofile/telemetry/main/module.xml
+++ b/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/microprofile/telemetry/main/module.xml
@@ -42,7 +42,9 @@
-
+
+
+
diff --git a/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/opentelemetry-api/main/module.xml b/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/opentelemetry-api/main/module.xml
index 6a7c90183949..253b24cdd395 100644
--- a/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/opentelemetry-api/main/module.xml
+++ b/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/opentelemetry-api/main/module.xml
@@ -22,14 +22,14 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/opentelemetry/main/module.xml b/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/opentelemetry/main/module.xml
index 6771f478e427..0e9a00e7ddc7 100644
--- a/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/opentelemetry/main/module.xml
+++ b/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/org/wildfly/extension/opentelemetry/main/module.xml
@@ -41,5 +41,6 @@
+
diff --git a/legacy/opentracing-extension/pom.xml b/legacy/opentracing-extension/pom.xml
index 41f78fbc72d9..2bd992126e9c 100644
--- a/legacy/opentracing-extension/pom.xml
+++ b/legacy/opentracing-extension/pom.xml
@@ -110,10 +110,20 @@
metainf-services
provided
+
+ org.wildfly.core
+ wildfly-subsystem
+ provided
+
${project.groupId}
wildfly-opentelemetry
test
+
+ ${project.groupId}
+ wildfly-opentelemetry-api
+ test
+
diff --git a/microprofile/telemetry-smallrye/extension/pom.xml b/microprofile/telemetry-smallrye/extension/pom.xml
index 2801b6bba87e..1d375780cffc 100644
--- a/microprofile/telemetry-smallrye/extension/pom.xml
+++ b/microprofile/telemetry-smallrye/extension/pom.xml
@@ -86,6 +86,10 @@
org.wildfly.core
wildfly-server
+
+ org.wildfly.core
+ wildfly-subsystem
+
${ee.maven.groupId}
@@ -104,6 +108,11 @@
${ee.maven.groupId}
wildfly-weld-common
+
+ ${full.maven.groupId}
+ wildfly-opentelemetry-api
+
+
org.jboss.logging
jboss-logging-annotations
@@ -146,6 +155,5 @@
junit
test
-
diff --git a/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetryDependencyProcessor.java b/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetryDependencyProcessor.java
index 7dbd39c62401..89e0792f3794 100644
--- a/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetryDependencyProcessor.java
+++ b/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetryDependencyProcessor.java
@@ -15,15 +15,17 @@
import org.jboss.as.server.deployment.module.ModuleSpecification;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleLoader;
+import org.jboss.msc.service.ServiceName;
+import org.wildfly.extension.opentelemetry.api.WildFlyOpenTelemetryConfig;
+import org.wildfly.service.ServiceDependency;
class MicroProfileTelemetryDependencyProcessor implements DeploymentUnitProcessor {
- public MicroProfileTelemetryDependencyProcessor() {
-
- }
-
@Override
public void deploy(DeploymentPhaseContext phaseContext) {
addDependencies(phaseContext.getDeploymentUnit());
+
+ // Ensure the OpenTelemetryConfig is available before the next phase DeploymentUnitPhaseService starts
+ phaseContext.requires(ServiceDependency.on(ServiceName.parse(WildFlyOpenTelemetryConfig.SERVICE_DESCRIPTOR.getName())));
}
private void addDependencies(DeploymentUnit deploymentUnit) {
diff --git a/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetryDeploymentProcessor.java b/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetryDeploymentProcessor.java
index 81b93373021f..838a81baaf70 100644
--- a/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetryDeploymentProcessor.java
+++ b/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetryDeploymentProcessor.java
@@ -12,7 +12,6 @@
import java.util.Map;
import java.util.function.Supplier;
-import io.smallrye.opentelemetry.api.OpenTelemetryConfig;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.ee.structure.DeploymentType;
import org.jboss.as.ee.structure.DeploymentTypeMarker;
@@ -23,8 +22,15 @@
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.weld.WeldCapability;
import org.wildfly.extension.microprofile.telemetry.api.MicroProfileTelemetryCdiExtension;
+import org.wildfly.extension.opentelemetry.api.WildFlyOpenTelemetryConfig;
public class MicroProfileTelemetryDeploymentProcessor implements DeploymentUnitProcessor {
+ private final Supplier configSupplier;
+
+ public MicroProfileTelemetryDeploymentProcessor(Supplier configSupplier) {
+ this.configSupplier = configSupplier;
+ }
+
@Override
public void deploy(DeploymentPhaseContext deploymentPhaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = deploymentPhaseContext.getDeploymentUnit();
@@ -39,10 +45,7 @@ public void deploy(DeploymentPhaseContext deploymentPhaseContext) throws Deploym
MPTEL_LOGGER.debug("The deployment does not have Jakarta Contexts and Dependency Injection enabled. " +
"Skipping MicroProfile Telemetry integration.");
} else {
- final OpenTelemetryConfig serverConfig =
- (OpenTelemetryConfig) support.getCapabilityRuntimeAPI("org.wildfly.extension.opentelemetry.config",
- Supplier.class).get();
- Map properties = new HashMap<>(serverConfig.properties());
+ Map properties = new HashMap<>(configSupplier.get().properties());
if (!properties.containsKey("otel.service.name")) {
properties.put("otel.service.name", getServiceName(deploymentUnit));
}
diff --git a/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetrySubsystemAdd.java b/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetrySubsystemAdd.java
index 98e2a7f11f4f..9a840ec86979 100644
--- a/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetrySubsystemAdd.java
+++ b/microprofile/telemetry-smallrye/extension/src/main/java/org/wildfly/extension/microprofile/telemetry/MicroProfileTelemetrySubsystemAdd.java
@@ -7,6 +7,8 @@
import static org.wildfly.extension.microprofile.telemetry.MicroProfileTelemetryExtensionLogger.MPTEL_LOGGER;
+import java.util.concurrent.atomic.AtomicReference;
+
import org.jboss.as.controller.AbstractBoottimeAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
@@ -14,8 +16,13 @@
import org.jboss.as.server.DeploymentProcessorTarget;
import org.jboss.as.server.deployment.Phase;
import org.jboss.dmr.ModelNode;
+import org.wildfly.extension.opentelemetry.api.WildFlyOpenTelemetryConfig;
+import org.wildfly.subsystem.service.ServiceDependency;
+import org.wildfly.subsystem.service.ServiceInstaller;
public class MicroProfileTelemetrySubsystemAdd extends AbstractBoottimeAddStepHandler {
+ private final AtomicReference openTelemetryConfig = new AtomicReference<>();
+
MicroProfileTelemetrySubsystemAdd() {
super();
}
@@ -29,6 +36,12 @@ protected void performBoottime(OperationContext context, ModelNode operation, Mo
super.performBoottime(context, operation, model);
+ ServiceInstaller.builder(ServiceDependency.on(WildFlyOpenTelemetryConfig.SERVICE_DESCRIPTOR))
+ .withCaptor(openTelemetryConfig::set)
+ .build()
+ .install(context);
+
+
context.addStep(new AbstractDeploymentChainStep() {
@Override
public void execute(DeploymentProcessorTarget processorTarget) {
@@ -42,7 +55,7 @@ public void execute(DeploymentProcessorTarget processorTarget) {
MicroProfileTelemetryExtension.SUBSYSTEM_NAME,
Phase.POST_MODULE,
Phase.POST_MODULE_MICROPROFILE_TELEMETRY,
- new MicroProfileTelemetryDeploymentProcessor());
+ new MicroProfileTelemetryDeploymentProcessor(openTelemetryConfig::get));
}
}, OperationContext.Stage.RUNTIME);
}
diff --git a/observability/opentelemetry-api/pom.xml b/observability/opentelemetry-api/pom.xml
index 092a97d77161..a3fe9f3195b5 100644
--- a/observability/opentelemetry-api/pom.xml
+++ b/observability/opentelemetry-api/pom.xml
@@ -94,6 +94,10 @@
jakarta.annotation-api
compile
+
+ org.wildfly.core
+ wildfly-service
+
diff --git a/observability/opentelemetry-api/src/main/java/org/wildfly/extension/opentelemetry/api/OpenTelemetryCdiExtension.java b/observability/opentelemetry-api/src/main/java/org/wildfly/extension/opentelemetry/api/OpenTelemetryCdiExtension.java
index 163b6376dbc9..09920aa2843e 100644
--- a/observability/opentelemetry-api/src/main/java/org/wildfly/extension/opentelemetry/api/OpenTelemetryCdiExtension.java
+++ b/observability/opentelemetry-api/src/main/java/org/wildfly/extension/opentelemetry/api/OpenTelemetryCdiExtension.java
@@ -23,7 +23,7 @@ public final class OpenTelemetryCdiExtension implements Extension {
private final WildFlyOpenTelemetryConfig config;
public OpenTelemetryCdiExtension(boolean useServerConfig, Map config) {
- this (useServerConfig, new WildFlyOpenTelemetryConfig(config));
+ this (useServerConfig, new WildFlyOpenTelemetryConfig(config, useServerConfig));
}
public OpenTelemetryCdiExtension(boolean useServerConfig, WildFlyOpenTelemetryConfig config) {
diff --git a/observability/opentelemetry-api/src/main/java/org/wildfly/extension/opentelemetry/api/WildFlyOpenTelemetryConfig.java b/observability/opentelemetry-api/src/main/java/org/wildfly/extension/opentelemetry/api/WildFlyOpenTelemetryConfig.java
index f530220eca7c..7ad6dfae5798 100644
--- a/observability/opentelemetry-api/src/main/java/org/wildfly/extension/opentelemetry/api/WildFlyOpenTelemetryConfig.java
+++ b/observability/opentelemetry-api/src/main/java/org/wildfly/extension/opentelemetry/api/WildFlyOpenTelemetryConfig.java
@@ -10,8 +10,13 @@
import java.util.Map;
import io.smallrye.opentelemetry.api.OpenTelemetryConfig;
+import org.wildfly.service.descriptor.NullaryServiceDescriptor;
public final class WildFlyOpenTelemetryConfig implements OpenTelemetryConfig {
+ public static NullaryServiceDescriptor SERVICE_DESCRIPTOR =
+ NullaryServiceDescriptor.of("org.wildfly.extension.opentelemetry.config",
+ WildFlyOpenTelemetryConfig.class);
+
public static final String OTEL_BSP_MAX_EXPORT_BATCH_SIZE = "otel.bsp.max.export.batch.size";
public static final String OTEL_BSP_MAX_QUEUE_SIZE = "otel.bsp.max.queue.size";
public static final String OTEL_BSP_SCHEDULE_DELAY = "otel.bsp.schedule.delay";
@@ -30,14 +35,17 @@ public final class WildFlyOpenTelemetryConfig implements OpenTelemetryConfig {
public static final String OTEL_TRACES_SAMPLER_ARG = "otel.traces.sampler.arg";
private final Map properties;
+ private final boolean mpTelemetryInstalled;
- public WildFlyOpenTelemetryConfig(Map properties) {
+ public WildFlyOpenTelemetryConfig(Map properties, boolean mpTelemetryInstalled) {
this.properties = Collections.unmodifiableMap(properties);
+ this.mpTelemetryInstalled = mpTelemetryInstalled;
}
public WildFlyOpenTelemetryConfig(String serviceName, String exporter, String endpoint,
Long batchDelay, Long maxQueueSize, Long maxExportBatchSize,
- Long exportTimeout, String spanProcessorType, String sampler, Double ratio) {
+ Long exportTimeout, String spanProcessorType, String sampler, Double ratio,
+ boolean mpTelemetryInstalled) {
Map config = new HashMap<>();
// Default to on
addValue(config, OTEL_SDK_DISABLED, "false");
@@ -82,6 +90,7 @@ public WildFlyOpenTelemetryConfig(String serviceName, String exporter, String en
properties = Collections.unmodifiableMap(config);
+ this.mpTelemetryInstalled = mpTelemetryInstalled;
}
@Override
@@ -89,6 +98,10 @@ public Map properties() {
return properties;
}
+ public boolean isMpTelemetryInstalled() {
+ return mpTelemetryInstalled;
+ }
+
/**
* Only add the value to the config if it is non-null, and convert the type to String to
* satisfy library requirements.
diff --git a/observability/opentelemetry/pom.xml b/observability/opentelemetry/pom.xml
index 78c54bdf97ee..9a4222453512 100644
--- a/observability/opentelemetry/pom.xml
+++ b/observability/opentelemetry/pom.xml
@@ -122,6 +122,10 @@
org.wildfly.core
wildfly-server
+
+ org.wildfly.core
+ wildfly-subsystem
+
${ee.maven.groupId}
wildfly-ee
diff --git a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryConfigurationConstants.java b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryConfigurationConstants.java
index 6acc3fb673f8..c111caff0e37 100644
--- a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryConfigurationConstants.java
+++ b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryConfigurationConstants.java
@@ -5,8 +5,19 @@
package org.wildfly.extension.opentelemetry;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
+
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.controller.descriptions.ParentResourceDescriptionResolver;
+import org.jboss.as.controller.descriptions.SubsystemResourceDescriptionResolver;
+
public final class OpenTelemetryConfigurationConstants {
+ public static final String SUBSYSTEM_NAME = "opentelemetry";
+ static final ParentResourceDescriptionResolver SUBSYSTEM_RESOLVER = new SubsystemResourceDescriptionResolver(SUBSYSTEM_NAME, OpenTelemetrySubsystemExtension.class);
+ public static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME);
+ static final String VERTX_DISABLE_DNS_RESOLVER = "vertx.disableDnsResolver";
+
private OpenTelemetryConfigurationConstants() {}
// *****************************************************************************************************************
diff --git a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryDependencyProcessor.java b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryDependencyProcessor.java
index 633407abf9c6..46c387c620a4 100644
--- a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryDependencyProcessor.java
+++ b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryDependencyProcessor.java
@@ -5,8 +5,8 @@
package org.wildfly.extension.opentelemetry;
-import static org.wildfly.extension.opentelemetry.OpenTelemetrySubsystemDefinition.API_MODULE;
-import static org.wildfly.extension.opentelemetry.OpenTelemetrySubsystemDefinition.EXPORTED_MODULES;
+import static org.wildfly.extension.opentelemetry.OpenTelemetrySubsystemRegistrar.API_MODULE;
+import static org.wildfly.extension.opentelemetry.OpenTelemetrySubsystemRegistrar.EXPORTED_MODULES;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.server.deployment.Attachments;
diff --git a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryDeploymentProcessor.java b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryDeploymentProcessor.java
index a0258ad012fe..b09780e6fb53 100644
--- a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryDeploymentProcessor.java
+++ b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryDeploymentProcessor.java
@@ -10,6 +10,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.function.Supplier;
import io.smallrye.opentelemetry.implementation.cdi.OpenTelemetryExtension;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
@@ -25,12 +26,10 @@
import org.wildfly.extension.opentelemetry.api.WildFlyOpenTelemetryConfig;
class OpenTelemetryDeploymentProcessor implements DeploymentUnitProcessor {
- private final boolean useServerConfig;
- private final WildFlyOpenTelemetryConfig serverConfig;
+ private final Supplier openTelemetryConfig;
- public OpenTelemetryDeploymentProcessor(boolean useServerConfig, WildFlyOpenTelemetryConfig serverConfig) {
- this.useServerConfig = useServerConfig;
- this.serverConfig = serverConfig;
+ public OpenTelemetryDeploymentProcessor(Supplier openTelemetryConfig) {
+ this.openTelemetryConfig = openTelemetryConfig;
}
@Override
@@ -46,18 +45,19 @@ public void deploy(DeploymentPhaseContext deploymentPhaseContext) throws Deploym
final WeldCapability weldCapability = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT)
.getCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class);
if (!weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
- // Jakarta RESTful Web Services require Jakarta Contexts and Dependency Injection. Without Jakarta
- // Contexts and Dependency Injection, there's no integration needed
+ // Jakarta RESTful Web Services require Jakarta Contexts and Dependency Injection, without which,
+ // there's no integration needed
OTEL_LOGGER.debug("The deployment does not have Jakarta Contexts and Dependency Injection enabled. Skipping OpenTelemetry integration.");
return;
}
- Map config = new HashMap<>(serverConfig.properties());
+ Map config = new HashMap<>(openTelemetryConfig.get().properties());
if (!config.containsKey(WildFlyOpenTelemetryConfig.OTEL_SERVICE_NAME)) {
config.put(WildFlyOpenTelemetryConfig.OTEL_SERVICE_NAME, getServiceName(deploymentUnit));
}
- weldCapability.registerExtensionInstance(new OpenTelemetryCdiExtension(useServerConfig, config), deploymentUnit);
+ weldCapability.registerExtensionInstance(
+ new OpenTelemetryCdiExtension(!openTelemetryConfig.get().isMpTelemetryInstalled(), config), deploymentUnit);
weldCapability.registerExtensionInstance(new OpenTelemetryExtension(), deploymentUnit);
} catch (CapabilityServiceSupport.NoSuchCapabilityException e) {
// We should not be here since the subsystem depends on weld capability. Just in case ...
diff --git a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryExtensionTransformerRegistration.java b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryExtensionTransformerRegistration.java
index de9eff0dbd1a..949c3e8b0ff1 100644
--- a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryExtensionTransformerRegistration.java
+++ b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetryExtensionTransformerRegistration.java
@@ -14,7 +14,7 @@
public class OpenTelemetryExtensionTransformerRegistration implements ExtensionTransformerRegistration {
@Override
public String getSubsystemName() {
- return OpenTelemetrySubsystemExtension.SUBSYSTEM_NAME;
+ return OpenTelemetryConfigurationConstants.SUBSYSTEM_NAME;
}
@Override
@@ -26,7 +26,7 @@ public void registerTransformers(SubsystemTransformerRegistration registration)
private void registerV_1_1_Transformers(ResourceTransformationDescriptionBuilder builder) {
builder.getAttributeBuilder()
- .setValueConverter(AttributeConverter.DEFAULT_VALUE, OpenTelemetrySubsystemDefinition.EXPORTER)
+ .setValueConverter(AttributeConverter.DEFAULT_VALUE, OpenTelemetrySubsystemRegistrar.EXPORTER)
.end();
}
}
diff --git a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemAdd.java b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemAdd.java
deleted file mode 100644
index 3cbd17de2ae1..000000000000
--- a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemAdd.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright The WildFly Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package org.wildfly.extension.opentelemetry;
-
-import static org.wildfly.extension.opentelemetry.OpenTelemetrySubsystemDefinition.CONFIG_SUPPLIER;
-import static org.wildfly.extension.opentelemetry.OpenTelemetrySubsystemDefinition.validateExporter;
-
-import org.jboss.as.controller.AbstractBoottimeAddStepHandler;
-import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.OperationFailedException;
-import org.jboss.as.server.AbstractDeploymentChainStep;
-import org.jboss.as.server.DeploymentProcessorTarget;
-import org.jboss.as.server.deployment.Phase;
-import org.jboss.dmr.ModelNode;
-import org.wildfly.extension.opentelemetry.api.WildFlyOpenTelemetryConfig;
-
-/**
- * Handler responsible for adding the subsystem resource to the model
- *
- * @author Jason Lee
- */
-class OpenTelemetrySubsystemAdd extends AbstractBoottimeAddStepHandler {
-
- private static final String VERTX_DISABLE_DNS_RESOLVER = "vertx.disableDnsResolver";
-
- OpenTelemetrySubsystemAdd() {
- super(OpenTelemetrySubsystemDefinition.ATTRIBUTES);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
- super.performBoottime(context, operation, model);
-
- String exporter = OpenTelemetrySubsystemDefinition.EXPORTER.resolveModelAttribute(context, model).asString();
- validateExporter(context, exporter);
-
- final WildFlyOpenTelemetryConfig config = new WildFlyOpenTelemetryConfig(
- OpenTelemetrySubsystemDefinition.SERVICE_NAME.resolveModelAttribute(context, model).asStringOrNull(),
- exporter,
- OpenTelemetrySubsystemDefinition.ENDPOINT.resolveModelAttribute(context, model).asStringOrNull(),
- OpenTelemetrySubsystemDefinition.BATCH_DELAY.resolveModelAttribute(context, model).asLongOrNull(),
- OpenTelemetrySubsystemDefinition.MAX_QUEUE_SIZE.resolveModelAttribute(context, model).asLongOrNull(),
- OpenTelemetrySubsystemDefinition.MAX_EXPORT_BATCH_SIZE.resolveModelAttribute(context, model).asLongOrNull(),
- OpenTelemetrySubsystemDefinition.EXPORT_TIMEOUT.resolveModelAttribute(context, model).asLongOrNull(),
- OpenTelemetrySubsystemDefinition.SPAN_PROCESSOR_TYPE.resolveModelAttribute(context, model).asStringOrNull(),
- OpenTelemetrySubsystemDefinition.SAMPLER.resolveModelAttribute(context, model).asStringOrNull(),
- OpenTelemetrySubsystemDefinition.RATIO.resolveModelAttribute(context, model).asDoubleOrNull()
- );
-
- CONFIG_SUPPLIER.accept(config);
-
- boolean mpTelemetryInstalled = context.getCapabilityServiceSupport()
- .hasCapability("org.wildfly.extension.microprofile.telemetry");
-
- context.addStep(new AbstractDeploymentChainStep() {
- @Override
- public void execute(DeploymentProcessorTarget processorTarget) {
- // We need to disable vertx's DNS resolver as it causes failures under k8s
- if (System.getProperty(VERTX_DISABLE_DNS_RESOLVER) == null) {
- System.setProperty(VERTX_DISABLE_DNS_RESOLVER, "true");
- }
- processorTarget.addDeploymentProcessor(
- OpenTelemetrySubsystemExtension.SUBSYSTEM_NAME,
- Phase.DEPENDENCIES,
- 0x1910,
- new OpenTelemetryDependencyProcessor()
- );
- processorTarget.addDeploymentProcessor(
- OpenTelemetrySubsystemExtension.SUBSYSTEM_NAME,
- Phase.POST_MODULE,
- 0x3810,
- new OpenTelemetryDeploymentProcessor(!mpTelemetryInstalled, config));
- }
- }, OperationContext.Stage.RUNTIME);
-
- }
-}
diff --git a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemExtension.java b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemExtension.java
index 467814bab123..021f5ef6e217 100644
--- a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemExtension.java
+++ b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemExtension.java
@@ -5,51 +5,18 @@
package org.wildfly.extension.opentelemetry;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
-
-import java.util.EnumSet;
-import java.util.List;
-
-import org.jboss.as.controller.Extension;
-import org.jboss.as.controller.ExtensionContext;
-import org.jboss.as.controller.PathElement;
-import org.jboss.as.controller.PersistentResourceXMLDescription;
-import org.jboss.as.controller.PersistentResourceXMLDescriptionReader;
-import org.jboss.as.controller.PersistentResourceXMLDescriptionWriter;
-import org.jboss.as.controller.SubsystemRegistration;
-import org.jboss.as.controller.descriptions.ParentResourceDescriptionResolver;
-import org.jboss.as.controller.descriptions.SubsystemResourceDescriptionResolver;
-import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
-import org.jboss.as.controller.parsing.ExtensionParsingContext;
-import org.jboss.as.controller.registry.ManagementResourceRegistration;
-import org.jboss.dmr.ModelNode;
-import org.jboss.staxmapper.XMLElementReader;
+import org.wildfly.subsystem.SubsystemConfiguration;
+import org.wildfly.subsystem.SubsystemExtension;
+import org.wildfly.subsystem.SubsystemPersistence;
/**
* @author Jason Lee
*/
-public class OpenTelemetrySubsystemExtension implements Extension {
- public static final String SUBSYSTEM_NAME = "opentelemetry";
- public static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME);
-
- static final ParentResourceDescriptionResolver SUBSYSTEM_RESOLVER = new SubsystemResourceDescriptionResolver(SUBSYSTEM_NAME, OpenTelemetrySubsystemExtension.class);
-
- private final PersistentResourceXMLDescription currentDescription = OpenTelemetrySubsystemSchema.CURRENT.getXMLDescription();
-
- @Override
- public void initialize(ExtensionContext context) {
- final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, OpenTelemetrySubsystemModel.CURRENT.getVersion());
- subsystem.registerXMLElementWriter(new PersistentResourceXMLDescriptionWriter(this.currentDescription));
-
- final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(new OpenTelemetrySubsystemDefinition());
- registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
- }
-
- @Override
- public void initializeParsers(ExtensionParsingContext context) {
- for (OpenTelemetrySubsystemSchema schema : EnumSet.allOf(OpenTelemetrySubsystemSchema.class)) {
- XMLElementReader> reader = (schema == OpenTelemetrySubsystemSchema.CURRENT) ? new PersistentResourceXMLDescriptionReader(this.currentDescription) : schema;
- context.setSubsystemXmlMapping(SUBSYSTEM_NAME, schema.getNamespace().getUri(), reader);
- }
+public class OpenTelemetrySubsystemExtension extends SubsystemExtension {
+ public OpenTelemetrySubsystemExtension() {
+ super(SubsystemConfiguration.of(OpenTelemetryConfigurationConstants.SUBSYSTEM_NAME,
+ OpenTelemetrySubsystemModel.CURRENT,
+ OpenTelemetrySubsystemRegistrar::new),
+ SubsystemPersistence.of(OpenTelemetrySubsystemSchema.CURRENT));
}
}
diff --git a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemDefinition.java b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemRegistrar.java
similarity index 59%
rename from observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemDefinition.java
rename to observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemRegistrar.java
index 68238f16b63c..24fa7c40250a 100644
--- a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemDefinition.java
+++ b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemRegistrar.java
@@ -17,39 +17,44 @@
import static org.wildfly.extension.opentelemetry.OpenTelemetryConfigurationConstants.GROUP_SPAN_PROCESSOR;
import static org.wildfly.extension.opentelemetry.OpenTelemetryConfigurationConstants.OPENTELEMETRY_CAPABILITY_NAME;
import static org.wildfly.extension.opentelemetry.OpenTelemetryConfigurationConstants.SPAN_PROCESSOR_BATCH;
+import static org.wildfly.extension.opentelemetry.OpenTelemetryConfigurationConstants.SUBSYSTEM_PATH;
+import static org.wildfly.extension.opentelemetry.OpenTelemetryConfigurationConstants.SUBSYSTEM_RESOLVER;
+import static org.wildfly.extension.opentelemetry.OpenTelemetryConfigurationConstants.VERTX_DISABLE_DNS_RESOLVER;
import static org.wildfly.extension.opentelemetry.OpenTelemetryExtensionLogger.OTEL_LOGGER;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.function.Consumer;
-import java.util.function.Supplier;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
-import io.smallrye.opentelemetry.api.OpenTelemetryConfig;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
-import org.jboss.as.controller.OperationStepHandler;
-import org.jboss.as.controller.PathAddress;
-import org.jboss.as.controller.PersistentResourceDefinition;
-import org.jboss.as.controller.ReloadRequiredRemoveStepHandler;
-import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
+import org.jboss.as.controller.ResourceDefinition;
+import org.jboss.as.controller.ResourceRegistration;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
-import org.jboss.as.controller.SimpleResourceDefinition;
+import org.jboss.as.controller.SubsystemRegistration;
import org.jboss.as.controller.capability.RuntimeCapability;
-import org.jboss.as.controller.logging.ControllerLogger;
import org.jboss.as.controller.operations.validation.StringAllowedValuesValidator;
-import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.as.controller.registry.OperationEntry;
+import org.jboss.as.server.deployment.Phase;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
+import org.wildfly.extension.opentelemetry.api.WildFlyOpenTelemetryConfig;
+import org.wildfly.subsystem.resource.ManagementResourceRegistrar;
+import org.wildfly.subsystem.resource.ManagementResourceRegistrationContext;
+import org.wildfly.subsystem.resource.ResourceDescriptor;
+import org.wildfly.subsystem.resource.SubsystemResourceDefinitionRegistrar;
+import org.wildfly.subsystem.resource.operation.ResourceOperationRuntimeHandler;
+import org.wildfly.subsystem.service.ResourceServiceConfigurator;
+import org.wildfly.subsystem.service.ResourceServiceInstaller;
+import org.wildfly.subsystem.service.capability.CapabilityServiceInstaller;
/*
* For future reference: https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#jaeger-exporter
*/
-class OpenTelemetrySubsystemDefinition extends PersistentResourceDefinition {
- static final String OPENTELEMETRY_MODULE = "org.wildfly.extension.opentelemetry";
+class OpenTelemetrySubsystemRegistrar implements SubsystemResourceDefinitionRegistrar, ResourceServiceConfigurator {
public static final String API_MODULE = "org.wildfly.extension.opentelemetry-api";
public static final String[] EXPORTED_MODULES = {
"io.opentelemetry.api",
@@ -64,9 +69,9 @@ class OpenTelemetrySubsystemDefinition extends PersistentResourceDefinition {
.addRequirements(WELD_CAPABILITY_NAME)
.build();
- public static final WildFlyOpenTelemetryConfigSupplier CONFIG_SUPPLIER = new WildFlyOpenTelemetryConfigSupplier();
- static final RuntimeCapability OPENTELEMETRY_CONFIG_CAPABILITY =
- RuntimeCapability.Builder.of(OPENTELEMETRY_MODULE + ".config", false, CONFIG_SUPPLIER).build();
+ public static final RuntimeCapability OPENTELEMETRY_CONFIG_CAPABILITY =
+ RuntimeCapability.Builder.of(WildFlyOpenTelemetryConfig.SERVICE_DESCRIPTOR).build();;
+
public static final SimpleAttributeDefinition SERVICE_NAME = SimpleAttributeDefinitionBuilder
.create(OpenTelemetryConfigurationConstants.SERVICE_NAME, ModelType.STRING, true)
.setAllowExpression(true)
@@ -158,72 +163,82 @@ class OpenTelemetrySubsystemDefinition extends PersistentResourceDefinition {
.setRestartAllServices()
.build();
- public static final AttributeDefinition[] ATTRIBUTES = {
+ public static final List ATTRIBUTES = List.of(
SERVICE_NAME, EXPORTER, ENDPOINT, SPAN_PROCESSOR_TYPE, BATCH_DELAY, MAX_QUEUE_SIZE, MAX_EXPORT_BATCH_SIZE,
EXPORT_TIMEOUT, SAMPLER, RATIO
- };
+ );
- protected OpenTelemetrySubsystemDefinition() {
- super(new SimpleResourceDefinition.Parameters(OpenTelemetrySubsystemExtension.SUBSYSTEM_PATH,
- OpenTelemetrySubsystemExtension.SUBSYSTEM_RESOLVER)
- .setAddHandler(new OpenTelemetrySubsystemAdd())
- .setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE)
- .setCapabilities(OPENTELEMETRY_CAPABILITY, OPENTELEMETRY_CONFIG_CAPABILITY)
- );
- }
+ private final AtomicReference openTelemetryConfig = new AtomicReference<>();
- static void validateExporter(OperationContext context, String exporter) throws OperationFailedException {
-
- if (EXPORTER_JAEGER.equals(exporter)) {
- if (context.isNormalServer()) {
- context.setRollbackOnly();
- throw new OperationFailedException(OTEL_LOGGER.jaegerIsNoLongerSupported());
- } else {
- OTEL_LOGGER.warn(OTEL_LOGGER.jaegerIsNoLongerSupported());
- }
+ static {
+ // We need to disable vertx's DNS resolver as it causes failures under k8s
+ if (System.getProperty(VERTX_DISABLE_DNS_RESOLVER) == null) {
+ System.setProperty(VERTX_DISABLE_DNS_RESOLVER, "true");
}
}
@Override
- public Collection getAttributes() {
- return Arrays.asList(ATTRIBUTES);
+ public ManagementResourceRegistration register(SubsystemRegistration parent,
+ ManagementResourceRegistrationContext context) {
+ ManagementResourceRegistration registration =
+ parent.registerSubsystemModel(ResourceDefinition.builder(ResourceRegistration.of(SUBSYSTEM_PATH),
+ SUBSYSTEM_RESOLVER).build());
+ ResourceDescriptor descriptor = ResourceDescriptor.builder(SUBSYSTEM_RESOLVER)
+ .addCapability(OPENTELEMETRY_CAPABILITY)
+ .addCapability(OPENTELEMETRY_CONFIG_CAPABILITY)
+ .withRuntimeHandler(ResourceOperationRuntimeHandler.configureService(this))
+ .addAttributes(ATTRIBUTES)
+ .withAddOperationRestartFlag(OperationEntry.Flag.RESTART_ALL_SERVICES)
+ .withRemoveOperationRestartFlag(OperationEntry.Flag.RESTART_ALL_SERVICES)
+ .withDeploymentChainContributor(target -> {
+ target.addDeploymentProcessor(OpenTelemetryConfigurationConstants.SUBSYSTEM_NAME,
+ Phase.DEPENDENCIES,
+ 0x18C5, // TODO: Update once WF Core is updated
+ new OpenTelemetryDependencyProcessor());
+ target.addDeploymentProcessor(OpenTelemetryConfigurationConstants.SUBSYSTEM_NAME,
+ Phase.POST_MODULE,
+ 0x3810, // TODO: Update once WF Core is updated
+ new OpenTelemetryDeploymentProcessor(this.openTelemetryConfig::get));
+ })
+ .build();
+
+ ManagementResourceRegistrar.of(descriptor).register(registration);
+
+ return registration;
}
@Override
- public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
- OperationStepHandler handler = new ValidateExporterWriteAttributeHandler();
- for (AttributeDefinition attr : getAttributes()) {
- if(!attr.getFlags().contains(AttributeAccess.Flag.RESTART_ALL_SERVICES)) {
- throw ControllerLogger.ROOT_LOGGER.attributeWasNotMarkedAsReloadRequired(attr.getName(), resourceRegistration.getPathAddress());
- }
- resourceRegistration.registerReadWriteAttribute(attr, null, handler);
- }
- }
-
- static class WildFlyOpenTelemetryConfigSupplier implements Supplier, Consumer {
- private OpenTelemetryConfig config;
- @Override
- public void accept(OpenTelemetryConfig openTelemetryConfig) {
- this.config = openTelemetryConfig;
- }
+ public ResourceServiceInstaller configure(OperationContext context, ModelNode model) throws OperationFailedException {
+ String exporter = OpenTelemetrySubsystemRegistrar.EXPORTER.resolveModelAttribute(context, model).asString();
+ validateExporter(context, exporter);
+
+ final WildFlyOpenTelemetryConfig config = new WildFlyOpenTelemetryConfig(
+ OpenTelemetrySubsystemRegistrar.SERVICE_NAME.resolveModelAttribute(context, model).asStringOrNull(),
+ exporter,
+ OpenTelemetrySubsystemRegistrar.ENDPOINT.resolveModelAttribute(context, model).asStringOrNull(),
+ OpenTelemetrySubsystemRegistrar.BATCH_DELAY.resolveModelAttribute(context, model).asLongOrNull(),
+ OpenTelemetrySubsystemRegistrar.MAX_QUEUE_SIZE.resolveModelAttribute(context, model).asLongOrNull(),
+ OpenTelemetrySubsystemRegistrar.MAX_EXPORT_BATCH_SIZE.resolveModelAttribute(context, model).asLongOrNull(),
+ OpenTelemetrySubsystemRegistrar.EXPORT_TIMEOUT.resolveModelAttribute(context, model).asLongOrNull(),
+ OpenTelemetrySubsystemRegistrar.SPAN_PROCESSOR_TYPE.resolveModelAttribute(context, model).asStringOrNull(),
+ OpenTelemetrySubsystemRegistrar.SAMPLER.resolveModelAttribute(context, model).asStringOrNull(),
+ OpenTelemetrySubsystemRegistrar.RATIO.resolveModelAttribute(context, model).asDoubleOrNull(),
+ context.getCapabilityServiceSupport().hasCapability("org.wildfly.extension.microprofile.telemetry")
+ );
- @Override
- public OpenTelemetryConfig get() {
- return config;
- }
+ return CapabilityServiceInstaller.builder(OPENTELEMETRY_CONFIG_CAPABILITY, config)
+ .withCaptor(openTelemetryConfig::set)
+ .build();
}
- private static class ValidateExporterWriteAttributeHandler extends ReloadRequiredWriteAttributeHandler {
-
- @Override
- protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder voidHandback) throws OperationFailedException {
- AttributeDefinition attributeDefinition = context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName).getAttributeDefinition();
- if (EXPORTER.equals(attributeDefinition)) {
- // Need to validate 'jaeger' isn't used in a non-admin-only server
- validateExporter(context, resolvedValue.asString());
+ private void validateExporter(OperationContext context, String exporter) throws OperationFailedException {
+ if (EXPORTER_JAEGER.equals(exporter)) {
+ if (context.isNormalServer()) {
+ context.setRollbackOnly();
+ throw new OperationFailedException(OTEL_LOGGER.jaegerIsNoLongerSupported());
+ } else {
+ OTEL_LOGGER.warn(OTEL_LOGGER.jaegerIsNoLongerSupported());
}
-
- return super.applyUpdateToRuntime(context, operation, attributeName, resolvedValue, currentValue, voidHandback);
}
}
}
diff --git a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemSchema.java b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemSchema.java
index 9c18431c6dc8..32a28d161c67 100644
--- a/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemSchema.java
+++ b/observability/opentelemetry/src/main/java/org/wildfly/extension/opentelemetry/OpenTelemetrySubsystemSchema.java
@@ -5,7 +5,7 @@
package org.wildfly.extension.opentelemetry;
-import static org.jboss.as.controller.PersistentResourceXMLDescription.builder;
+import static org.jboss.as.controller.PersistentResourceXMLDescription.factory;
import org.jboss.as.controller.PersistentResourceXMLDescription;
import org.jboss.as.controller.PersistentSubsystemSchema;
@@ -22,7 +22,7 @@ public enum OpenTelemetrySubsystemSchema implements PersistentSubsystemSchema namespace;
OpenTelemetrySubsystemSchema(int major, int minor) {
- this.namespace = SubsystemSchema.createSubsystemURN(OpenTelemetrySubsystemExtension.SUBSYSTEM_NAME, new IntVersion(major, minor));
+ this.namespace = SubsystemSchema.createSubsystemURN(OpenTelemetryConfigurationConstants.SUBSYSTEM_NAME, new IntVersion(major, minor));
}
@Override
@@ -32,8 +32,9 @@ public VersionedNamespace getNamespace
@Override
public PersistentResourceXMLDescription getXMLDescription() {
- return builder(OpenTelemetrySubsystemExtension.SUBSYSTEM_PATH, this.namespace)
- .addAttributes(OpenTelemetrySubsystemDefinition.ATTRIBUTES)
+ return factory(this)
+ .builder(OpenTelemetryConfigurationConstants.SUBSYSTEM_PATH)
+ .addAttributes(OpenTelemetrySubsystemRegistrar.ATTRIBUTES.stream())
.build();
}
}
diff --git a/observability/opentelemetry/src/test/java/org/wildfly/extension/opentelemetry/SubsystemParsingTestCase.java b/observability/opentelemetry/src/test/java/org/wildfly/extension/opentelemetry/SubsystemParsingTestCase.java
index 4f1b17d00731..65c9f46fcd26 100644
--- a/observability/opentelemetry/src/test/java/org/wildfly/extension/opentelemetry/SubsystemParsingTestCase.java
+++ b/observability/opentelemetry/src/test/java/org/wildfly/extension/opentelemetry/SubsystemParsingTestCase.java
@@ -36,7 +36,7 @@ public static Iterable parameters() {
}
public SubsystemParsingTestCase(OpenTelemetrySubsystemSchema schema) {
- super(OpenTelemetrySubsystemExtension.SUBSYSTEM_NAME, new OpenTelemetrySubsystemExtension(), schema,
+ super(OpenTelemetryConfigurationConstants.SUBSYSTEM_NAME, new OpenTelemetrySubsystemExtension(), schema,
OpenTelemetrySubsystemSchema.CURRENT);
}
diff --git a/observability/opentelemetry/src/test/java/org/wildfly/extension/opentelemetry/SubsystemTransformersTestCase.java b/observability/opentelemetry/src/test/java/org/wildfly/extension/opentelemetry/SubsystemTransformersTestCase.java
index d96b9f6ee1b0..379176e816e9 100644
--- a/observability/opentelemetry/src/test/java/org/wildfly/extension/opentelemetry/SubsystemTransformersTestCase.java
+++ b/observability/opentelemetry/src/test/java/org/wildfly/extension/opentelemetry/SubsystemTransformersTestCase.java
@@ -25,7 +25,7 @@
public class SubsystemTransformersTestCase extends AbstractSubsystemTest {
public SubsystemTransformersTestCase() {
- super(OpenTelemetrySubsystemExtension.SUBSYSTEM_NAME, new OpenTelemetrySubsystemExtension());
+ super(OpenTelemetryConfigurationConstants.SUBSYSTEM_NAME, new OpenTelemetrySubsystemExtension());
}
@Test
diff --git a/pom.xml b/pom.xml
index 4d8d7ec431df..b183aa37f74a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -374,7 +374,7 @@
18.0.2
3.10.0
0.9.30
- 1.19.8
+ 1.20.0
7.4.0
5.1.0.Beta4
1.6.2
diff --git a/testsuite/integration/microprofile/pom.xml b/testsuite/integration/microprofile/pom.xml
index 457f833c71ed..26f3daad3640 100644
--- a/testsuite/integration/microprofile/pom.xml
+++ b/testsuite/integration/microprofile/pom.xml
@@ -338,7 +338,7 @@
test
- org.wildfly
+ ${full.maven.groupId}
wildfly-opentelemetry-api
test
@@ -396,6 +396,13 @@
wildfly-naming-client
test
+
+
+ org.jboss.arquillian
+ arquillian-testcontainers
+ 1.0.0.Alpha1
+ test
+
@@ -483,6 +490,7 @@
integ-basicmpconfig-test-env-var-value
+ true
${basedir}/target/wildfly
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/faulttolerance/micrometer/FaultToleranceMicrometerIntegrationTestCase.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/faulttolerance/micrometer/FaultToleranceMicrometerIntegrationTestCase.java
index 919509eae1cb..69dafb9de2d2 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/faulttolerance/micrometer/FaultToleranceMicrometerIntegrationTestCase.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/faulttolerance/micrometer/FaultToleranceMicrometerIntegrationTestCase.java
@@ -12,17 +12,17 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import jakarta.inject.Inject;
-
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.search.Search;
+import jakarta.inject.Inject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.arquillian.testcontainers.api.DockerRequired;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.test.integration.common.HttpRequest;
@@ -31,6 +31,7 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
+import org.junit.AssumptionViolatedException;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -47,6 +48,7 @@
*/
@RunWith(Arquillian.class)
@ServerSetup(MicrometerSetupTask.class)
+@DockerRequired(AssumptionViolatedException.class)
public class FaultToleranceMicrometerIntegrationTestCase {
// Let's use a slightly higher number of invocations, so we can at times differentiate between stale read and other problems
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/BaseContainer.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/BaseContainer.java
index 8069aea6f67d..9983e135dd09 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/BaseContainer.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/BaseContainer.java
@@ -7,38 +7,35 @@
import java.time.Duration;
import java.util.List;
+import org.jboss.arquillian.testcontainers.api.DockerRequired;
+import org.junit.AssumptionViolatedException;
import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
-import org.testcontainers.containers.wait.strategy.WaitStrategy;
+import org.testcontainers.containers.Network;
import org.testcontainers.utility.DockerImageName;
+@DockerRequired(AssumptionViolatedException.class)
public abstract class BaseContainer> extends GenericContainer {
private final String containerName;
- private final List exposedPorts;
private static final int STARTUP_ATTEMPTS = Integer.parseInt(
- System.getProperty("testsuite.integration.container.startup.attempts", "1"));
+ System.getProperty("testsuite.integration.container.startup.attempts", "5"));
private static final Duration ATTEMPT_DURATION = Duration.parse(
- System.getProperty("testsuite.integration.container.attempt.duration", "PT5S"));
- protected final Boolean loggingEnabled; // Default: null/false
+ System.getProperty("testsuite.integration.container.attempt.duration", "PT10S"));
+ protected Boolean loggingEnabled; // Default: null/false
public BaseContainer(String containerName,
String imageName,
String imageVersion,
- List exposedPorts,
- List waitStrategies) {
+ List exposedPorts) {
super(DockerImageName.parse(imageName + ":" + imageVersion));
this.containerName = containerName;
- this.exposedPorts = exposedPorts;
- setWaitStrategy(buildWaitStrategy(waitStrategies));
setExposedPorts(exposedPorts);
setStartupAttempts(STARTUP_ATTEMPTS);
+ setNetwork(Network.SHARED);
- loggingEnabled =
- Boolean.parseBoolean(System.getProperty("testsuite.integration.container.logging")) ||
- Boolean.parseBoolean(System.getProperty("testsuite.integration.container." + containerName.toLowerCase() + ".logging"));
+ checkForLogging(containerName);
if (loggingEnabled) {
setLogConsumers(List.of(outputFrame -> {
@@ -50,8 +47,15 @@ public BaseContainer(String containerName,
}
}
+ private void checkForLogging(String containerName) {
+ loggingEnabled =
+ Boolean.parseBoolean(System.getenv().get("TC_LOGGING")) ||
+ Boolean.parseBoolean(System.getProperty("testsuite.integration.container.logging")) ||
+ Boolean.parseBoolean(System.getProperty("testsuite.integration.container." + containerName.toLowerCase() + ".logging"));
+ }
+
protected void debugLog(String message) {
- debugLog(containerName.toUpperCase(), message);
+ debugLog(containerName, message);
}
protected void debugLog(String prefix, String message) {
@@ -59,12 +63,4 @@ protected void debugLog(String prefix, String message) {
System.err.println("[" + prefix + "] " + message);
}
}
-
- private WaitStrategy buildWaitStrategy(List waitStrategies) {
- WaitAllStrategy strategy = new WaitAllStrategy()
- .withStartupTimeout(ATTEMPT_DURATION);
- waitStrategies.forEach(strategy::withStrategy);
-
- return strategy;
- }
}
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/JaegerContainer.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/JaegerContainer.java
index 1cf7111fb965..86d65e72ac40 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/JaegerContainer.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/JaegerContainer.java
@@ -5,14 +5,10 @@
package org.wildfly.test.integration.observability.container;
import java.util.List;
+
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
-import jakarta.ws.rs.client.WebTarget;
-
import org.junit.Assert;
-import org.testcontainers.containers.Network;
-import org.testcontainers.containers.wait.strategy.Wait;
-import org.wildfly.common.annotation.NotNull;
import org.wildfly.test.integration.observability.opentelemetry.jaeger.JaegerResponse;
import org.wildfly.test.integration.observability.opentelemetry.jaeger.JaegerTrace;
@@ -21,61 +17,46 @@
* tracing data should be passing through the otel collector and any methods on its Container.
*/
class JaegerContainer extends BaseContainer {
- private static JaegerContainer INSTANCE = null;
-
+ public static final String IMAGE_NAME = "jaegertracing/all-in-one";
+ public static final String IMAGE_VERSION = "1.53.0";
public static final int PORT_JAEGER_QUERY = 16686;
public static final int PORT_JAEGER_OTLP = 4317;
private String jaegerEndpoint;
- private JaegerContainer() {
- super("Jaeger", "jaegertracing/all-in-one", "latest",
- List.of(PORT_JAEGER_QUERY, PORT_JAEGER_OTLP),
- List.of(Wait.forHttp("/").forPort(PORT_JAEGER_QUERY)));
- }
-
- @NotNull
- public static synchronized JaegerContainer getInstance() {
- if (INSTANCE == null) {
- INSTANCE = new JaegerContainer()
- .withNetwork(Network.SHARED)
- .withNetworkAliases("jaeger")
- .withEnv("JAEGER_DISABLED", "true");
- INSTANCE.start();
- }
-
- return INSTANCE;
+ public JaegerContainer() {
+ super("Jaeger", IMAGE_NAME, IMAGE_VERSION, List.of(PORT_JAEGER_QUERY, PORT_JAEGER_OTLP));
+ withNetworkAliases("jaeger")
+ .withEnv("COLLECTOR_OTLP_ENABLED", "true");
}
@Override
public void start() {
super.start();
jaegerEndpoint = "http://localhost:" + getMappedPort(PORT_JAEGER_QUERY);
- }
-
- @Override
- public synchronized void stop() {
- INSTANCE = null;
- super.stop();
+ debugLog("Query port: " + getMappedPort(PORT_JAEGER_QUERY));
+ debugLog("OTLP port: " + getMappedPort(PORT_JAEGER_OTLP));
+ debugLog("port bindings: " + getPortBindings());
}
List getTraces(String serviceName) throws InterruptedException {
try (Client client = ClientBuilder.newClient()) {
waitForDataToAppear(serviceName);
- String jaegerUrl = jaegerEndpoint + "/api/traces?service=" + serviceName;
- JaegerResponse jaegerResponse = client.target(jaegerUrl).request().get().readEntity(JaegerResponse.class);
- return jaegerResponse.getData();
+ return client.target(jaegerEndpoint + "/api/traces?service=" + serviceName).request()
+ .get()
+ .readEntity(JaegerResponse.class)
+ .getData();
}
}
private void waitForDataToAppear(String serviceName) {
try (Client client = ClientBuilder.newClient()) {
- String uri = jaegerEndpoint + "/api/services";
- WebTarget target = client.target(uri);
boolean found = false;
int count = 0;
- while (count < 10) {
- String response = target.request().get().readEntity(String.class);
+ while (count < 30) {
+ String response = client.target(jaegerEndpoint + "/api/services").request()
+ .get()
+ .readEntity(String.class);
if (response.contains(serviceName)) {
found = true;
break;
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/OpenTelemetryCollectorContainer.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/OpenTelemetryCollectorContainer.java
index c48a200bc5f1..6993e4c0a44b 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/OpenTelemetryCollectorContainer.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/container/OpenTelemetryCollectorContainer.java
@@ -7,58 +7,47 @@
import java.util.Collections;
import java.util.List;
-import org.testcontainers.containers.Network;
-import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.MountableFile;
-import org.wildfly.common.annotation.NotNull;
import org.wildfly.test.integration.observability.opentelemetry.jaeger.JaegerTrace;
public class OpenTelemetryCollectorContainer extends BaseContainer {
- private static OpenTelemetryCollectorContainer INSTANCE = null;
- private static JaegerContainer jaegerContainer;
-
+ public static final String IMAGE_NAME = "otel/opentelemetry-collector";
+ public static final String IMAGE_VERSION = "0.93.0";
public static final int OTLP_GRPC_PORT = 4317;
public static final int OTLP_HTTP_PORT = 4318;
public static final int PROMETHEUS_PORT = 49152;
public static final int HEALTH_CHECK_PORT = 13133;
-
public static final String OTEL_COLLECTOR_CONFIG_YAML = "/etc/otel-collector-config.yaml";
+ private JaegerContainer jaegerContainer;
+
private String otlpGrpcEndpoint;
private String otlpHttpEndpoint;
private String prometheusUrl;
-
- private OpenTelemetryCollectorContainer() {
- super("OpenTelemetryCollector",
- "otel/opentelemetry-collector",
- "0.93.0",
- List.of(OTLP_GRPC_PORT, OTLP_HTTP_PORT, HEALTH_CHECK_PORT, PROMETHEUS_PORT),
- List.of(Wait.forHttp("/").forPort(HEALTH_CHECK_PORT)));
- }
-
- @NotNull
- public static synchronized OpenTelemetryCollectorContainer getInstance() {
- if (INSTANCE == null) {
- jaegerContainer = JaegerContainer.getInstance();
-
- INSTANCE = new OpenTelemetryCollectorContainer()
- .withNetwork(Network.SHARED)
- .withCopyToContainer(MountableFile.forClasspathResource(
- "org/wildfly/test/integration/observability/container/otel-collector-config.yaml"),
- OpenTelemetryCollectorContainer.OTEL_COLLECTOR_CONFIG_YAML)
- .withCommand("--config " + OpenTelemetryCollectorContainer.OTEL_COLLECTOR_CONFIG_YAML);
- INSTANCE.start();
- }
- return INSTANCE;
+ public OpenTelemetryCollectorContainer() {
+ super("OpenTelemetryCollector", IMAGE_NAME, IMAGE_VERSION,
+ List.of(OTLP_GRPC_PORT, OTLP_HTTP_PORT, HEALTH_CHECK_PORT, PROMETHEUS_PORT));
+ withCopyToContainer(
+ MountableFile.forClasspathResource("org/wildfly/test/integration/observability/container/otel-collector-config.yaml"),
+ OpenTelemetryCollectorContainer.OTEL_COLLECTOR_CONFIG_YAML)
+ .withCommand("--config " + OpenTelemetryCollectorContainer.OTEL_COLLECTOR_CONFIG_YAML);
+ jaegerContainer = new JaegerContainer();
}
@Override
public void start() {
super.start();
+ jaegerContainer.start();
+
otlpGrpcEndpoint = "http://localhost:" + getMappedPort(OTLP_GRPC_PORT);
otlpHttpEndpoint = "http://localhost:" + getMappedPort(OTLP_HTTP_PORT);
prometheusUrl = "http://localhost:" + getMappedPort(PROMETHEUS_PORT) + "/metrics";
+
+ debugLog("OTLP gRPC port: " + getMappedPort(OTLP_GRPC_PORT));
+ debugLog("OTLP HTTP port: " + getMappedPort(OTLP_HTTP_PORT));
+ debugLog("Prometheus port: " + getMappedPort(PROMETHEUS_PORT));
+ debugLog("port bindings: " + getPortBindings());
}
@Override
@@ -67,7 +56,6 @@ public synchronized void stop() {
jaegerContainer.stop();
jaegerContainer = null;
}
- INSTANCE = null;
super.stop();
}
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/BasicMicrometerTestCase.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/BasicMicrometerTestCase.java
new file mode 100644
index 000000000000..673eae8adebc
--- /dev/null
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/BasicMicrometerTestCase.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright The WildFly Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.wildfly.test.integration.observability.micrometer;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import jakarta.inject.Inject;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.testcontainers.api.DockerRequired;
+import org.jboss.as.arquillian.api.ServerSetup;
+import org.jboss.as.test.shared.CdiUtils;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.AssumptionViolatedException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.wildfly.test.integration.observability.opentelemetry.application.JaxRsActivator;
+
+
+@RunWith(Arquillian.class)
+@ServerSetup(MicrometerSetupTask.class)
+@DockerRequired(AssumptionViolatedException.class)
+public class BasicMicrometerTestCase {
+ @Inject
+ private MeterRegistry meterRegistry;
+
+ @Deployment
+ public static Archive> deploy() {
+ return ShrinkWrap.create(WebArchive.class, "micrometer-test.war")
+ .addClasses(
+ JaxRsActivator.class,
+ MetricResource.class)
+ .addAsWebInfResource(CdiUtils.createBeansXml(), "beans.xml");
+ }
+
+ @Test
+ public void testInjection() {
+ Assert.assertNotNull(meterRegistry);
+ }
+}
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MetricResource.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MetricResource.java
index bf5b8e9cb0dc..ff9c2c8eba34 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MetricResource.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MetricResource.java
@@ -2,20 +2,18 @@
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
-
package org.wildfly.test.integration.observability.micrometer;
+import io.micrometer.core.instrument.Counter;
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.instrument.Timer;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
-import io.micrometer.core.instrument.Counter;
-import io.micrometer.core.instrument.MeterRegistry;
-import io.micrometer.core.instrument.Tags;
-import io.micrometer.core.instrument.Timer;
-
/**
* @author Jason Lee
*/
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MicrometerOtelIntegrationTestCase.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MicrometerOtelIntegrationTestCase.java
index 5bb3c0501eac..ccbd0dbbafb5 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MicrometerOtelIntegrationTestCase.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MicrometerOtelIntegrationTestCase.java
@@ -10,42 +10,45 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-import jakarta.inject.Inject;
+
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.WebTarget;
-
-import io.micrometer.core.instrument.Counter;
-import io.micrometer.core.instrument.MeterRegistry;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.arquillian.testcontainers.api.DockerRequired;
+import org.jboss.arquillian.testcontainers.api.Testcontainer;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.test.shared.CdiUtils;
+import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.as.test.shared.util.AssumeTestGroupUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
+import org.junit.AssumptionViolatedException;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.test.integration.observability.container.OpenTelemetryCollectorContainer;
+import org.wildfly.test.integration.observability.opentelemetry.application.JaxRsActivator;
@RunWith(Arquillian.class)
@ServerSetup(MicrometerSetupTask.class)
+@DockerRequired(AssumptionViolatedException.class)
+@RunAsClient
public class MicrometerOtelIntegrationTestCase {
- protected static boolean dockerAvailable = AssumeTestGroupUtil.isDockerAvailable();
-
public static final int REQUEST_COUNT = 5;
+
@ArquillianResource
private URL url;
- @Inject
- private MeterRegistry meterRegistry;
+
+ @Testcontainer
+ private OpenTelemetryCollectorContainer otelCollector;
static final String WEB_XML =
"\n"
@@ -61,14 +64,12 @@ public class MicrometerOtelIntegrationTestCase {
@Deployment
public static Archive> deploy() {
- return dockerAvailable ?
- ShrinkWrap.create(WebArchive.class, "micrometer-test.war")
- .addClasses(ServerSetupTask.class,
- MetricResource.class,
- AssumeTestGroupUtil.class)
- .addAsWebInfResource(new StringAsset(WEB_XML), "web.xml")
- .addAsWebInfResource(CdiUtils.createBeansXml(), "beans.xml") :
- AssumeTestGroupUtil.emptyWar();
+ return ShrinkWrap.create(WebArchive.class, "micrometer-test.war")
+ .addClasses(ServerSetupTask.class,
+ JaxRsActivator.class,
+ MetricResource.class,
+ AssumeTestGroupUtil.class)
+ .addAsWebInfResource(CdiUtils.createBeansXml(), "beans.xml");
}
// The @ServerSetup(MicrometerSetupTask.class) requires Docker to be available.
@@ -81,13 +82,6 @@ public static void checkForDocker() {
@Test
@InSequence(1)
- public void testInjection() {
- Assert.assertNotNull(meterRegistry);
- }
-
- @Test
- @RunAsClient
- @InSequence(2)
public void makeRequests() throws URISyntaxException {
try (Client client = ClientBuilder.newClient()) {
WebTarget target = client.target(url.toURI());
@@ -99,9 +93,13 @@ public void makeRequests() throws URISyntaxException {
@Test
@InSequence(3)
- public void checkCounter() {
- Counter counter = meterRegistry.get("demo_counter").counter();
- Assert.assertEquals(counter.count(), REQUEST_COUNT, 0.0);
+ public void checkCounter() throws InterruptedException {
+ Thread.sleep(TimeoutUtil.adjust(1000)); // Allow time for metrics to be pushed
+ String meterName = "demo_counter";
+ Map metrics = getMetricsMap(fetchMetrics(meterName));
+
+ String counter = metrics.get(meterName + "_total{job=\"wildfly\"}");
+ Assert.assertEquals("" + REQUEST_COUNT, counter);
}
// Request the published metrics from the OpenTelemetry Collector via the configured Prometheus exporter and check
@@ -140,17 +138,20 @@ public void testJmxMetrics() throws InterruptedException {
"thread_daemon_count",
"cpu_available_processors"
);
- final String response = fetchMetrics(metricsToTest.get(0));
- Map metrics = Arrays.stream(response.split("\n"))
- .filter(s -> !s.startsWith("#"))
- .map(this::splitMetric)
- .collect(Collectors.toMap(e -> e[0], e -> e[1]));
+ Map metrics = getMetricsMap(fetchMetrics(metricsToTest.get(0)));
metricsToTest.forEach(m -> {
Assert.assertNotEquals("Metric value should be non-zero: " + m,
"0", metrics.get(m + "{job=\"wildfly\"}")); // Add the metrics tags to complete the key
});
}
+ private Map getMetricsMap(String response) {
+ return Arrays.stream(response.split("\n"))
+ .filter(s -> !s.startsWith("#"))
+ .map(this::splitMetric)
+ .collect(Collectors.toMap(e -> e[0], e -> e[1]));
+ }
+
private String[] splitMetric(String entry) {
int index = entry.lastIndexOf(" ");
return new String[]{
@@ -162,7 +163,7 @@ private String[] splitMetric(String entry) {
private String fetchMetrics(String nameToMonitor) throws InterruptedException {
String body = "";
try (Client client = ClientBuilder.newClient()) {
- WebTarget target = client.target(OpenTelemetryCollectorContainer.getInstance().getPrometheusUrl());
+ WebTarget target = client.target(otelCollector.getPrometheusUrl());
int attemptCount = 0;
boolean found = false;
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MicrometerSetupTask.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MicrometerSetupTask.java
index c1c8e2daece5..42affadfdc47 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MicrometerSetupTask.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/MicrometerSetupTask.java
@@ -6,11 +6,13 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STATISTICS_ENABLED;
+import org.jboss.arquillian.testcontainers.api.DockerRequired;
+import org.jboss.arquillian.testcontainers.api.Testcontainer;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.test.shared.ServerReload;
-import org.jboss.as.test.shared.util.AssumeTestGroupUtil;
import org.jboss.dmr.ModelNode;
+import org.junit.AssumptionViolatedException;
import org.wildfly.test.integration.observability.container.OpenTelemetryCollectorContainer;
import org.wildfly.test.integration.observability.setuptask.AbstractSetupTask;
@@ -18,13 +20,12 @@
* Sets up a functioning Micrometer subsystem configuration. Requires functioning Docker environment! Tests using this
* are expected to call AssumeTestGroupUtil.assumeDockerAvailable(); in a @BeforeClass.
*/
+@DockerRequired(AssumptionViolatedException.class)
public class MicrometerSetupTask extends AbstractSetupTask {
- protected boolean dockerAvailable = AssumeTestGroupUtil.isDockerAvailable();
+ private static final ModelNode micrometerExtension = Operations.createAddress("extension", "org.wildfly.extension.micrometer");
+ private static final ModelNode micrometerSubsystem = Operations.createAddress("subsystem", "micrometer");
- private final ModelNode micrometerExtension = Operations.createAddress("extension", "org.wildfly.extension.micrometer");
- private final ModelNode micrometerSubsystem = Operations.createAddress("subsystem", "micrometer");
- private boolean extensionAdded = false;
- private boolean subsystemAdded = false;
+ @Testcontainer
private OpenTelemetryCollectorContainer otelCollector;
@Override
@@ -33,39 +34,28 @@ public void setup(final ManagementClient managementClient, String containerId) t
if (!Operations.isSuccessfulOutcome(executeRead(managementClient, micrometerExtension))) {
executeOp(managementClient, Operations.createAddOperation(micrometerExtension));
- extensionAdded = true;
}
if (!Operations.isSuccessfulOutcome(executeRead(managementClient, micrometerSubsystem))) {
ModelNode addOp = Operations.createAddOperation(micrometerSubsystem);
- addOp.get("endpoint").set("http://localhost:4318/v1/metrics"); // Default endpoint
+ addOp.get("endpoint").set(otelCollector.getOtlpHttpEndpoint() + "/v1/metrics");
executeOp(managementClient, addOp);
- subsystemAdded = true;
}
- if (dockerAvailable) {
- otelCollector = OpenTelemetryCollectorContainer.getInstance();
- executeOp(managementClient, writeAttribute("micrometer", "endpoint",
- otelCollector.getOtlpHttpEndpoint() + "/v1/metrics"));
- executeOp(managementClient, writeAttribute("micrometer", "step", "1"));
- }
+ executeOp(managementClient, writeAttribute("micrometer", "endpoint",
+ otelCollector.getOtlpHttpEndpoint() + "/v1/metrics"));
+ executeOp(managementClient, writeAttribute("micrometer", "step", "1"));
ServerReload.executeReloadAndWaitForCompletion(managementClient);
}
@Override
public void tearDown(final ManagementClient managementClient, String containerId) throws Exception {
- if (dockerAvailable) {
- otelCollector.stop();
- }
+ otelCollector.stop();
executeOp(managementClient, clearAttribute("undertow", STATISTICS_ENABLED));
- if (subsystemAdded) {
- executeOp(managementClient, Operations.createRemoveOperation(micrometerSubsystem));
- }
- if (extensionAdded) {
- executeOp(managementClient, Operations.createRemoveOperation(micrometerExtension));
- }
+ executeOp(managementClient, Operations.createRemoveOperation(micrometerSubsystem));
+ executeOp(managementClient, Operations.createRemoveOperation(micrometerExtension));
ServerReload.reloadIfRequired(managementClient);
}
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/BaseOpenTelemetryTest.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/BaseOpenTelemetryTest.java
index 172e8a6438f4..a3462c927efd 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/BaseOpenTelemetryTest.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/BaseOpenTelemetryTest.java
@@ -8,23 +8,20 @@
import static org.jboss.as.test.shared.PermissionUtils.createPermissionsXmlAsset;
import java.lang.reflect.ReflectPermission;
+import java.net.MalformedURLException;
import java.net.NetPermission;
-import java.net.URL;
import java.util.PropertyPermission;
-import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.as.test.shared.util.AssumeTestGroupUtil;
+import org.jboss.as.test.shared.CdiUtils;
+import org.jboss.as.test.shared.TestSuiteEnvironment;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.BeforeClass;
-import org.wildfly.test.integration.observability.opentelemetry.application.OtelApplication;
+import org.wildfly.test.integration.observability.opentelemetry.application.JaxRsActivator;
import org.wildfly.test.integration.observability.opentelemetry.application.OtelService1;
import org.wildfly.test.integration.observability.opentelemetry.jaeger.JaegerResponse;
public abstract class BaseOpenTelemetryTest {
- protected static boolean dockerAvailable = AssumeTestGroupUtil.isDockerAvailable();
-
private static final String WEB_XML
= "\n"
+ "/*\n"
+ " "
+ "";
- @ArquillianResource
- protected URL url;
static WebArchive buildBaseArchive(String name) {
- return dockerAvailable ?
- ShrinkWrap
- .create(WebArchive.class, name + ".war")
- .addClasses(
- BaseOpenTelemetryTest.class,
- OtelApplication.class,
- OtelService1.class,
- AssumeTestGroupUtil.class
- )
- .addPackage(JaegerResponse.class.getPackage())
- .addAsManifestResource(new StringAsset("otel.sdk.disabled=false"),
- "microprofile-config.properties")
- .addAsWebInfResource(new StringAsset(WEB_XML), "web.xml")
- .addAsWebInfResource(new StringAsset(""), "beans.xml")
- // Some of the classes used in testing do things that break when the Security Manager is installed
- .addAsManifestResource(createPermissionsXmlAsset(
- new RuntimePermission("getClassLoader"),
- new RuntimePermission("getProtectionDomain"),
- new RuntimePermission("getenv.*"),
- new RuntimePermission("setDefaultUncaughtExceptionHandler"),
- new RuntimePermission("modifyThread"),
- new ReflectPermission("suppressAccessChecks"),
- new NetPermission("getProxySelector"),
- new PropertyPermission("*", "read, write")),
- "permissions.xml") :
- AssumeTestGroupUtil.emptyWar(name);
+ return ShrinkWrap
+ .create(WebArchive.class, name + ".war")
+ .addClasses(
+ BaseOpenTelemetryTest.class,
+ JaxRsActivator.class,
+ OtelService1.class
+ )
+ .addPackage(JaegerResponse.class.getPackage())
+ .addAsManifestResource(new StringAsset("otel.sdk.disabled=false"),
+ "microprofile-config.properties")
+ .addAsWebInfResource(new StringAsset(WEB_XML), "web.xml")
+ .addAsWebInfResource(CdiUtils.createBeansXml(), "beans.xml")
+ // Some of the classes used in testing do things that break when the Security Manager is installed
+ .addAsManifestResource(createPermissionsXmlAsset(
+ new RuntimePermission("getClassLoader"),
+ new RuntimePermission("getProtectionDomain"),
+ new RuntimePermission("getenv.*"),
+ new RuntimePermission("setDefaultUncaughtExceptionHandler"),
+ new RuntimePermission("modifyThread"),
+ new ReflectPermission("suppressAccessChecks"),
+ new NetPermission("getProxySelector"),
+ new PropertyPermission("*", "read, write")),
+ "permissions.xml");
}
- @BeforeClass
- public static void checkForDocker() {
- AssumeTestGroupUtil.assumeDockerAvailable();
+ protected String getDeploymentUrl(String deploymentName) throws MalformedURLException {
+ return TestSuiteEnvironment.getHttpUrl() + "/" + deploymentName + "/";
}
}
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/BasicOpenTelemetryTestCase.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/BasicOpenTelemetryTestCase.java
index 93515d4d9005..96372897c676 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/BasicOpenTelemetryTestCase.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/BasicOpenTelemetryTestCase.java
@@ -2,27 +2,28 @@
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
-
package org.wildfly.test.integration.observability.opentelemetry;
-import jakarta.inject.Inject;
-import jakarta.ws.rs.client.Client;
-import jakarta.ws.rs.client.ClientBuilder;
-
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.baggage.Baggage;
import io.opentelemetry.api.trace.Tracer;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.testcontainers.api.DockerRequired;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
+import org.junit.AssumptionViolatedException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.test.integration.observability.setuptask.OpenTelemetrySetupTask;
@RunWith(Arquillian.class)
@ServerSetup(OpenTelemetrySetupTask.class)
+@DockerRequired(AssumptionViolatedException.class)
public class BasicOpenTelemetryTestCase extends BaseOpenTelemetryTest {
@Inject
private Tracer tracer;
@@ -57,8 +58,8 @@ public void baggageInjection() {
public void restClientHasFilterAdded() throws ClassNotFoundException {
try (Client client = ClientBuilder.newClient()) {
Assert.assertTrue(
- client.getConfiguration().isRegistered(
- Class.forName("io.smallrye.opentelemetry.implementation.rest.OpenTelemetryClientFilter"))
+ client.getConfiguration()
+ .isRegistered(Class.forName("io.smallrye.opentelemetry.implementation.rest.OpenTelemetryClientFilter"))
);
}
}
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/ContextPropagationTestCase.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/ContextPropagationTestCase.java
index b9c01ecf4067..b8a7ced1f9f9 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/ContextPropagationTestCase.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/ContextPropagationTestCase.java
@@ -2,26 +2,26 @@
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
-
package org.wildfly.test.integration.observability.opentelemetry;
-import java.net.URI;
+import java.net.MalformedURLException;
import java.util.List;
+
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.core.Response;
-
import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.arquillian.testcontainers.api.DockerRequired;
+import org.jboss.arquillian.testcontainers.api.Testcontainer;
import org.jboss.as.arquillian.api.ServerSetup;
-import org.jboss.as.test.shared.IntermittentFailure;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.AssumptionViolatedException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.test.integration.observability.container.OpenTelemetryCollectorContainer;
@@ -38,17 +38,15 @@
@RunWith(Arquillian.class)
@RunAsClient
@ServerSetup({OpenTelemetrySetupTask.class})
+@DockerRequired(AssumptionViolatedException.class)
public class ContextPropagationTestCase extends BaseOpenTelemetryTest {
-
- @BeforeClass
- public static void disableForWFLY19509() {
- IntermittentFailure.thisTestIsFailingIntermittently("WFLY-19509");
- }
+ @Testcontainer
+ private OpenTelemetryCollectorContainer otelCollector;
@ArquillianResource
private Deployer deployer;
- @Deployment(name = "service1")
+ @Deployment(name = "service1", managed = false)
public static WebArchive getDeployment1() {
return buildBaseArchive("service1");
}
@@ -61,18 +59,19 @@ public static WebArchive getDeployment2() {
@Test
@InSequence(1)
public void deploy() {
+ deployer.deploy("service1");
deployer.deploy("service2");
}
@Test
@InSequence(2)
- public void testContextPropagation() throws InterruptedException {
+ public void testContextPropagation() throws InterruptedException, MalformedURLException {
try (Client client = ClientBuilder.newClient()) {
- Response response = client.target(URI.create(url + "contextProp1")).request().get();
+ Response response = client.target(getDeploymentUrl("service1") + "contextProp1")
+ .request().get();
Assert.assertEquals(204, response.getStatus());
- List traces = OpenTelemetryCollectorContainer.getInstance()
- .getTraces("service1.war");
+ List traces = otelCollector.getTraces("service1.war");
Assert.assertFalse("Traces not found for service", traces.isEmpty());
JaegerTrace trace = traces.get(0);
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/OpenTelemetryIntegrationTestCase.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/OpenTelemetryIntegrationTestCase.java
index 182713cdc390..21387a50d8eb 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/OpenTelemetryIntegrationTestCase.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/OpenTelemetryIntegrationTestCase.java
@@ -2,27 +2,27 @@
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
-
package org.wildfly.test.integration.observability.opentelemetry;
import static org.wildfly.test.integration.observability.setuptask.ServiceNameSetupTask.SERVICE_NAME;
import java.util.List;
+
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.core.Response;
-
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
+import org.jboss.arquillian.testcontainers.api.DockerRequired;
+import org.jboss.arquillian.testcontainers.api.Testcontainer;
import org.jboss.as.arquillian.api.ContainerResource;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
-import org.jboss.as.test.shared.IntermittentFailure;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.AssumptionViolatedException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.test.integration.observability.container.OpenTelemetryCollectorContainer;
@@ -33,19 +33,17 @@
@RunWith(Arquillian.class)
@ServerSetup({OpenTelemetrySetupTask.class})
@RunAsClient
+@DockerRequired(AssumptionViolatedException.class)
public class OpenTelemetryIntegrationTestCase extends BaseOpenTelemetryTest {
-
- @BeforeClass
- public static void disableForWFLY19509() {
- IntermittentFailure.thisTestIsFailingIntermittently("WFLY-19510");
- }
+ @Testcontainer
+ private OpenTelemetryCollectorContainer otelCollector;
@ContainerResource
ManagementClient managementClient;
- @Deployment
+ @Deployment(testable = false)
public static WebArchive getDeployment() {
- return buildBaseArchive(OpenTelemetryIntegrationTestCase.class.getSimpleName());
+ return buildBaseArchive("otelinteg");
}
@Test
@@ -58,12 +56,11 @@ public void setup() throws Exception {
@InSequence(2)
public void testServiceNameOverride() throws Exception {
try (Client client = ClientBuilder.newClient()) {
- Response response = client.target(url.toURI()).request().get();
+ Response response = client.target(getDeploymentUrl("otelinteg")).request().get();
Assert.assertEquals(200, response.getStatus());
}
- List traces = OpenTelemetryCollectorContainer.getInstance()
- .getTraces(SERVICE_NAME);
+ List traces = otelCollector.getTraces(SERVICE_NAME);
Assert.assertFalse("Traces not found for service", traces.isEmpty());
}
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/OtelApplication.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/JaxRsActivator.java
similarity index 64%
rename from testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/OtelApplication.java
rename to testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/JaxRsActivator.java
index f6af60841fb2..eb1190b9b616 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/OtelApplication.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/JaxRsActivator.java
@@ -5,8 +5,10 @@
package org.wildfly.test.integration.observability.opentelemetry.application;
+import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
-public class OtelApplication extends Application {
+@ApplicationPath("/")
+public class JaxRsActivator extends Application {
}
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/OtelService1.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/OtelService1.java
index b4f102df92da..725ed2707628 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/OtelService1.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/OtelService1.java
@@ -6,6 +6,10 @@
import java.net.URI;
import java.net.URISyntaxException;
+
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.context.Scope;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
@@ -18,10 +22,6 @@
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
-import io.opentelemetry.api.trace.Span;
-import io.opentelemetry.api.trace.Tracer;
-import io.opentelemetry.context.Scope;
-
@RequestScoped
@Path("/")
public class OtelService1 {
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/OtelService2.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/OtelService2.java
index 3cfc00e67622..2a29a4282da9 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/OtelService2.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/opentelemetry/application/OtelService2.java
@@ -4,6 +4,9 @@
*/
package org.wildfly.test.integration.observability.opentelemetry.application;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.context.Scope;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
@@ -13,10 +16,6 @@
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.Response;
-import io.opentelemetry.api.trace.Span;
-import io.opentelemetry.api.trace.Tracer;
-import io.opentelemetry.context.Scope;
-
@RequestScoped
@Path("/")
public class OtelService2 {
diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/setuptask/OpenTelemetrySetupTask.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/setuptask/OpenTelemetrySetupTask.java
index 5f0872bd728a..6d15ec438f1a 100644
--- a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/setuptask/OpenTelemetrySetupTask.java
+++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/setuptask/OpenTelemetrySetupTask.java
@@ -4,62 +4,47 @@
*/
package org.wildfly.test.integration.observability.setuptask;
+import org.jboss.arquillian.testcontainers.api.DockerRequired;
+import org.jboss.arquillian.testcontainers.api.Testcontainer;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.test.shared.ServerReload;
-import org.jboss.as.test.shared.util.AssumeTestGroupUtil;
import org.jboss.dmr.ModelNode;
+import org.junit.AssumptionViolatedException;
import org.wildfly.test.integration.observability.container.OpenTelemetryCollectorContainer;
+@DockerRequired(AssumptionViolatedException.class)
public class OpenTelemetrySetupTask extends AbstractSetupTask {
- protected boolean dockerAvailable = AssumeTestGroupUtil.isDockerAvailable();
+ private static final String SUBSYSTEM_NAME = "opentelemetry";
+ private static final ModelNode extensionAddress = Operations.createAddress("extension", "org.wildfly.extension.opentelemetry");
+ private static final ModelNode subsystemAddress = Operations.createAddress("subsystem", SUBSYSTEM_NAME);
- public static OpenTelemetryCollectorContainer otelCollectorContainer;
-
- protected static final String SUBSYSTEM_NAME = "opentelemetry";
- protected final ModelNode extensionAddress = Operations.createAddress("extension", "org.wildfly.extension.opentelemetry");
- protected final ModelNode subsystemAddress = Operations.createAddress("subsystem", SUBSYSTEM_NAME);
-
- private boolean extensionAdded = false;
- private boolean subsystemAdded = false;
+ @Testcontainer
+ private OpenTelemetryCollectorContainer otelCollectorContainer;
@Override
public void setup(final ManagementClient managementClient, final String containerId) throws Exception {
if (!Operations.isSuccessfulOutcome(executeRead(managementClient, extensionAddress))) {
executeOp(managementClient, Operations.createAddOperation(extensionAddress));
- extensionAdded = true;
}
if (!Operations.isSuccessfulOutcome(executeRead(managementClient, subsystemAddress))) {
- ModelNode addOp = Operations.createAddOperation(subsystemAddress);
- executeOp(managementClient, addOp);
- subsystemAdded = true;
+ executeOp(managementClient, Operations.createAddOperation(subsystemAddress));
}
executeOp(managementClient, writeAttribute(SUBSYSTEM_NAME, "batch-delay", "1"));
executeOp(managementClient, writeAttribute(SUBSYSTEM_NAME, "sampler-type", "on"));
- executeOp(managementClient, writeAttribute(SUBSYSTEM_NAME, "max-queue-size", "1"));
-
- if (dockerAvailable) {
- otelCollectorContainer = OpenTelemetryCollectorContainer.getInstance();
- executeOp(managementClient, writeAttribute(SUBSYSTEM_NAME, "endpoint",
- otelCollectorContainer.getOtlpGrpcEndpoint()));
- }
+ executeOp(managementClient, writeAttribute(SUBSYSTEM_NAME, "endpoint", otelCollectorContainer.getOtlpGrpcEndpoint()));
ServerReload.reloadIfRequired(managementClient);
}
@Override
public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception {
- if (dockerAvailable) {
- otelCollectorContainer.stop();
- }
- if (subsystemAdded) {
- executeOp(managementClient, Operations.createRemoveOperation(subsystemAddress));
- }
- if (extensionAdded) {
- executeOp(managementClient, Operations.createRemoveOperation(extensionAddress));
- }
+ otelCollectorContainer.stop();
+
+ executeOp(managementClient, Operations.createRemoveOperation(subsystemAddress));
+ executeOp(managementClient, Operations.createRemoveOperation(extensionAddress));
ServerReload.reloadIfRequired(managementClient);
}
diff --git a/testsuite/integration/microprofile/src/test/resources/org/wildfly/test/integration/observability/container/otel-collector-config.yaml b/testsuite/integration/microprofile/src/test/resources/org/wildfly/test/integration/observability/container/otel-collector-config.yaml
index c65d9e3be9c3..f8cc9784e08f 100644
--- a/testsuite/integration/microprofile/src/test/resources/org/wildfly/test/integration/observability/container/otel-collector-config.yaml
+++ b/testsuite/integration/microprofile/src/test/resources/org/wildfly/test/integration/observability/container/otel-collector-config.yaml
@@ -20,7 +20,7 @@ exporters:
prometheus:
endpoint: "0.0.0.0:49152"
otlp:
- endpoint: http://jaeger:4317
+ endpoint: jaeger:4317
tls:
insecure: true