Merge "Added DNS-SD lookup counter for successful/unsuccessful lookups"

This commit is contained in:
Julius Volz 2013-12-16 14:52:50 +01:00 committed by Gerrit Code Review
commit f44f398ea7
2 changed files with 14 additions and 0 deletions

View file

@ -42,10 +42,20 @@ var (
ReportablePercentiles: []float64{0.01, 0.05, 0.5, 0.90, 0.99}})
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() {
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_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)
}

View file

@ -59,11 +59,15 @@ func NewSdTargetProvider(job config.JobConfig) *sdTargetProvider {
}
func (p *sdTargetProvider) Targets() ([]Target, error) {
var err error
defer func() { recordOutcome(err) }()
if time.Since(p.lastRefresh) < p.refreshInterval {
return p.targets, nil
}
response, err := lookupSRV(p.job.GetSdName())
if err != nil {
return nil, err
}