Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
f427b997
Commit
f427b997
authored
Jul 08, 2015
by
Victor Marmol
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10889 from cjcullen/tokenMetrics
Add prometheus metrics for altTokenSource.
parents
cfbc64e3
53c9f324
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
token_source.go
pkg/cloudprovider/gce/token_source.go
+30
-0
No files found.
pkg/cloudprovider/gce/token_source.go
View file @
f427b997
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"code.google.com/p/google-api-go-client/googleapi"
"code.google.com/p/google-api-go-client/googleapi"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/oauth2"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"golang.org/x/oauth2/google"
)
)
...
@@ -35,6 +36,26 @@ const (
...
@@ -35,6 +36,26 @@ const (
tokenURLBurst
=
3
tokenURLBurst
=
3
)
)
var
(
getTokenCounter
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"get_token_count"
,
Help
:
"Counter of total Token() requests to the alternate token source"
,
},
)
getTokenFailCounter
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"get_token_fail_count"
,
Help
:
"Counter of failed Token() requests to the alternate token source"
,
},
)
)
func
init
()
{
prometheus
.
MustRegister
(
getTokenCounter
)
prometheus
.
MustRegister
(
getTokenFailCounter
)
}
type
altTokenSource
struct
{
type
altTokenSource
struct
{
oauthClient
*
http
.
Client
oauthClient
*
http
.
Client
tokenURL
string
tokenURL
string
...
@@ -43,6 +64,15 @@ type altTokenSource struct {
...
@@ -43,6 +64,15 @@ type altTokenSource struct {
func
(
a
*
altTokenSource
)
Token
()
(
*
oauth2
.
Token
,
error
)
{
func
(
a
*
altTokenSource
)
Token
()
(
*
oauth2
.
Token
,
error
)
{
a
.
throttle
.
Accept
()
a
.
throttle
.
Accept
()
getTokenCounter
.
Inc
()
t
,
err
:=
a
.
token
()
if
err
!=
nil
{
getTokenFailCounter
.
Inc
()
}
return
t
,
err
}
func
(
a
*
altTokenSource
)
token
()
(
*
oauth2
.
Token
,
error
)
{
req
,
err
:=
http
.
NewRequest
(
"GET"
,
a
.
tokenURL
,
nil
)
req
,
err
:=
http
.
NewRequest
(
"GET"
,
a
.
tokenURL
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment