mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 15:44:05 -08:00
Merge "Added DNS-SD lookup counter for successful/unsuccessful lookups"
This commit is contained in:
commit
f44f398ea7
|
@ -42,10 +42,20 @@ var (
|
||||||
ReportablePercentiles: []float64{0.01, 0.05, 0.5, 0.90, 0.99}})
|
ReportablePercentiles: []float64{0.01, 0.05, 0.5, 0.90, 0.99}})
|
||||||
|
|
||||||
targetOperations = prometheus.NewCounter()
|
targetOperations = prometheus.NewCounter()
|
||||||
|
dnsSDLookupsCount = prometheus.NewCounter()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func recordOutcome(err error) {
|
||||||
|
message := success
|
||||||
|
if err != nil {
|
||||||
|
message = failure
|
||||||
|
}
|
||||||
|
dnsSDLookupsCount.Increment(map[string]string{outcome: message})
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
prometheus.Register("prometheus_target_operations_total", "The total numbers of operations of the various targets that are being monitored.", prometheus.NilLabels, targetOperations)
|
prometheus.Register("prometheus_target_operations_total", "The total numbers of operations of the various targets that are being monitored.", prometheus.NilLabels, targetOperations)
|
||||||
prometheus.Register("prometheus_target_operation_latency_ms", "The latencies for various target operations.", prometheus.NilLabels, targetOperationLatencies)
|
prometheus.Register("prometheus_target_operation_latency_ms", "The latencies for various target operations.", prometheus.NilLabels, targetOperationLatencies)
|
||||||
prometheus.Register("prometheus_targetpool_duration_ms", "The durations for each TargetPool to retrieve state from all included entities.", prometheus.NilLabels, retrievalDurations)
|
prometheus.Register("prometheus_targetpool_duration_ms", "The durations for each TargetPool to retrieve state from all included entities.", prometheus.NilLabels, retrievalDurations)
|
||||||
|
prometheus.Register("prometheus_dns_sd_lookups_total", "The number of DNS-SD lookup successes/failures per pool.", prometheus.NilLabels, dnsSDLookupsCount)
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,11 +59,15 @@ func NewSdTargetProvider(job config.JobConfig) *sdTargetProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *sdTargetProvider) Targets() ([]Target, error) {
|
func (p *sdTargetProvider) Targets() ([]Target, error) {
|
||||||
|
var err error
|
||||||
|
defer func() { recordOutcome(err) }()
|
||||||
|
|
||||||
if time.Since(p.lastRefresh) < p.refreshInterval {
|
if time.Since(p.lastRefresh) < p.refreshInterval {
|
||||||
return p.targets, nil
|
return p.targets, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := lookupSRV(p.job.GetSdName())
|
response, err := lookupSRV(p.job.GetSdName())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue