-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFLY-19846] Update multideployment MP Metrics tests for MP Telemetry…
… metrics
- Loading branch information
1 parent
8263a3e
commit 61c9dd6
Showing
7 changed files
with
192 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 20 additions & 3 deletions
23
...etrics/src/main/java/org/jboss/eap/qe/microprofile/metrics/namefellow/PingOneService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
package org.jboss.eap.qe.microprofile.metrics.namefellow; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
|
||
import org.eclipse.microprofile.metrics.annotation.Counted; | ||
import io.opentelemetry.api.common.AttributeKey; | ||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.metrics.LongCounter; | ||
import io.opentelemetry.api.metrics.Meter; | ||
|
||
@ApplicationScoped | ||
public class PingOneService { | ||
public static final String MESSAGE = "pong one"; | ||
public static final String PING_ONE_SERVICE_TAG = "ping-one-service-tag"; | ||
|
||
@Counted(name = "ping-count", absolute = true, displayName = "Pong Count", description = "Number of ping invocations", tags = "_app=" | ||
+ PING_ONE_SERVICE_TAG) | ||
@Inject | ||
private Meter meter; | ||
private LongCounter longCounter; | ||
|
||
@PostConstruct | ||
public void init() { | ||
longCounter = meter | ||
.counterBuilder("ping_count") | ||
.setDescription("Number of ping invocations") | ||
.build(); | ||
} | ||
|
||
public String ping() { | ||
longCounter.add(1, Attributes.of( | ||
AttributeKey.stringKey("_app"), PING_ONE_SERVICE_TAG)); | ||
return MESSAGE; | ||
} | ||
} |
23 changes: 20 additions & 3 deletions
23
...etrics/src/main/java/org/jboss/eap/qe/microprofile/metrics/namefellow/PingTwoService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
package org.jboss.eap.qe.microprofile.metrics.namefellow; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
|
||
import org.eclipse.microprofile.metrics.annotation.Counted; | ||
import io.opentelemetry.api.common.AttributeKey; | ||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.metrics.LongCounter; | ||
import io.opentelemetry.api.metrics.Meter; | ||
|
||
@ApplicationScoped | ||
public class PingTwoService { | ||
public static final String MESSAGE = "pong two"; | ||
public static final String PING_TWO_SERVICE_TAG = "ping-two-service-tag"; | ||
|
||
@Counted(name = "ping-count", absolute = true, displayName = "Pong Count", description = "Number of ping invocations", tags = "_app=" | ||
+ PING_TWO_SERVICE_TAG) | ||
@Inject | ||
private Meter meter; | ||
private LongCounter longCounter; | ||
|
||
@PostConstruct | ||
public void init() { | ||
longCounter = meter | ||
.counterBuilder("ping_count") | ||
.setDescription("Number of ping invocations") | ||
.build(); | ||
} | ||
|
||
public String ping() { | ||
longCounter.add(1, Attributes.of( | ||
AttributeKey.stringKey("_app"), PING_TWO_SERVICE_TAG)); | ||
return MESSAGE; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...trics/src/test/java/org/jboss/eap/qe/microprofile/metrics/MPTelemetryServerSetupTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.jboss.eap.qe.microprofile.metrics; | ||
|
||
import org.jboss.as.arquillian.api.ServerSetupTask; | ||
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.observability.containers.OpenTelemetryCollectorContainer; | ||
import org.jboss.eap.qe.ts.common.docker.Docker; | ||
|
||
/** | ||
* Server setup task for configuration of MicroProfile Telemetry and otel collector | ||
*/ | ||
public class MPTelemetryServerSetupTask implements ServerSetupTask { | ||
|
||
private static OpenTelemetryCollectorContainer otelCollector; | ||
|
||
/** | ||
* Start otel collector in container and configure OpenTelemetry and MP Telemetry in application server | ||
*/ | ||
@Override | ||
public void setup(ManagementClient managementClient, String containerId) throws Exception { | ||
// we need a Docker container for The OTel collector here, so throw an exception if a docker service is not available | ||
try { | ||
Docker.checkDockerPresent(); | ||
} catch (Exception e) { | ||
throw new IllegalStateException("Cannot verify Docker availability: " + e.getMessage()); | ||
} | ||
// disable micrometer | ||
MicrometerServerConfiguration.disableMicrometer(); | ||
// start the OTel collector container | ||
otelCollector = OpenTelemetryCollectorContainer.getInstance(); | ||
otelCollector.start(); | ||
// Enable MP Telemetry based metrics, which rely on OpenTelemetry subsystem | ||
MicroProfileTelemetryServerConfiguration.enableOpenTelemetry(); | ||
MicroProfileTelemetryServerConfiguration.addOpenTelemetryCollectorConfiguration(otelCollector.getOtlpGrpcEndpoint()); | ||
MicroProfileTelemetryServerConfiguration.enableMicroProfileTelemetry(); | ||
} | ||
|
||
/** | ||
* Stop otel collector in container and disable OpenTelemetry and MP Telemetry in application server | ||
*/ | ||
@Override | ||
public void tearDown(ManagementClient managementClient, String containerId) throws Exception { | ||
// disable MP Telemetry based metrics | ||
MicroProfileTelemetryServerConfiguration.disableMicroProfileTelemetry(); | ||
MicroProfileTelemetryServerConfiguration.disableOpenTelemetry(); | ||
// stop the OTel collector container | ||
otelCollector.stop(); | ||
} | ||
} |
Oops, something went wrong.