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/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 |
---|---|---|
|
|
|
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: |
||
|
|
|
If Environment variable: |
||
|
|
|
If Environment variable: |