Skip to content

Commit

Permalink
Merge pull request wildfly#18103 from jasondlee/WFLY-19583
Browse files Browse the repository at this point in the history
[WFLY-19583] Deployment-related undertow metrics are not exported
  • Loading branch information
bstansberry authored Aug 7, 2024
2 parents d5bec13 + ff127c4 commit 80beb54
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentCompleteServiceProcessor;
import org.jboss.as.server.deployment.DeploymentModelUtils;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
Expand Down Expand Up @@ -48,7 +49,9 @@ public void deploy(DeploymentPhaseContext deploymentPhaseContext) throws Deploym
createDeploymentAddressPrefix(deploymentUnit)::append,
this.config.getSubsystemFilter());
ServiceInstaller.builder(factory)
.requires(ServiceDependency.on(DeploymentCompleteServiceProcessor.serviceName(deploymentUnit.getServiceName())))
.requires(collector)
.asActive()
.onStop(MetricRegistration::unregister)
.build()
.install(deploymentPhaseContext);
Expand All @@ -73,7 +76,6 @@ private void registerCdiExtension(DeploymentPhaseContext deploymentPhaseContext)
try {
CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);


final WeldCapability weldCapability = support.getCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class);
if (!weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
MICROMETER_LOGGER.noCdiDeployment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
@RunAsClient
public class MicrometerOtelIntegrationTestCase {
public static final int REQUEST_COUNT = 5;
public static final String DEPLOYMENT_NAME = "micrometer-test.war";

@ArquillianResource
private URL url;
Expand All @@ -52,7 +53,7 @@ public class MicrometerOtelIntegrationTestCase {

@Deployment
public static Archive<?> deploy() {
return ShrinkWrap.create(WebArchive.class, "micrometer-test.war")
return ShrinkWrap.create(WebArchive.class, DEPLOYMENT_NAME)
.addClasses(JaxRsActivator.class, MetricResource.class)
.addAsWebInfResource(CdiUtils.createBeansXml(), "beans.xml");
}
Expand Down Expand Up @@ -96,6 +97,26 @@ public void getMetrics() throws InterruptedException {
final List<PrometheusMetric> metrics = otelCollector.fetchMetrics(metricsToTest.get(0));
metricsToTest.forEach(n -> Assert.assertTrue("Missing metric: " + n,
metrics.stream().anyMatch(m -> m.getKey().startsWith(n))));

Map<String, PrometheusMetric> appMetrics =
metrics.stream().filter(m -> m.getTags().entrySet().stream()
.anyMatch(t -> "app".equals(t.getKey()) && DEPLOYMENT_NAME.equals(t.getValue()))
)
.collect(Collectors.toMap(PrometheusMetric::getKey, i -> i));

List.of(
"undertow_active_sessions",
"undertow_expired_sessions_total",
"undertow_highest_session_count",
"undertow_max_active_sessions",
"undertow_max_request_time_seconds",
"undertow_min_request_time_seconds",
"undertow_rejected_sessions_total",
"undertow_request_time_seconds_total",
"undertow_session_avg_alive_time_seconds",
"undertow_session_max_alive_time_seconds",
"undertow_sessions_created_total"
).forEach(appMetrics::containsKey);
}

@Test
Expand Down

0 comments on commit 80beb54

Please sign in to comment.