This module is an implementation of Pushy's ApnsClientMetricsListener
interface that uses the Micrometer application monitoring 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-micrometer-metrics-listener</artifactId>
<version>0.15.2</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 Micrometer listener for Pushy depends on Pushy itself (obviously enough) and version 1.0 of the Micrometer application monitoring library. Please note that while Pushy itself works with Java 7 and newer, the Micrometer metrics listener requires Java 8 or newer.
Creating new Micrometer listeners is straightforward. To get started, construct a new listener by passing an existing MeterRegistry
(and an optional list of tags) to the MicrometerApnsClientMetricsListener
constructor. From there, construct a new ApnsClient
with the metric listener:
final MicrometerApnsClientMetricsListener listener =
new MicrometerApnsClientMetricsListener(existingMeterRegistry,
"notifications", "apns", "pushy");
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 MicrometerApnsClientMetricsListener
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.
The Micrometer metrics listener for Pushy is available under the MIT License.