Skip to content

Commit

Permalink
Fix Fault Tolerance multiple metrics provider test
Browse files Browse the repository at this point in the history
Split OTel related configuration APIs to OpenTelemetryServerCOnfiguration
  • Loading branch information
fabiobrz authored and jbliznak committed Dec 16, 2024
1 parent aa2a418 commit 22655bc
Show file tree
Hide file tree
Showing 7 changed files with 259 additions and 213 deletions.
1 change: 1 addition & 0 deletions microprofile-fault-tolerance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
<layers>
<layer>cloud-server</layer>
<layer>microprofile-fault-tolerance</layer>
<layer>micrometer</layer>
</layers>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jboss.eap.qe.microprofile.common.setuptasks.MicroProfileFaultToleranceServerConfiguration;
import org.jboss.eap.qe.microprofile.common.setuptasks.MicroProfileTelemetryServerConfiguration;
import org.jboss.eap.qe.microprofile.common.setuptasks.MicrometerServerConfiguration;
import org.jboss.eap.qe.microprofile.common.setuptasks.OpenTelemetryServerConfiguration;
import org.jboss.eap.qe.microprofile.fault.tolerance.deployments.v10.HelloService;
import org.jboss.eap.qe.microprofile.tooling.server.configuration.creaper.ManagementClientProvider;
import org.jboss.eap.qe.microprofile.tooling.server.configuration.deployment.ConfigurationUtil;
Expand Down Expand Up @@ -142,8 +143,8 @@ public void testFaultToleranceMetricsAreTracedWithSameDeployments(
otelCollector.start();
try {
// Enable MP Telemetry based metrics, which rely on OpenTelemetry subsystem
MicroProfileTelemetryServerConfiguration.enableOpenTelemetry();
MicroProfileTelemetryServerConfiguration
OpenTelemetryServerConfiguration.enableOpenTelemetry();
OpenTelemetryServerConfiguration
.addOpenTelemetryCollectorConfiguration(otelCollector.getOtlpGrpcEndpoint());
MicroProfileTelemetryServerConfiguration.enableMicroProfileTelemetry();
try {
Expand Down Expand Up @@ -213,7 +214,7 @@ public void testFaultToleranceMetricsAreTracedWithSameDeployments(
} finally {
// disable MP Telemetry based metrics
MicroProfileTelemetryServerConfiguration.disableMicroProfileTelemetry();
MicroProfileTelemetryServerConfiguration.disableOpenTelemetry();
OpenTelemetryServerConfiguration.disableOpenTelemetry();
}
} finally {
// stop the OTel collector container
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.eap.qe.microprofile.common.setuptasks.MicroProfileTelemetryServerConfiguration;
import org.jboss.eap.qe.microprofile.common.setuptasks.MicrometerServerConfiguration;
import org.jboss.eap.qe.microprofile.common.setuptasks.OpenTelemetryServerConfiguration;
import org.jboss.eap.qe.observability.containers.OpenTelemetryCollectorContainer;
import org.jboss.eap.qe.ts.common.docker.Docker;

Expand Down Expand Up @@ -31,8 +32,8 @@ public void setup(ManagementClient managementClient, String containerId) throws
otelCollector = OpenTelemetryCollectorContainer.getInstance();
otelCollector.start();
// Enable MP Telemetry based metrics, which rely on OpenTelemetry subsystem
MicroProfileTelemetryServerConfiguration.enableOpenTelemetry();
MicroProfileTelemetryServerConfiguration.addOpenTelemetryCollectorConfiguration(otelCollector.getOtlpGrpcEndpoint());
OpenTelemetryServerConfiguration.enableOpenTelemetry();
OpenTelemetryServerConfiguration.addOpenTelemetryCollectorConfiguration(otelCollector.getOtlpGrpcEndpoint());
MicroProfileTelemetryServerConfiguration.enableMicroProfileTelemetry();
}

Expand All @@ -43,7 +44,7 @@ public void setup(ManagementClient managementClient, String containerId) throws
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
// disable MP Telemetry based metrics
MicroProfileTelemetryServerConfiguration.disableMicroProfileTelemetry();
MicroProfileTelemetryServerConfiguration.disableOpenTelemetry();
OpenTelemetryServerConfiguration.disableOpenTelemetry();
// stop the OTel collector container
otelCollector.stop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static synchronized OpenTelemetryCollectorContainer getInstance() {
* Static method to get a unique instance of {@link OpenTelemetryCollectorContainer}.
*
* @param jaegerBackendContainer A {@link JaegerContainer} instance that will be used as the Jaeger backend, e.g.:
* for storing and retrieving traces.
* for storing and retrieving traces.
* @return A unique instance of {@link OpenTelemetryCollectorContainer}
*/
public static synchronized OpenTelemetryCollectorContainer getInstance(JaegerContainer jaegerBackendContainer) {
Expand All @@ -150,7 +150,7 @@ public static synchronized OpenTelemetryCollectorContainer getNewInstance() {
* external code.
*
* @param jaegerBackendContainer A {@link JaegerContainer} instance that will be used as the Jaeger backend, e.g.:
* for storing and retrieving traces.
* for storing and retrieving traces.
* @return An instance of {@link OpenTelemetryCollectorContainer}
*/
public static synchronized OpenTelemetryCollectorContainer getNewInstance(JaegerContainer jaegerBackendContainer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,14 @@
import org.wildfly.extras.creaper.core.online.operations.admin.Administration;

/**
* Operations required to set up the server for MicroProfile Telemetry
* Operations required to set up and configure the {@code microprofile-telemetry} extension
*/
public class MicroProfileTelemetryServerConfiguration {
private static final Address OPENTELEMETRY_EXTENSION_ADDRESS = Address
.extension("org.wildfly.extension.opentelemetry");
private static final Address OPENTELEMETRY_SUBSYSTEM_ADDRESS = Address
.subsystem("opentelemetry");

private static final Address MICROPROFILE_TELEMETRY_EXTENSION_ADDRESS = Address
.extension("org.wildfly.extension.microprofile.telemetry");
private static final Address MICROPROFILE_TELEMETRY_SUBSYSTEM_ADDRESS = Address
.subsystem("microprofile-telemetry");

/**
* Checks whether <b>"org.wildfly.extension.opentelemetry"</b> extension is present
*
* @return True if extension is already present,false otherwise
* @throws Exception exception thrown by the internal operation executed by {@link Operations} API
*/
public static Boolean openTelemetryExtensionExists(Operations operations) throws Exception {
return operations.exists(OPENTELEMETRY_EXTENSION_ADDRESS);
}

/**
* Checks whether <b>"opentelemetry"</b> subsystem is present
*
* @return True if extension is already present,false otherwise
* @throws Exception exception thrown by the internal operation executed by {@link Operations} API
*/
public static Boolean openTelemetrySubsystemExists(Operations operations) throws Exception {
return operations.exists(OPENTELEMETRY_SUBSYSTEM_ADDRESS);
}

/**
* Checks whether <b>"org.wildfly.extension.microprofile.telemetry"</b> extension is present
*
Expand All @@ -60,91 +35,6 @@ public static Boolean microProfileTelemetrySubsystemExists(Operations operations
return operations.exists(MICROPROFILE_TELEMETRY_SUBSYSTEM_ADDRESS);
}

/**
* Enable OpenTelemetry extension and subsystem.
*
* @throws Exception exception thrown by the internal operation executed by {@link OnlineManagementClient} API
*/
public static void enableOpenTelemetry() throws Exception {
try (OnlineManagementClient client = ManagementClientProvider.onlineStandalone()) {
enableOpenTelemetry(client);
}
}

/**
* Set a default, working OpenTelemetry subsystem configuration, e.g.: to set the OTLP receiver URL.
*/
public static void addOpenTelemetryCollectorConfiguration(final String otlpCollectorEndpointUrl) throws Exception {
try (OnlineManagementClient client = ManagementClientProvider.onlineStandalone()) {
addOpenTelemetryCollectorConfiguration(otlpCollectorEndpointUrl, client);
}
}

/**
* Set a default, working OpenTelemetry subsystem configuration, e.g.: to set the OTLP receiver URL.
*
* @param client {@link OnlineManagementClient} instance used to execute the command
*/
public static void addOpenTelemetryCollectorConfiguration(final String otlpCollectorEndpointUrl,
OnlineManagementClient client) throws Exception {
Operations operations = new Operations(client);
if (!openTelemetrySubsystemExists(operations)) {
throw new IllegalStateException("OpenTelemetry subsystem not found");
}
operations.writeAttribute(OPENTELEMETRY_SUBSYSTEM_ADDRESS, "exporter-type", "otlp");
operations.writeAttribute(OPENTELEMETRY_SUBSYSTEM_ADDRESS, "sampler-type", "on");
operations.writeAttribute(OPENTELEMETRY_SUBSYSTEM_ADDRESS, "max-export-batch-size", "512");
operations.writeAttribute(OPENTELEMETRY_SUBSYSTEM_ADDRESS, "batch-delay", "1");
operations.writeAttribute(OPENTELEMETRY_SUBSYSTEM_ADDRESS, "max-queue-size", "1");
operations.writeAttribute(OPENTELEMETRY_SUBSYSTEM_ADDRESS, "endpoint", otlpCollectorEndpointUrl);
new Administration(client).reloadIfRequired();
}

/**
* Enable OpenTelemetry extension and subsystem.
*
* @param client {@link OnlineManagementClient} instance used to execute the command
* @throws Exception exception thrown by the internal operation executed by {@link OnlineManagementClient} API
*/
public static void enableOpenTelemetry(OnlineManagementClient client) throws Exception {
Operations operations = new Operations(client);
if (!openTelemetryExtensionExists(operations)) {
operations.add(OPENTELEMETRY_EXTENSION_ADDRESS);
}
if (!openTelemetrySubsystemExists(operations)) {
operations.add(OPENTELEMETRY_SUBSYSTEM_ADDRESS);
}
new Administration(client).reloadIfRequired();
}

/**
* Disable OpenTelemetry subsystem and extension
*
* @throws Exception exception thrown by the internal operation executed by {@link OnlineManagementClient} API
*/
public static void disableOpenTelemetry() throws Exception {
try (OnlineManagementClient client = ManagementClientProvider.onlineStandalone()) {
disableOpenTelemetry(client);
}
}

/**
* Disable OpenTelemetry subsystem and extension
*
* @param client {@link OnlineManagementClient} instance used to execute the command
* @throws Exception exception thrown by the internal operation executed by {@link OnlineManagementClient} API
*/
public static void disableOpenTelemetry(OnlineManagementClient client) throws Exception {
Operations operations = new Operations(client);
if (openTelemetrySubsystemExists(operations)) {
operations.remove(OPENTELEMETRY_SUBSYSTEM_ADDRESS);
}
if (openTelemetryExtensionExists(operations)) {
operations.remove(OPENTELEMETRY_EXTENSION_ADDRESS);
}
new Administration(client).reloadIfRequired();
}

/**
* Enable MicroProfile Telemetry extension and subsystem.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package org.jboss.eap.qe.microprofile.common.setuptasks;

import org.jboss.eap.qe.microprofile.tooling.server.configuration.creaper.ManagementClientProvider;
import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
import org.wildfly.extras.creaper.core.online.operations.Address;
import org.wildfly.extras.creaper.core.online.operations.Operations;
import org.wildfly.extras.creaper.core.online.operations.admin.Administration;

/**
* Operations required to set up and configure the {@code opentelemetry} subsystem
*/
public class OpenTelemetryServerConfiguration {
private static final Address OPENTELEMETRY_EXTENSION_ADDRESS = Address
.extension("org.wildfly.extension.opentelemetry");
private static final Address OPENTELEMETRY_SUBSYSTEM_ADDRESS = Address
.subsystem("opentelemetry");

/**
* Checks whether <b>"org.wildfly.extension.opentelemetry"</b> extension is present
*
* @return True if extension is already present,false otherwise
* @throws Exception exception thrown by the internal operation executed by {@link Operations} API
*/
public static Boolean openTelemetryExtensionExists(Operations operations) throws Exception {
return operations.exists(OPENTELEMETRY_EXTENSION_ADDRESS);
}

/**
* Checks whether <b>"opentelemetry"</b> subsystem is present
*
* @return True if extension is already present,false otherwise
* @throws Exception exception thrown by the internal operation executed by {@link Operations} API
*/
public static Boolean openTelemetrySubsystemExists(Operations operations) throws Exception {
return operations.exists(OPENTELEMETRY_SUBSYSTEM_ADDRESS);
}

/**
* Enable OpenTelemetry extension and subsystem.
*
* @throws Exception exception thrown by the internal operation executed by {@link OnlineManagementClient} API
*/
public static void enableOpenTelemetry() throws Exception {
try (OnlineManagementClient client = ManagementClientProvider.onlineStandalone()) {
enableOpenTelemetry(client);
}
}

/**
* Set a default, working OpenTelemetry subsystem configuration, e.g.: to set the OTLP receiver URL.
*/
public static void addOpenTelemetryCollectorConfiguration(final String otlpCollectorEndpointUrl) throws Exception {
try (OnlineManagementClient client = ManagementClientProvider.onlineStandalone()) {
addOpenTelemetryCollectorConfiguration(otlpCollectorEndpointUrl, client);
}
}

/**
* Set a default, working OpenTelemetry subsystem configuration, e.g.: to set the OTLP receiver URL.
*
* @param client {@link OnlineManagementClient} instance used to execute the command
*/
public static void addOpenTelemetryCollectorConfiguration(final String otlpCollectorEndpointUrl,
OnlineManagementClient client) throws Exception {
Operations operations = new Operations(client);
if (!openTelemetrySubsystemExists(operations)) {
throw new IllegalStateException("OpenTelemetry subsystem not found");
}
operations.writeAttribute(OPENTELEMETRY_SUBSYSTEM_ADDRESS, "exporter-type", "otlp");
operations.writeAttribute(OPENTELEMETRY_SUBSYSTEM_ADDRESS, "sampler-type", "on");
operations.writeAttribute(OPENTELEMETRY_SUBSYSTEM_ADDRESS, "max-export-batch-size", "512");
operations.writeAttribute(OPENTELEMETRY_SUBSYSTEM_ADDRESS, "max-queue-size", "1");
operations.writeAttribute(OPENTELEMETRY_SUBSYSTEM_ADDRESS, "endpoint", otlpCollectorEndpointUrl);
new Administration(client).reloadIfRequired();
}

/**
* Enable OpenTelemetry extension and subsystem.
*
* @param client {@link OnlineManagementClient} instance used to execute the command
* @throws Exception exception thrown by the internal operation executed by {@link OnlineManagementClient} API
*/
public static void enableOpenTelemetry(OnlineManagementClient client) throws Exception {
Operations operations = new Operations(client);
if (!openTelemetryExtensionExists(operations)) {
operations.add(OPENTELEMETRY_EXTENSION_ADDRESS);
}
if (!openTelemetrySubsystemExists(operations)) {
operations.add(OPENTELEMETRY_SUBSYSTEM_ADDRESS);
}
new Administration(client).reloadIfRequired();
}

/**
* Disable OpenTelemetry subsystem and extension
*
* @throws Exception exception thrown by the internal operation executed by {@link OnlineManagementClient} API
*/
public static void disableOpenTelemetry() throws Exception {
try (OnlineManagementClient client = ManagementClientProvider.onlineStandalone()) {
disableOpenTelemetry(client);
}
}

/**
* Disable OpenTelemetry subsystem and extension
*
* @param client {@link OnlineManagementClient} instance used to execute the command
* @throws Exception exception thrown by the internal operation executed by {@link OnlineManagementClient} API
*/
public static void disableOpenTelemetry(OnlineManagementClient client) throws Exception {
Operations operations = new Operations(client);
if (openTelemetrySubsystemExists(operations)) {
operations.remove(OPENTELEMETRY_SUBSYSTEM_ADDRESS);
}
if (openTelemetryExtensionExists(operations)) {
operations.remove(OPENTELEMETRY_EXTENSION_ADDRESS);
}
new Administration(client).reloadIfRequired();
}
}

0 comments on commit 22655bc

Please sign in to comment.