Change metric type from Gauge to Counter (#569)

This commit is contained in:
Jason Murray 2021-05-14 16:05:54 -07:00 committed by GitHub
parent 937bca3f37
commit 1c21eb8e87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

View File

@ -81,37 +81,37 @@ func (c Metrics) Describe(ch chan<- *prometheus.Desc) {
func (c Metrics) Collect(ch chan<- prometheus.Metric) { func (c Metrics) Collect(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.TotalPushCount, c.TotalPushCount,
prometheus.GaugeValue, prometheus.CounterValue,
float64(StatStorage.GetTotalCount()), float64(StatStorage.GetTotalCount()),
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.IosSuccess, c.IosSuccess,
prometheus.GaugeValue, prometheus.CounterValue,
float64(StatStorage.GetIosSuccess()), float64(StatStorage.GetIosSuccess()),
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.IosError, c.IosError,
prometheus.GaugeValue, prometheus.CounterValue,
float64(StatStorage.GetIosError()), float64(StatStorage.GetIosError()),
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.AndroidSuccess, c.AndroidSuccess,
prometheus.GaugeValue, prometheus.CounterValue,
float64(StatStorage.GetAndroidSuccess()), float64(StatStorage.GetAndroidSuccess()),
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.AndroidError, c.AndroidError,
prometheus.GaugeValue, prometheus.CounterValue,
float64(StatStorage.GetAndroidError()), float64(StatStorage.GetAndroidError()),
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.HuaweiSuccess, c.HuaweiSuccess,
prometheus.GaugeValue, prometheus.CounterValue,
float64(StatStorage.GetHuaweiSuccess()), float64(StatStorage.GetHuaweiSuccess()),
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.HuaweiError, c.HuaweiError,
prometheus.GaugeValue, prometheus.CounterValue,
float64(StatStorage.GetHuaweiError()), float64(StatStorage.GetHuaweiError()),
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(

View File

@ -159,11 +159,13 @@ func newApnsClient(certificate tls.Certificate) (*apns2.Client, error) {
IdleConnTimeout: idleConnTimeout, IdleConnTimeout: idleConnTimeout,
} }
if h2Transport, err := http2.ConfigureTransports(transport); err != nil { h2Transport, err := http2.ConfigureTransports(transport)
if err != nil {
return nil, err return nil, err
} else {
configureHTTP2ConnHealthCheck(h2Transport)
} }
configureHTTP2ConnHealthCheck(h2Transport)
client.HTTPClient.Transport = transport client.HTTPClient.Transport = transport
return client, nil return client, nil
@ -188,12 +190,13 @@ func newApnsTokenClient(token *token.Token) (*apns2.Client, error) {
IdleConnTimeout: idleConnTimeout, IdleConnTimeout: idleConnTimeout,
} }
if h2Transport, err := http2.ConfigureTransports(transport); err != nil { h2Transport, err := http2.ConfigureTransports(transport)
if err != nil {
return nil, err return nil, err
} else {
configureHTTP2ConnHealthCheck(h2Transport)
} }
configureHTTP2ConnHealthCheck(h2Transport)
client.HTTPClient.Transport = transport client.HTTPClient.Transport = transport
return client, nil return client, nil