-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
106 changed files
with
1,098 additions
and
800 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
internal/component/discovery/consulagent/consulagent_metrics.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package consulagent | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/prometheus/discovery" | ||
) | ||
|
||
// This code was adapted from the consul service discovery | ||
// package in prometheus: https://github.com/prometheus/prometheus/blob/main/discovery/consul/metrics.go | ||
// which is copyrighted: 2015 The Prometheus Authors | ||
// and licensed under the Apache License, Version 2.0 (the "License"); | ||
|
||
var _ discovery.DiscovererMetrics = (*consulMetrics)(nil) | ||
|
||
type consulMetrics struct { | ||
rpcFailuresCount prometheus.Counter | ||
rpcDuration *prometheus.SummaryVec | ||
|
||
servicesRPCDuration prometheus.Observer | ||
serviceRPCDuration prometheus.Observer | ||
|
||
metricRegisterer discovery.MetricRegisterer | ||
} | ||
|
||
func newDiscovererMetrics(reg prometheus.Registerer, _ discovery.RefreshMetricsInstantiator) discovery.DiscovererMetrics { | ||
m := &consulMetrics{ | ||
rpcFailuresCount: prometheus.NewCounter( | ||
prometheus.CounterOpts{ | ||
Name: "sd_consulagent_rpc_failures_total", | ||
Help: "The number of Consul Agent RPC call failures.", | ||
}), | ||
rpcDuration: prometheus.NewSummaryVec( | ||
prometheus.SummaryOpts{ | ||
Name: "sd_consulagent_rpc_duration_seconds", | ||
Help: "The duration of a Consul Agent RPC call in seconds.", | ||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, | ||
}, | ||
[]string{"endpoint", "call"}, | ||
), | ||
} | ||
|
||
m.metricRegisterer = discovery.NewMetricRegisterer(reg, []prometheus.Collector{ | ||
m.rpcFailuresCount, | ||
m.rpcDuration, | ||
}) | ||
|
||
// Initialize metric vectors. | ||
m.servicesRPCDuration = m.rpcDuration.WithLabelValues("agent", "services") | ||
m.serviceRPCDuration = m.rpcDuration.WithLabelValues("agent", "service") | ||
|
||
return m | ||
} | ||
|
||
// Register implements discovery.DiscovererMetrics. | ||
func (m *consulMetrics) Register() error { | ||
return m.metricRegisterer.RegisterMetrics() | ||
} | ||
|
||
// Unregister implements discovery.DiscovererMetrics. | ||
func (m *consulMetrics) Unregister() { | ||
m.metricRegisterer.UnregisterMetrics() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.