@@ -34,6 +34,8 @@ const (
34
34
35
35
MetricsKeyRateLimit = "github.rate.limit"
36
36
MetricsKeyRateLimitRemaining = "github.rate.remaining"
37
+ MetricsKeyRateLimitUsed = "github.rate.used"
38
+ MetricsKeyRateLimitReset = "github.rate.reset"
37
39
)
38
40
39
41
// ClientMetrics creates client middleware that records metrics about all
@@ -73,11 +75,15 @@ func ClientMetrics(registry metrics.Registry) ClientMiddleware {
73
75
74
76
limitMetric := fmt .Sprintf ("%s[installation:%d]" , MetricsKeyRateLimit , installationID )
75
77
remainingMetric := fmt .Sprintf ("%s[installation:%d]" , MetricsKeyRateLimitRemaining , installationID )
78
+ usedMetric := fmt .Sprintf ("%s[installation:%d]" , MetricsKeyRateLimitUsed , installationID )
79
+ resetMetric := fmt .Sprintf ("%s[installation:%d]" , MetricsKeyRateLimitReset , installationID )
76
80
77
81
// Headers from https://developer.github.com/v3/#rate-limiting
78
82
updateRegistryForHeader (res .Header , httpHeaderRateLimit , metrics .GetOrRegisterGauge (limitMetric , registry ))
79
83
updateRegistryForHeader (res .Header , httpHeaderRateRemaining , metrics .GetOrRegisterGauge (remainingMetric , registry ))
80
- // TODO Think about to add X-Ratelimit-Used, X-Ratelimit-Reset and X-Ratelimit-Resource as well
84
+ updateRegistryForHeader (res .Header , httpHeaderRateUsed , metrics .GetOrRegisterGauge (usedMetric , registry ))
85
+ updateRegistryForHeader (res .Header , httpHeaderRateReset , metrics .GetOrRegisterGauge (resetMetric , registry ))
86
+ // TODO Think about to add X-Ratelimit-Resource as well
81
87
}
82
88
83
89
return res , err
0 commit comments