Metrics Feature

Stable • Since 0.14.0

Collect metrics using Micrometer.

Unlike CXF Metrics feature, this Quarkus CXF extension does not support Dropwizard Metrics. Only Micrometer is supported.

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 Quarkus CXF.

Usage

The integration of CXF into the Quarkus Micrometer ecosystem is implemented using io.quarkiverse.cxf.metrics.QuarkusCxfMetricsFeature. As long as your application depends on quarkus-cxf-rt-features-metrics, an instance of QuarkusCxfMetricsFeature is created internally and enabled by default for all clients and service endpoints created by Quarkus CXF. You can disable it via quarkus.cxf.metrics.enabled-for, quarkus.cxf.client."client-name".metrics.enabled and quarkus.cxf.endpoint."/endpoint-path".metrics.enabled properties documented below.

Runnable example

There is an integration test covering Micrometer Metrics in the Quarkus CXF source tree.

Unsurprisingly, it depends on quarkus-cxf-rt-features-metrics

pom.xml
<dependency>
    <groupId>io.quarkiverse.cxf</groupId>
    <artifactId>quarkus-cxf-rt-features-metrics</artifactId>
</dependency>

It is using quarkus-micrometer-registry-prometheus extension to export the metrics in JSON format and for Prometheus:

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

The following configuration is needed to be able to inspect the collected metrics over a REST endpoint:

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

Having all the above in place, you can start the application in Dev mode:

$ mvn quarkus:dev

Now send a request to the HelloService:

$ curl \
  -d '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:helloResponse xmlns:ns2="http://it.server.metrics.cxf.quarkiverse.io/"><return>Hello Joe!</return></ns2:helloResponse></soap:Body></soap:Envelope>' \
  -H 'Content-Type: text/xml' \
  -X POST \
  http://localhost:8080/metrics/client/hello

After that, you should see some metrics under cxf.server.requests in the output of the endpoint 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
    },
    ...
}

Configuration

Configuration property fixed at build time. All other configuration properties are overridable at runtime.

Configuration property Type Default

quarkus.cxf.metrics.enabled-for

clients, services, both, none

both

Specifies whether the metrics collection will be enabled for clients, services, both or none. This global setting can be overridden per client or service endpoint using the quarkus.cxf.client."client-name".metrics.enabled or quarkus.cxf.endpoint."/endpoint-path".metrics.enabled option respectively.

Environment variable: QUARKUS_CXF_METRICS_ENABLED_FOR
Since Quarkus CXF: 2.7.0

quarkus.cxf.metrics.tags-customizers

List of string

A list of references to org.apache.cxf.metrics.micrometer.provider.TagsCustomizer beans that will be attached to the global metrics feature.

Environment variable: QUARKUS_CXF_METRICS_TAGS_CUSTOMIZERS
Since Quarkus CXF: 3.15.0

quarkus.cxf.client."client-name".metrics.enabled

boolean

true

If true and if quarkus.cxf.metrics.enabled-for is set to both or clients then the MetricsFeature will be added to this client; otherwise the feature will not be added to this client.

Environment variable: QUARKUS_CXF_CLIENT__CLIENT_NAME__METRICS_ENABLED
Since Quarkus CXF: 2.7.0

quarkus.cxf.endpoint."/endpoint-path".metrics.enabled

boolean

true

If true and if quarkus.cxf.metrics.enabled-for is set to both or services then the MetricsFeature will be added to this service endpoint; otherwise the feature will not be added to this service endpoint.

Environment variable: QUARKUS_CXF_ENDPOINT___ENDPOINT_PATH__METRICS_ENABLED
Since Quarkus CXF: 2.7.0