chore: drop github per user rate limit tracking (#12286)

* chore: drop github per user rate limit tracking

Rate limits for authenticated requests are per user.
This would be an excessive number of prometheus labels,
so we only track the unauthorized limit.
This commit is contained in:
Steven Masley
2024-02-23 11:17:52 -06:00
committed by GitHub
parent 90db6683c4
commit 13359aa16f
3 changed files with 28 additions and 19 deletions

View File

@ -179,6 +179,15 @@ func TestGithubRateLimits(t *testing.T) {
}
}
// Ignore the well known, required for setup
if !strings.Contains(r.URL.String(), ".well-known") {
// GitHub rate limits only are instrumented for unauthenticated calls. So emulate
// that here. We cannot actually use invalid credentials because the fake IDP
// will throw a test error, as it only expects things to work. And we want to use
// a real idp to emulate the right http calls to be instrumented.
rw.WriteHeader(http.StatusUnauthorized)
return
}
next.ServeHTTP(rw, r)
})
}))
@ -195,13 +204,13 @@ func TestGithubRateLimits(t *testing.T) {
// Do a single oauth2 call
ctx := testutil.Context(t, testutil.WaitShort)
ctx = context.WithValue(ctx, oauth2.HTTPClient, idp.HTTPClient(nil))
_, err := cfg.Exchange(ctx, idp.CreateAuthCode(t, "foo"))
require.NoError(t, err)
_, err := cfg.Exchange(ctx, "invalid")
require.Error(t, err, "expected unauthorized exchange")
// Verify
labels := prometheus.Labels{
"name": "test",
"resource": "core",
"resource": "core-unauthorized",
}
pass := true
if !c.ExpectNoMetrics {