|
|
@ -14,6 +14,7 @@ import (
|
|
|
|
"github.com/armon/go-metrics/prometheus"
|
|
|
|
"github.com/armon/go-metrics/prometheus"
|
|
|
|
"github.com/hashicorp/go-hclog"
|
|
|
|
"github.com/hashicorp/go-hclog"
|
|
|
|
"github.com/hashicorp/go-multierror"
|
|
|
|
"github.com/hashicorp/go-multierror"
|
|
|
|
|
|
|
|
prometheuscore "github.com/prometheus/client_golang/prometheus"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/lib/retry"
|
|
|
|
"github.com/hashicorp/consul/lib/retry"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -258,7 +259,7 @@ func dogstatdSink(cfg TelemetryConfig, hostname string) (metrics.MetricSink, err
|
|
|
|
return sink, nil
|
|
|
|
return sink, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func prometheusSink(cfg TelemetryConfig, hostname string) (metrics.MetricSink, error) {
|
|
|
|
func prometheusSink(cfg TelemetryConfig, _ string) (metrics.MetricSink, error) {
|
|
|
|
|
|
|
|
|
|
|
|
if cfg.PrometheusOpts.Expiration.Nanoseconds() < 1 {
|
|
|
|
if cfg.PrometheusOpts.Expiration.Nanoseconds() < 1 {
|
|
|
|
return nil, nil
|
|
|
|
return nil, nil
|
|
|
@ -266,12 +267,19 @@ func prometheusSink(cfg TelemetryConfig, hostname string) (metrics.MetricSink, e
|
|
|
|
|
|
|
|
|
|
|
|
sink, err := prometheus.NewPrometheusSinkFrom(cfg.PrometheusOpts)
|
|
|
|
sink, err := prometheus.NewPrometheusSinkFrom(cfg.PrometheusOpts)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
// During testing we may try to register the same metrics collector
|
|
|
|
|
|
|
|
// multiple times in a single run (e.g. a metrics test fails and
|
|
|
|
|
|
|
|
// we attempt a retry), resulting in an AlreadyRegisteredError.
|
|
|
|
|
|
|
|
// Suppress this and move on.
|
|
|
|
|
|
|
|
if errors.As(err, &prometheuscore.AlreadyRegisteredError{}) {
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sink, nil
|
|
|
|
return sink, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func circonusSink(cfg TelemetryConfig, hostname string) (metrics.MetricSink, error) {
|
|
|
|
func circonusSink(cfg TelemetryConfig, _ string) (metrics.MetricSink, error) {
|
|
|
|
token := cfg.CirconusAPIToken
|
|
|
|
token := cfg.CirconusAPIToken
|
|
|
|
url := cfg.CirconusSubmissionURL
|
|
|
|
url := cfg.CirconusSubmissionURL
|
|
|
|
if token == "" && url == "" {
|
|
|
|
if token == "" && url == "" {
|
|
|
|