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.eatthepath</groupId>
<artifactId>pushy-dropwizard-metrics-listener</artifactId>
<version>0.16.0</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 4.2.26 of the Dropwizard Metrics library.
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 apnsClient = new ApnsClientBuilder()
.setApnsServer(ApnsClientBuilder.DEVELOPMENT_APNS_HOST)
.setSigningKey(ApnsSigningKey.loadFromPkcs8File(new File("/path/to/key.p8"),
"TEAMID1234", "KEYID67890"))
.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);
The Dropwizard Metrics listener for Pushy is available under the MIT License.