Skip to content

Commit 36d7d39

Browse files
committed
wording
1 parent f13df6f commit 36d7d39

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

coderd/promoauth/github.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func githubRateLimits(resp *http.Response, err error) (rateLimits, bool) {
2828
Limit: p.int("x-ratelimit-limit"),
2929
Remaining: p.int("x-ratelimit-remaining"),
3030
Used: p.int("x-ratelimit-used"),
31-
Resource: p.header.Get("x-ratelimit-resource"),
31+
Resource: p.string("x-ratelimit-resource"),
3232
}
3333

3434
if limits.Limit == 0 &&
@@ -74,7 +74,7 @@ type headerParser struct {
7474
header http.Header
7575
}
7676

77-
func (p *headerParser) int(key string) int {
77+
func (p *headerParser) string(key string) string {
7878
if p.errors == nil {
7979
p.errors = make(map[string]error)
8080
}
@@ -83,6 +83,14 @@ func (p *headerParser) int(key string) int {
8383
if v == "" {
8484
p.errors[key] = fmt.Errorf("missing header %q", key)
8585
}
86+
return v
87+
}
88+
89+
func (p *headerParser) int(key string) int {
90+
v := p.string(key)
91+
if v == "" {
92+
return -1
93+
}
8694

8795
i, err := strconv.Atoi(v)
8896
if err != nil {

coderd/promoauth/oauth2.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ type metrics struct {
5050
rateLimit *prometheus.GaugeVec
5151
rateLimitRemaining *prometheus.GaugeVec
5252
rateLimitUsed *prometheus.GaugeVec
53-
// rateLimitReset is the time in seconds the rate limit resets.
53+
// rateLimitReset is unix time of the next interval (when the rate limit resets).
5454
rateLimitReset *prometheus.GaugeVec
5555
// rateLimitResetIn is the time in seconds until the rate limit resets.
56+
// This is included because it is sometimes more helpful to know the limit
57+
// will reset in 600seconds, rather than at 1704000000 unix time.
5658
rateLimitResetIn *prometheus.GaugeVec
5759
}
5860

@@ -104,7 +106,7 @@ func NewFactory(registry prometheus.Registerer) *Factory {
104106
Namespace: "coderd",
105107
Subsystem: "oauth2",
106108
Name: "external_requests_rate_limit_next_reset_unix",
107-
Help: "Unix timestamp of the next interval",
109+
Help: "Unix timestamp for when the next interval starts",
108110
}, []string{
109111
"name",
110112
"resource",

0 commit comments

Comments
 (0)