Skip to content

Commit

Permalink
Merge pull request #9 from cosminrentea/feature/prometheus-basic-metrics
Browse files Browse the repository at this point in the history
First Prometheus metric - for APNS
  • Loading branch information
cosminrentea committed Mar 17, 2017
2 parents 25ac255 + 4c836b7 commit f81bfe6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/apns/apns.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (a *apns) HandleResponse(request connector.Request, responseIface interface
if r.Sent() {
logger.WithField("id", r.ApnsID).Info("APNS notification was successfully sent")
mTotalSentMessages.Add(1)
pSentMessages.Inc()
if *a.IntervalMetrics && metadata != nil {
addToLatenciesAndCountsMaps(currentTotalMessagesLatenciesKey, currentTotalMessagesKey, metadata.Latency)
}
Expand Down
18 changes: 18 additions & 0 deletions server/apns/apns_prometheus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package apns

import (
"github.com/prometheus/client_golang/prometheus"
)

var (
pSentMessages = prometheus.NewCounter(prometheus.CounterOpts{
Name: "apns_sent_messages",
Help: "Number of messages sent to APNS",
})
)

func init() {
prometheus.MustRegister(
pSentMessages,
)
}

0 comments on commit f81bfe6

Please sign in to comment.