Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Micrometer metrics library become a de factor instrumentation choice for JVM application. It has been supported by Apache CXF starting from 3.4.1 / 3.3.8 and above for the server-side and 3.4.2 / 3.3.9 and above for the client-side.

Metrics Provider

The Micrometer integration is provided by MicrometerMetricsProvider.

...

PropertyDescriptionDefault
autoTimeRequests

Whether requests handled by CXF should be automatically timed.  If the number of time series emitted grows
too large on account of request mapping timings, set it to "false" and use @Timed or @TimeSet on a per
invocation basis as needed.

true
serverRequestsMetricNameName of the metric for received requests (server-side)cxf.server.requests
clientRequestsMetricNameName of the metric for sent requests (client-side)cxf.client.requests

Integration with JAX-WS

Server

...

Code Block
EndpointImpl endpoint = new EndpointImpl(bus, new HelloPortImpl(), null, null, new WebServiceFeature[]{
    new MetricsFeature(metricsProvider)
});

Client

...

(since 3.3.9 / 3.4.2)

The client integration is no different from the server and uses the same MetricsFeature feature.

Code Block
final MeterRegistry registry = ...; /* Micrometer MeterRegistry  instance */
        
final JaxwsTags jaxwsTags = new JaxwsTags();
final TagsCustomizer operationsCustomizer = new JaxwsOperationTagsCustomizer(jaxwsTags);
final TagsCustomizer faultsCustomizer = new JaxwsFaultCodeTagsCustomizer(jaxwsTags, new JaxwsFaultCodeProvider());
        
final TagsProvider tagsProvider = new StandardTagsProvider(new DefaultExceptionClassProvider(), new StandardTags()); 
final MicrometerMetricsProperties properties = new MicrometerMetricsProperties();
        
final MetricsProvider metricsProvider = new MicrometerMetricsProvider(registry, tagsProvider, 
     Arrays.asList(operationsCustomizer, faultsCustomizer), new DefaultTimedAnnotationProvider(), properties);

final JaxWsClientFactoryBean factory = new JaxWsClientFactoryBean();
factory.setFeatures(Arrays.asList(new MetricsFeature(new MicrometerMetricsProvider(metricsProvider))));
...

Integration with JAX-RS

Server

...

Code Block
final MeterRegistry registry = ...; /* Micrometer MeterRegistry  instance */
        
final JaxrsTags jaxrsTags = new JaxrsTags();
final TagsCustomizer operationsCustomizer = new JaxrsOperationTagsCustomizer(jaxrsTags);
        
final TagsProvider tagsProvider = new StandardTagsProvider(new DefaultExceptionClassProvider(), new StandardTags()); 
final MicrometerMetricsProperties properties = new MicrometerMetricsProperties();
        
final MetricsProvider metricsProvider = new MicrometerMetricsProvider(registry, tagsProvider, 
     Arrays.asList(operationsCustomizer), new DefaultTimedAnnotationProvider(), properties);

final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
factory.setFeatures(Arrays.asList(new MetricsFeature(metricsProvider)));
...

Client

...

(since 3.3.9 / 3.4.2)

The client integration is no different from the server and uses the same MetricsFeature feature.

Code Block
final MeterRegistry registry = ...; /* Micrometer MeterRegistry  instance */
        
final JaxrsTags jaxrsTags = new JaxrsTags();
final TagsCustomizer operationsCustomizer = new JaxrsOperationTagsCustomizer(jaxrsTags);
        
final TagsProvider tagsProvider = new StandardTagsProvider(new DefaultExceptionClassProvider(), new StandardTags()); 
final MicrometerMetricsProperties properties = new MicrometerMetricsProperties();
        
final MetricsProvider metricsProvider = new MicrometerMetricsProvider(registry, tagsProvider, 
     Arrays.asList(operationsCustomizer), new DefaultTimedAnnotationProvider(), properties);

final JAXRSClientFactoryBean factory = new JAXRSClientFactoryBean();
factory.setFeatures(Arrays.asList(new MetricsFeature(metricsProvider)));
...

...