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
8fa332cc
Unverified
Commit
8fa332cc
authored
Feb 14, 2019
by
Davanum Srinivas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure prometheus metrics are not registered twice
Change-Id: I0f05fae65689b1e22c18d2c46dc5125780e81024
parent
07428f7e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
7 deletions
+23
-7
aws_metrics.go
pkg/cloudprovider/providers/aws/aws_metrics.go
+12
-4
openstack_metrics.go
pkg/cloudprovider/providers/openstack/openstack_metrics.go
+11
-3
No files found.
pkg/cloudprovider/providers/aws/aws_metrics.go
View file @
8fa332cc
...
...
@@ -16,7 +16,11 @@ limitations under the License.
package
aws
import
"github.com/prometheus/client_golang/prometheus"
import
(
"sync"
"github.com/prometheus/client_golang/prometheus"
)
var
(
awsAPIMetric
=
prometheus
.
NewHistogramVec
(
...
...
@@ -53,8 +57,12 @@ func recordAWSThrottlesMetric(operation string) {
awsAPIThrottlesMetric
.
With
(
prometheus
.
Labels
{
"operation_name"
:
operation
})
.
Inc
()
}
var
registerOnce
sync
.
Once
func
registerMetrics
()
{
prometheus
.
MustRegister
(
awsAPIMetric
)
prometheus
.
MustRegister
(
awsAPIErrorMetric
)
prometheus
.
MustRegister
(
awsAPIThrottlesMetric
)
registerOnce
.
Do
(
func
()
{
prometheus
.
MustRegister
(
awsAPIMetric
)
prometheus
.
MustRegister
(
awsAPIErrorMetric
)
prometheus
.
MustRegister
(
awsAPIThrottlesMetric
)
})
}
pkg/cloudprovider/providers/openstack/openstack_metrics.go
View file @
8fa332cc
...
...
@@ -16,7 +16,11 @@ limitations under the License.
package
openstack
import
"github.com/prometheus/client_golang/prometheus"
import
(
"sync"
"github.com/prometheus/client_golang/prometheus"
)
const
(
openstackSubsystem
=
"openstack"
...
...
@@ -44,7 +48,11 @@ var (
)
)
var
registerOnce
sync
.
Once
func
registerMetrics
()
{
prometheus
.
MustRegister
(
openstackOperationsLatency
)
prometheus
.
MustRegister
(
openstackAPIRequestErrors
)
registerOnce
.
Do
(
func
()
{
prometheus
.
MustRegister
(
openstackOperationsLatency
)
prometheus
.
MustRegister
(
openstackAPIRequestErrors
)
})
}
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