diff options
author | Kevin Lyda <kevin@ie.suberic.net> | 2017-02-12 14:38:12 +0000 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2017-02-12 14:38:12 +0000 |
commit | ed8bc523fd0d1a66acf3fa449c453508035efdfc (patch) | |
tree | c05849546e1dd9d771dcc4c4ff52056d249a95fb /server/auth/github | |
parent | 9c344a0a95c44ef9cebade7b8a65ac160d9eb900 (diff) |
Initial pass at prometheus support. (#56)
Diffstat (limited to 'server/auth/github')
-rw-r--r-- | server/auth/github/github.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/server/auth/github/github.go b/server/auth/github/github.go index 46cf76a..d44a49d 100644 --- a/server/auth/github/github.go +++ b/server/auth/github/github.go @@ -7,6 +7,7 @@ import ( "github.com/nsheridan/cashier/server/auth" "github.com/nsheridan/cashier/server/config" + "github.com/nsheridan/cashier/server/metrics" githubapi "github.com/google/go-github/github" "golang.org/x/oauth2" @@ -73,6 +74,7 @@ func (c *Config) Valid(token *oauth2.Token) bool { if c.organization == "" { // There's no organization and the token is valid. Can only reach here // if there's a user whitelist set and the user is in the whitelist. + metrics.M.AuthValid.WithLabelValues("github").Inc() return true } client := githubapi.NewClient(c.newClient(token)) @@ -80,6 +82,9 @@ func (c *Config) Valid(token *oauth2.Token) bool { if err != nil { return false } + if member { + metrics.M.AuthValid.WithLabelValues("github").Inc() + } return member } @@ -108,6 +113,7 @@ func (c *Config) Exchange(code string) (*oauth2.Token, error) { if t.Expiry.Unix() <= 0 { t.Expiry = time.Now().Add(1 * time.Hour) } + metrics.M.AuthExchange.WithLabelValues("github").Inc() return t, nil } |