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
<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:
<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:
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//soap/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
},
...
}
Client metrics
While still having the metrics integration test from the previous section up and running in dev mode, you can check the client metrics as well:
-
Send some requests to the REST endpoint wrapping the CXF client:
$ curl \ -d 'Joe' \ -H 'Content-Type: text/plain' \ -X POST \ http://localhost:8080/metrics/client/hello
-
Check the metrics under the key
cxf.client.requests
in the output of the endpoint you configured above:$ curl http://localhost:8080/q/metrics/json metrics: { ... "cxf.client.requests": { "count;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=http://localhost:8080/soap/hello": 1, "elapsedTime;exception=None;faultCode=None;method=POST;operation=hello;outcome=SUCCESS;status=200;uri=http://localhost:8080/soap/hello": 29.0 }, ... }
Vert.x HttpClient metrics
Since Quarkus CXF 3.25.0, the metrics of the underlying Vert.x HttpClient are exposed as well.
This works only if your SOAP clients using the default Vert.x HttpClient based
HTTPConduitFactory
.
While still having the metrics integration test from the previous section up and running, you can check those metrics as follows:
-
Send some requests to the REST endpoint wrapping the CXF client:
$ curl \ -d 'Joe' \ -H 'Content-Type: text/plain' \ -X POST \ http://localhost:8080/metrics/client/hello
-
Check the metrics under the keys starting with
http.client.
in the output of the endpoint you configured above:$ curl http://localhost:8080/q/metrics/json metrics: { ... "http.client.requests": { "count;address=localhost:8080;clientName=hello;method=GET;outcome=SUCCESS;status=200;uri=/soap/hello?wsdl": 1, "elapsedTime;address=localhost:8080;clientName=hello;method=GET;outcome=SUCCESS;status=200;uri=/soap/hello?wsdl": 7.0, "count;address=localhost:8080;clientName=hello;method=POST;outcome=SUCCESS;status=200;uri=/soap/hello": 1, "elapsedTime;address=localhost:8080;clientName=hello;method=POST;outcome=SUCCESS;status=200;uri=/soap/hello": 26.0 }, "http.client.connections": { "activeTasks;clientName=hello": 0, "duration;clientName=hello": 0.0, "max;clientName=hello": 0.0, "mean;clientName=hello": 0.0 }, "http.client.bytes.read": { "min;clientName=hello": 232.0, "count;clientName=hello": 2, "max;clientName=hello": 2317.0, "mean;clientName=hello": 1274.5, "p50;clientName=hello": 232.0, "p75;clientName=hello": 2317.875, "p95;clientName=hello": 2317.875, "p98;clientName=hello": 2317.875, "p99;clientName=hello": 2317.875, "p999;clientName=hello": 2317.875 }, "http.client.bytes.written": { "min;clientName=hello": 205.0, "count;clientName=hello": 1, "max;clientName=hello": 205.0, "mean;clientName=hello": 205.0, "p50;clientName=hello": 205.0, "p75;clientName=hello": 205.0, "p95;clientName=hello": 205.0, "p98;clientName=hello": 205.0, "p99;clientName=hello": 205.0, "p999;clientName=hello": 205.0 }, ... }
The number of connections opened by Vert.x HttpClient at any given time is capped by
-
quarkus.cxf.client."client-name".vertx.connection-pool.http1-max-size
for HTTP/1.x connections -
quarkus.cxf.client."client-name".vertx.connection-pool.http2-max-size
for HTTP/2 connections.
-
Configuration
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
Configuration property | Type | Default |
---|---|---|
|
|
|
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 Environment variable: |
||
List of |
||
A list of references to
Environment variable: |
||
|
|
|
If Environment variable: |
||
|
|
|
If Environment variable: |