Skip to content

Latest commit

 

History

History
 
 

dropwizard-metrics-listener

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Dropwizard Metrics listener for Pushy

This module is an implementation of Pushy's ApnsClientMetricsListener interface that uses the Dropwizard Metrics library to gather and report metrics. If you use Maven, you can add the listener to your project by adding the following dependency declaration to your POM:

<dependency>
    <groupId>com.turo</groupId>
    <artifactId>pushy-dropwizard-metrics-listener</artifactId>
    <version>0.10</version>
</dependency>

If you don't use Maven, you can add the .jar file and its dependencies to your classpath by the method of your choice. The Dropwizard Metrics listener for Pushy depends on Pushy itself (obviously enough) and version 3.1.0 of the Dropwizard Metrics library.

Using the Dropwizard Metrics listener

Creating new Dropwizard Metrics listeners is straightforward. To get started, construct a new listener and pass it in when constructing a new client.

final DropwizardApnsClientMetricsListener listener =
    new DropwizardApnsClientMetricsListener();

final ApnsClient<SimpleApnsPushNotification> apnsClient =
    new ApnsClientBuilder<SimpleApnsPushNotification>()
        .setClientCredentials(new File("/path/to/certificate.p12"), "p12-file-password")
        .setMetricsListener(listener)
        .build();

Note that a DropwizardApnsClientMetricsListener is intended for use with only one ApnsClient at a time; if you're constructing multiple clients with the same builder, you'll need to specify a new listener for each client.

DropwizardApnsClientMetricsListeners are themselves Metrics, and can be registered with a MetricRegistry.

registry.register("com.example.MyApnsClient", listener);

License

The Dropwizard Metrics listener for Pushy is available under the MIT License.