Skip to content

Commit a661a40

Browse files
committed
wording
1 parent 24c4bdd commit a661a40

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
@@ -60,9 +60,11 @@ type metrics struct {
6060
rateLimit *prometheus.GaugeVec
6161
rateLimitRemaining *prometheus.GaugeVec
6262
rateLimitUsed *prometheus.GaugeVec
63-
// rateLimitReset is the time in seconds the rate limit resets.
63+
// rateLimitReset is unix time of the next interval (when the rate limit resets).
6464
rateLimitReset *prometheus.GaugeVec
6565
// rateLimitResetIn is the time in seconds until the rate limit resets.
66+
// This is included because it is sometimes more helpful to know the limit
67+
// will reset in 600seconds, rather than at 1704000000 unix time.
6668
rateLimitResetIn *prometheus.GaugeVec
6769
}
6870

@@ -114,7 +116,7 @@ func NewFactory(registry prometheus.Registerer) *Factory {
114116
Namespace: "coderd",
115117
Subsystem: "oauth2",
116118
Name: "external_requests_rate_limit_next_reset_unix",
117-
Help: "Unix timestamp of the next interval",
119+
Help: "Unix timestamp for when the next interval starts",
118120
}, []string{
119121
"name",
120122
"resource",

0 commit comments

Comments
 (0)