Added DNS-SD lookup counter for successful/unsuccessful lookups

Change-Id: I0a71e994a989cecace280b5134a31ebc2ace7591
This commit is contained in:
Stuart Nelson 2013-12-13 20:50:48 -05:00
parent 0c58e388f6
commit 48a6326d25
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}}) 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)
} }

View file

@ -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
} }