Skip to content

Commit

Permalink
Request duration metric is not populated if request resolution was fa…
Browse files Browse the repository at this point in the history
…ulty (#257)
  • Loading branch information
0xERR0R committed Aug 30, 2021
1 parent 26efda2 commit 48a3802
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions resolver/metrics_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,22 @@ func (m *MetricsResolver) Resolve(request *Request) (*Response, error) {
"client": strings.Join(request.ClientNames, ","),
"type": dns.TypeToString[request.Req.Question[0].Qtype]}).Inc()

reqDurationMs := float64(time.Since(request.RequestTS).Milliseconds())
responseType := "err"

if response != nil {
responseType = response.RType.String()
}

m.durationHistogram.WithLabelValues(responseType).Observe(reqDurationMs)

if err != nil {
m.totalErrors.Inc()
} else {
m.totalResponse.With(prometheus.Labels{
"reason": response.Reason,
"response_code": dns.RcodeToString[response.Res.Rcode],
"response_type": response.RType.String()}).Inc()
reqDurationMs := float64(time.Since(request.RequestTS).Milliseconds())
m.durationHistogram.WithLabelValues(response.RType.String()).Observe(reqDurationMs)
}
}

Expand Down

0 comments on commit 48a3802

Please sign in to comment.