Skip to content

Commit

Permalink
Merge pull request #11830 from jmesnil/WFLY-10712_microprofile_metric…
Browse files Browse the repository at this point in the history
…s-smallrye

[WFLY-10712] Observability: MicroProfile Metrics
  • Loading branch information
kabir committed Nov 13, 2018
2 parents b7c16ae + 5b91260 commit bada8cb
Show file tree
Hide file tree
Showing 46 changed files with 2,056 additions and 6 deletions.
Expand Up @@ -22,6 +22,8 @@

package org.wildfly.extension.batch.jberet.deployment;

import static org.jboss.as.server.deployment.Attachments.DEPLOYMENT_COMPLETE_SERVICES;

import javax.enterprise.inject.spi.BeanManager;

import org.jberet.repository.JobRepository;
Expand Down Expand Up @@ -158,7 +160,8 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
serviceBuilder.install();

// Install the JobOperatorService
Services.addServerExecutorDependency(serviceTarget.addService(BatchServiceNames.jobOperatorServiceName(deploymentUnit), jobOperatorService)
ServiceName jobOperatorServiceName = BatchServiceNames.jobOperatorServiceName(deploymentUnit);
Services.addServerExecutorDependency(serviceTarget.addService(jobOperatorServiceName, jobOperatorService)
.addDependency(support.getCapabilityServiceName(Capabilities.BATCH_CONFIGURATION_CAPABILITY.getName()), BatchConfiguration.class, jobOperatorService.getBatchConfigurationInjector())
.addDependency(SuspendController.SERVICE_NAME, SuspendController.class, jobOperatorService.getSuspendControllerInjector())
.addDependency(BatchServiceNames.batchEnvironmentServiceName(deploymentUnit), SecurityAwareBatchEnvironment.class, jobOperatorService.getBatchEnvironmentInjector()),
Expand All @@ -167,6 +170,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU

// Add the JobOperatorService to the deployment unit
deploymentUnit.putAttachment(BatchAttachments.JOB_OPERATOR, jobOperatorService);
deploymentUnit.addToAttachmentList(DEPLOYMENT_COMPLETE_SERVICES, jobOperatorServiceName);

// Add the JobOperator to the context selector
selector.registerContext(moduleClassLoader, JobOperatorContext.create(jobOperatorService));
Expand Down
Expand Up @@ -40,6 +40,8 @@ include::subsystem-configuration/MicroProfile_Config_SmallRye.adoc[]

include::subsystem-configuration/MicroProfile_Health.adoc[]

include::subsystem-configuration/MicroProfile_Metric.adoc[]

include::subsystem-configuration/MicroProfile_OpenTracing_SmallRye.adoc[]

include::subsystem-configuration/Security.adoc[]
Expand Down
@@ -0,0 +1,85 @@
[[MicroProfile_Metrics_SmallRye]]
= MicroProfile Metrics Subsystem Configuration

Support for https://microprofile.io/project/eclipse/microprofile-metrics[Eclipse MicroProfile Metrics] is provided by
the _microprofile-metrics-smallrye_ subsystem.

[[required-extension]]
== Required Extension

This extension is included in all the standalone configurations included in the
WildFly distribution.

You can also add the extension to a configuration without it either by adding
an `<extension module="org.wildfly.extension.microprofile.metrics-smallrye"/>`
element to the xml or by using the following CLI operation:

[source,ruby]
----
[standalone@localhost:9990 /]/extension=org.wildfly.extension.microprofile.metrics-smallrye:add
----

== Management Model

The `/subsystem=microprofile-metrics-smallrye` resource defines two attributes:

* `security-enabled` - a boolean to indicate whether authentication is required to access the HTTP metrics endpoint (described below). By default, it is `true`. The
standalone configurations explicitly sets it to `false` to accept unauthenticated access to the HTTP endpoints.
* `exposed-subsystems` - a list of strings corresponding to the names of subsystems that exposes their metrics in the HTTP metrics endpoints.
By default, it is not defined (there will be no metrics exposed by subsystem. The special wildcard `*` can be used to expose metrics from _all_ subsystems. The standalone
configuration sets this attribute to `*`.

== HTTP Endpoint

The Metric HTTP endpoint is accessible on WildFly HTTP management interface http://localhost:9990/metrics[http://localhost:9990/metrics].

Secured access to the HTTP endpoint is controlled by the `security-enabled` attribute of the `/subsystem=microprofile-metrics-smallrye` resource.
If it is set to `true`, the HTTP client must be authenticated.

If the application server is healthy, it will return a `200 OK` response:

----
$ curl -v http://localhost:9990/metrics
< HTTP/1.1 200 OK
...
# HELP base:classloader_total_loaded_class_count Displays the total number of classes that have been loaded since the Java virtual machine has started execution
.
# TYPE base:classloader_total_loaded_class_count counter
base:classloader_total_loaded_class_count 10822.0
...
----

If security has been enabled, the HTTP client must pass the credentials corresponding to a management user
created by the `add-user` script. For example:

----
$ curl -v --digest -u myadminuser:myadminpassword http://localhost:9990/metrics
< HTTP/1.1 200 OK
...
# HELP base:classloader_total_loaded_class_count Displays the total number of classes that have been loaded since the Java virtual machine has started execution
.
# TYPE base:classloader_total_loaded_class_count counter
base:classloader_total_loaded_class_count 10822.0
...
----

If the authentication fails, the server will reply with a `401 NOT AUTHORIZED` response.

== Exposed Metrics

The HTTP endpoint exposes the following metrics:

* Base metrics - Required metrics specified in the MicroProfile 1.1 specification are exposed in the `base` scope.
* Vendor metrics - Metrics from WildFly subsystems are exposed in the `vendor` scope
* Application metrics - Metrics from the application and from the deployment's subsystems are exposed in the `application` scope.

== Component Reference

The Eclipse MicroProfile Health is implemented by the SmallRye Health project.

****
* https://microprofile.io/project/eclipse/microprofile-metrics[Eclipse MicroProfile Metrics]
* http://github.com/smallrye/smallrye-metrics/[SmallRye Metrics]
****
33 changes: 33 additions & 0 deletions feature-pack/pom.xml
Expand Up @@ -2925,6 +2925,39 @@
</exclusions>
</dependency>

<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-metrics</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>wildfly-microprofile-metrics-smallrye</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>wildfly-mod_cluster-extension</artifactId>
Expand Down
Expand Up @@ -28,6 +28,7 @@
<subsystem>messaging-activemq-colocated.xml</subsystem>
<subsystem>microprofile-config-smallrye.xml</subsystem>
<subsystem>microprofile-health-smallrye.xml</subsystem>
<subsystem>microprofile-metrics-smallrye.xml</subsystem>
<subsystem>microprofile-opentracing-smallrye.xml</subsystem>
<subsystem>naming.xml</subsystem>
<subsystem>pojo.xml</subsystem>
Expand Down
Expand Up @@ -26,6 +26,7 @@
<subsystem>mail.xml</subsystem>
<subsystem>microprofile-config-smallrye.xml</subsystem>
<subsystem>microprofile-health-smallrye.xml</subsystem>
<subsystem>microprofile-metrics-smallrye.xml</subsystem>
<subsystem>microprofile-opentracing-smallrye.xml</subsystem>
<subsystem>naming.xml</subsystem>
<subsystem>pojo.xml</subsystem>
Expand Down
Expand Up @@ -25,6 +25,7 @@
<subsystem>mail.xml</subsystem>
<subsystem>microprofile-config-smallrye.xml</subsystem>
<subsystem>microprofile-health-smallrye.xml</subsystem>
<subsystem>microprofile-metrics-smallrye.xml</subsystem>
<subsystem>microprofile-opentracing-smallrye.xml</subsystem>
<subsystem>naming.xml</subsystem>
<subsystem>pojo.xml</subsystem>
Expand Down
Expand Up @@ -26,6 +26,7 @@
<subsystem>messaging-activemq.xml</subsystem>
<subsystem>microprofile-config-smallrye.xml</subsystem>
<subsystem>microprofile-health-smallrye.xml</subsystem>
<subsystem>microprofile-metrics-smallrye.xml</subsystem>
<subsystem>microprofile-opentracing-smallrye.xml</subsystem>
<subsystem>naming.xml</subsystem>
<subsystem>picketlink-federation.xml</subsystem>
Expand Down
Expand Up @@ -27,6 +27,7 @@
<subsystem>messaging-activemq.xml</subsystem>
<subsystem>microprofile-config-smallrye.xml</subsystem>
<subsystem>microprofile-health-smallrye.xml</subsystem>
<subsystem>microprofile-metrics-smallrye.xml</subsystem>
<subsystem>microprofile-opentracing-smallrye.xml</subsystem>
<subsystem>naming.xml</subsystem>
<subsystem>pojo.xml</subsystem>
Expand Down
Expand Up @@ -26,6 +26,7 @@
<subsystem>messaging-activemq.xml</subsystem>
<subsystem>microprofile-config-smallrye.xml</subsystem>
<subsystem>microprofile-health-smallrye.xml</subsystem>
<subsystem>microprofile-metrics-smallrye.xml</subsystem>
<subsystem>microprofile-opentracing-smallrye.xml</subsystem>
<subsystem>naming.xml</subsystem>
<subsystem>pojo.xml</subsystem>
Expand Down
Expand Up @@ -24,6 +24,7 @@
<subsystem>mail.xml</subsystem>
<subsystem>microprofile-config-smallrye.xml</subsystem>
<subsystem>microprofile-health-smallrye.xml</subsystem>
<subsystem>microprofile-metrics-smallrye.xml</subsystem>
<subsystem>microprofile-opentracing-smallrye.xml</subsystem>
<subsystem>naming.xml</subsystem>
<subsystem>pojo.xml</subsystem>
Expand Down
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2018, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<module xmlns="urn:jboss:module:1.8" name="io.smallrye.metrics">
<properties>
<property name="jboss.api" value="private"/>
</properties>

<resources>
<artifact name="${io.smallrye:smallrye-metrics}"/>
</resources>

<dependencies>
<module name="javax.api"/>
<module name="org.eclipse.microprofile.config.api" />
<module name="org.eclipse.microprofile.metrics.api" />
<module name="org.jboss.logging" />
<module name="javax.enterprise.api" />
<module name="javax.annotation.api" />
<module name="javax.json.api" />
<module name="org.jboss.weld.core" />
<module name="org.jboss.weld.spi" />
</dependencies>
</module>
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2018, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<module xmlns="urn:jboss:module:1.8" name="org.eclipse.microprofile.metrics.api">
<resources>
<artifact name="${org.eclipse.microprofile.metrics:microprofile-metrics-api}"/>
</resources>

<dependencies>
<module name="javax.enterprise.api" />
<module name="org.eclipse.microprofile.config.api" />
<module name="org.jboss.weld.core" />
<module name="org.jboss.weld.spi" />
</dependencies>
</module>
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2018, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<module xmlns="urn:jboss:module:1.8" name="org.wildfly.extension.microprofile.metrics-smallrye">
<properties>
<property name="jboss.api" value="private"/>
</properties>

<resources>
<artifact name="${org.wildfly:wildfly-microprofile-metrics-smallrye}"/>
</resources>

<dependencies>
<module name="io.smallrye.metrics" export="true"/>
<module name="io.undertow.core"/>
<module name="javax.api"/>
<module name="org.eclipse.microprofile.metrics.api" />
<module name="org.jboss.staxmapper"/>
<module name="org.jboss.as.controller"/>
<module name="org.jboss.as.core-security"/>
<module name="org.jboss.as.server"/>
<module name="org.jboss.modules"/>
<module name="org.jboss.msc"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.vfs"/>
<module name="org.wildfly.extension.microprofile.config-smallrye" />
<module name="javax.enterprise.api" />
<module name="javax.annotation.api" />
</dependencies>
</module>

0 comments on commit bada8cb

Please sign in to comment.