Metrics Feature

Stable • Since 0.14.0

Collect metrics using Micrometer.

Dropwizard Metrics are unsupported. They do not work in native mode and the are no tests for JVM mode.

Maven coordinates

Create a new project using quarkus-cxf-rt-features-metrics on code.quarkus.io or add these coordinates to your existing project:

<dependency>
    <groupId>io.quarkiverse.cxf</groupId>
    <artifactId>quarkus-cxf-rt-features-metrics</artifactId>
</dependency>
Check the User guide and especially its Dependency management section for more information about writing applications with CXF Extensions for Quarkus.

Usage

The integration of CXF into Quarkus Micrometer ecosystem is implemented using CXF MicrometerMetricsProvider and io.quarkiverse.cxf.metrics.QuarkusCxfMetricsFeature.

The sample code snippets used in this section come from the metrics integration test in the source tree of CXF Extensions for Quarkus

To enable metrics collection for services, just add io.quarkiverse.cxf.metrics.QuarkusCxfMetricsFeature to your service’s features:

application.properties
quarkus.cxf.path = /soap
quarkus.cxf.endpoint."/hello".implementor = io.quarkiverse.cxf.metrics.server.it.HelloServiceImpl
quarkus.cxf.endpoint."/hello".features = io.quarkiverse.cxf.metrics.QuarkusCxfMetricsFeature

The same can be done for a client:

application.properties
quarkus.cxf.client.hello.wsdl = http://localhost:${quarkus.http.test-port}/soap/hello?wsdl
quarkus.cxf.client.hello.client-endpoint-url = http://localhost:${quarkus.http.test-port}/soap/hello
quarkus.cxf.client.hello.service-interface = io.quarkiverse.cxf.metrics.server.it.HelloService
quarkus.cxf.client.hello.features = io.quarkiverse.cxf.metrics.QuarkusCxfMetricsFeature

Finally, to export the metrics in json format and for Prometheus, add the following dependency to your project

pom.xml
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>

and set the following properties

application.properties
quarkus.micrometer.export.json.enabled = true
quarkus.micrometer.export.json.path = metrics/json
quarkus.micrometer.export.prometheus.path = metrics/prometheus

After that, you should be able to see some metrics under cxf.server.requests and/or cxf.client.requests in the output of the endpoints you configured above:

$ curl http://localhost:8080/q/metrics/json
metrics: {
    ...
    "cxf.server.requests": {
        "count;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=/soap/hello": 2,
        "elapsedTime;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=/soap/hello": 64.0
    },
    ...
    "cxf.client.requests": {
        "count;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=http://localhost:808 /soap/hello": 1,
        "elapsedTime;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=http://localhost:8081/soap/hello": 34.0
    },
    ...
}

Configuration

The metrics feature can be associated with a SOAP client or service using the following configuration properties: