mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
keep consul service metrics in global variables (#6764)
Signed-off-by: yeya24 <yb532204897@gmail.com>
This commit is contained in:
parent
0a27df92f0
commit
60527de355
|
@ -83,6 +83,10 @@ var (
|
||||||
[]string{"endpoint", "call"},
|
[]string{"endpoint", "call"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Initialize metric vectors.
|
||||||
|
servicesRPCDuraion = rpcDuration.WithLabelValues("catalog", "services")
|
||||||
|
serviceRPCDuraion = rpcDuration.WithLabelValues("catalog", "service")
|
||||||
|
|
||||||
// DefaultSDConfig is the default Consul SD configuration.
|
// DefaultSDConfig is the default Consul SD configuration.
|
||||||
DefaultSDConfig = SDConfig{
|
DefaultSDConfig = SDConfig{
|
||||||
TagSeparator: ",",
|
TagSeparator: ",",
|
||||||
|
@ -141,10 +145,6 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
func init() {
|
func init() {
|
||||||
prometheus.MustRegister(rpcFailuresCount)
|
prometheus.MustRegister(rpcFailuresCount)
|
||||||
prometheus.MustRegister(rpcDuration)
|
prometheus.MustRegister(rpcDuration)
|
||||||
|
|
||||||
// Initialize metric vectors.
|
|
||||||
rpcDuration.WithLabelValues("catalog", "service")
|
|
||||||
rpcDuration.WithLabelValues("catalog", "services")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discovery retrieves target information from a Consul server
|
// Discovery retrieves target information from a Consul server
|
||||||
|
@ -355,7 +355,7 @@ func (d *Discovery) watchServices(ctx context.Context, ch chan<- []*targetgroup.
|
||||||
}
|
}
|
||||||
srvs, meta, err := catalog.Services(opts.WithContext(ctx))
|
srvs, meta, err := catalog.Services(opts.WithContext(ctx))
|
||||||
elapsed := time.Since(t0)
|
elapsed := time.Since(t0)
|
||||||
rpcDuration.WithLabelValues("catalog", "services").Observe(elapsed.Seconds())
|
servicesRPCDuraion.Observe(elapsed.Seconds())
|
||||||
|
|
||||||
// Check the context before in order to exit early.
|
// Check the context before in order to exit early.
|
||||||
select {
|
select {
|
||||||
|
@ -470,7 +470,7 @@ func (srv *consulService) watch(ctx context.Context, ch chan<- []*targetgroup.Gr
|
||||||
}
|
}
|
||||||
nodes, meta, err := catalog.ServiceMultipleTags(srv.name, srv.tags, opts.WithContext(ctx))
|
nodes, meta, err := catalog.ServiceMultipleTags(srv.name, srv.tags, opts.WithContext(ctx))
|
||||||
elapsed := time.Since(t0)
|
elapsed := time.Since(t0)
|
||||||
rpcDuration.WithLabelValues("catalog", "service").Observe(elapsed.Seconds())
|
serviceRPCDuraion.Observe(elapsed.Seconds())
|
||||||
|
|
||||||
// Check the context before in order to exit early.
|
// Check the context before in order to exit early.
|
||||||
select {
|
select {
|
||||||
|
|
Loading…
Reference in a new issue