Versions Compared

Key

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

Table of Contents

Introduction

The Dropwizard Metrics library is a widely used metrics instrumentation choice for JVM application. The 3.x release line of Dropwizard Metrics has been supported by Apache CXF starting from 3.1.0and above, and the 4.x has become the default one since Apache CXF 3.4.0.

Metrics Provider

The Dropwizard Metrics integration is provided by CodahaleMetricsProvider.

Integration with JAX-WS

Server

The typical way to plug Dropwizard Metrics integration on the server-side is by using WebServiceFeature mechanism, for which there is a dedicated MetricsFeature implementation. The snipped below illustrated the basic initialization sequence and set of the dependencies involved.

Code Block
final Bus bus = ...; /* MetricRegistry instance is taken from Bus instance */
final MetricsProvider metricsProvider = new CodahaleMetricsProvider(bus);
 
final JAXWSServerFactoryBean factory = new JAXWSServerFactoryBean();
factory.setWsFeatures(Arrays.asList(new MetricsFeature(metricsProvider)));
...

Alternatively, the MetricsFeature could be supplied directly to JAX-WS endpoint, for example:

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

Client

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

Code Block
final Bus bus = ...; /* MetricRegistry instance is taken from Bus instance */
final MetricsProvider metricsProvider = new CodahaleMetricsProvider(bus);

final JaxWsClientFactoryBean factory = new JaxWsClientFactoryBean();
factory.setFeatures(Arrays.asList(new MetricsFeature(new CodahaleMetricsProvider(bus))));
...

Integration with JAX-RS

Server

The typical way to plug Dropwizard Metrics integration  on the server-side is by using AbstractFeature which is implemented by MetricsFeature. The snipped below illustrated the basic initialization sequence and set of the dependencies involved.

Code Block
final Bus bus = ...; /* MetricRegistry instance is taken from Bus instance */
final MetricsProvider metricsProvider = new CodahaleMetricsProvider(bus);

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

Client

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

Code Block
final Bus bus = ...; /* MetricRegistry instance is taken from Bus instance */
final MetricsProvider metricsProvider = new CodahaleMetricsProvider(bus);

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