Skip to content

Commit

Permalink
Fix Fault Tolerance multiple metrics provider test
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiobrz committed Dec 5, 2024
1 parent 622d336 commit c833a81
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 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 @@ -108,7 +108,8 @@ public static Archive<?> deploymentWithMPTelemetryEnabled() {
*/
@Deployment(name = FAULT_TOLERANCE_DEPOYMENT_WITH_MP_TELEMETRY_DISABLING_MICROMETER, managed = false)
public static Archive<?> deploymentWithMPTelemetryEnabledDisablingMicrometer() {
String mpConfig = "otel.metric.export.interval=100\notel.service.name=" + FAULT_TOLERANCE_DEPOYMENT_WITH_MP_TELEMETRY_DISABLING_MICROMETER
String mpConfig = "otel.metric.export.interval=100\notel.service.name="
+ FAULT_TOLERANCE_DEPOYMENT_WITH_MP_TELEMETRY_DISABLING_MICROMETER
+ "\notel.sdk.disabled=false\nTimeout/enabled=true\nsmallrye.faulttolerance.micrometer.disabled=true";
return ShrinkWrap.create(WebArchive.class, FAULT_TOLERANCE_DEPOYMENT_WITH_MP_TELEMETRY_DISABLING_MICROMETER + ".war")
.addPackages(true, HelloService.class.getPackage())
Expand All @@ -124,7 +125,9 @@ public static Archive<?> deploymentWithMPTelemetryEnabledDisablingMicrometer() {
*/
@Test
@InSequence(0)
public void deployAll() {
public void deployAll() throws Exception {
MicroProfileTelemetryServerConfiguration.disableOpenTelemetry();
MicrometerServerConfiguration.disableMicrometer();
deployer.deploy(FAULT_TOLERANCE_DEPLOYMENT);
deployer.deploy(FAULT_TOLERANCE_DEPOYMENT_WITH_MP_TELEMETRY);
deployer.deploy(FAULT_TOLERANCE_DEPOYMENT_WITH_MP_TELEMETRY_DISABLING_MICROMETER);
Expand Down Expand Up @@ -243,12 +246,14 @@ public void noMetricsAreCollectedWhenOnlyMPTelemetryIsAvailableButNotEnabled(
@ArquillianResource @OperateOnDeployment(FAULT_TOLERANCE_DEPLOYMENT) URL deploymentUrl) throws Exception {
// Remove the Micrometer extension...
MicrometerServerConfiguration.disableMicrometer();
// ... but make the MicroProfile Telemetry extension available
MicroProfileTelemetryServerConfiguration.enableMicroProfileTelemetry();
// ... start the OTel collector container...
OpenTelemetryCollectorContainer otelCollector = OpenTelemetryCollectorContainer.getNewInstance();
otelCollector.start();
try {
// start the OTel collector container
OpenTelemetryCollectorContainer otelCollector = OpenTelemetryCollectorContainer.getNewInstance();
otelCollector.start();
// ... and make the MicroProfile Telemetry extension available
MicroProfileTelemetryServerConfiguration.enableMicroProfileTelemetry();
MicroProfileTelemetryServerConfiguration
.addOpenTelemetryCollectorConfiguration(otelCollector.getOtlpGrpcEndpoint());
try {
// deploy an app that DOES NOT enable MP Telemetry
deployer.deploy(FAULT_TOLERANCE_DEPLOYMENT);
Expand All @@ -273,10 +278,10 @@ public void noMetricsAreCollectedWhenOnlyMPTelemetryIsAvailableButNotEnabled(
deployer.undeploy(FAULT_TOLERANCE_DEPLOYMENT);
}
} finally {
otelCollector.stop();
MicroProfileTelemetryServerConfiguration.disableMicroProfileTelemetry();
}
} finally {
MicroProfileTelemetryServerConfiguration.disableMicroProfileTelemetry();
otelCollector.stop();
}
}

Expand All @@ -294,12 +299,14 @@ public void metricsAreCollectedWhenOnlyMPTelemetryExtensionIsAvailableAndEnabled
throws Exception {
// Remove the Micrometer extension
MicrometerServerConfiguration.disableMicrometer();
// Make the MP Telemetry extension available
MicroProfileTelemetryServerConfiguration.enableMicroProfileTelemetry();
// start the OTel collector container
OpenTelemetryCollectorContainer otelCollector = OpenTelemetryCollectorContainer.getNewInstance();
otelCollector.start();
try {
// start the OTel collector container
OpenTelemetryCollectorContainer otelCollector = OpenTelemetryCollectorContainer.getNewInstance();
otelCollector.start();
// Make the MP Telemetry extension available
MicroProfileTelemetryServerConfiguration.enableMicroProfileTelemetry();
MicroProfileTelemetryServerConfiguration
.addOpenTelemetryCollectorConfiguration(otelCollector.getOtlpGrpcEndpoint());
try {
// deploy an app that enables MP Telemetry
deployer.deploy(FAULT_TOLERANCE_DEPOYMENT_WITH_MP_TELEMETRY);
Expand All @@ -325,10 +332,10 @@ public void metricsAreCollectedWhenOnlyMPTelemetryExtensionIsAvailableAndEnabled
deployer.undeploy(FAULT_TOLERANCE_DEPOYMENT_WITH_MP_TELEMETRY);
}
} finally {
otelCollector.stop();
MicroProfileTelemetryServerConfiguration.disableMicroProfileTelemetry();
}
} finally {
MicroProfileTelemetryServerConfiguration.disableMicroProfileTelemetry();
otelCollector.stop();
}
}

Expand All @@ -346,13 +353,15 @@ public void metricsAreCollectedWhenOnlyMPTelemetryExtensionIsAvailableAndEnabled
public void metricsAreCollectedWhenBothExtensionsAreAvailableAndOnlyMPTelIsEnabled(
@ArquillianResource @OperateOnDeployment(FAULT_TOLERANCE_DEPOYMENT_WITH_MP_TELEMETRY_DISABLING_MICROMETER) URL deploymentUrl)
throws Exception {
// Make the MP Telemetry extension available
MicroProfileTelemetryServerConfiguration.enableMicroProfileTelemetry();
// start the OTel collector container
OpenTelemetryCollectorContainer otelCollector = OpenTelemetryCollectorContainer.getNewInstance();
otelCollector.start();
try {
// start the OTel collector container
OpenTelemetryCollectorContainer otelCollector = OpenTelemetryCollectorContainer.getNewInstance();
otelCollector.start();
// Make the MP Telemetry extension available
MicroProfileTelemetryServerConfiguration.enableMicroProfileTelemetry();
try {
MicroProfileTelemetryServerConfiguration
.addOpenTelemetryCollectorConfiguration(otelCollector.getOtlpGrpcEndpoint());
// And be sure Micrometer is available too
MicrometerServerConfiguration.enableMicrometer(otelCollector.getOtlpHttpEndpoint());
try {
Expand Down Expand Up @@ -387,10 +396,10 @@ public void metricsAreCollectedWhenBothExtensionsAreAvailableAndOnlyMPTelIsEnabl
MicrometerServerConfiguration.disableMicrometer();
}
} finally {
otelCollector.stop();
MicroProfileTelemetryServerConfiguration.disableMicroProfileTelemetry();
}
} finally {
MicroProfileTelemetryServerConfiguration.disableMicroProfileTelemetry();
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

0 comments on commit c833a81

Please sign in to comment.