chore: instrument external oauth2 requests (#11519)

* chore: instrument external oauth2 requests

External requests made by oauth2 configs are now instrumented into prometheus metrics.
This commit is contained in:
Steven Masley
2024-01-10 09:13:30 -06:00
committed by GitHub
parent aa7fe075a8
commit 50b78e3325
17 changed files with 425 additions and 98 deletions

View File

@ -2,10 +2,13 @@ package testutil
import (
"context"
"net/http"
"net/url"
"time"
"golang.org/x/oauth2"
"github.com/coder/coder/v2/coderd/promoauth"
)
type OAuth2Config struct {
@ -13,6 +16,10 @@ type OAuth2Config struct {
TokenSourceFunc OAuth2TokenSource
}
func (*OAuth2Config) Do(_ context.Context, _ promoauth.Oauth2Source, req *http.Request) (*http.Response, error) {
return http.DefaultClient.Do(req)
}
func (*OAuth2Config) AuthCodeURL(state string, _ ...oauth2.AuthCodeOption) string {
return "/?state=" + url.QueryEscape(state)
}