Browse Source

Added DNS-SD lookup counter for successful/unsuccessful lookups

Change-Id: I0a71e994a989cecace280b5134a31ebc2ace7591
changes/82/82/4
Stuart Nelson 11 years ago
parent
commit
48a6326d25
  1. 10
      retrieval/instrumentation.go
  2. 4
      retrieval/target_provider.go

10
retrieval/instrumentation.go

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

4
retrieval/target_provider.go

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

Loading…
Cancel
Save