plugin/forward Add rcode and rtype to request_duration_seconds metric (#4391)

* plugin/forward Add rcode and rtype to request_duration_seconds metric

Signed-off-by: Maxime Ginters <maxime.ginters@shopify.com>

* Control the cardinality of query type

Signed-off-by: Maxime Ginters <maxime.ginters@shopify.com>
This commit is contained in:
Maxime Ginters 2021-01-28 10:37:17 -05:00 committed by GitHub
parent 2ab304078b
commit b1173ed2a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 36 deletions

View file

@ -11,6 +11,7 @@ import (
"sync/atomic"
"time"
"github.com/coredns/coredns/plugin/pkg/dnsutil"
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
@ -129,9 +130,11 @@ func (p *Proxy) Connect(ctx context.Context, state request.Request, opts options
rc = strconv.Itoa(ret.Rcode)
}
qtype := dnsutil.QTypeMonitorLabel(state.QType())
RequestCount.WithLabelValues(p.addr).Add(1)
RcodeCount.WithLabelValues(rc, p.addr).Add(1)
RequestDuration.WithLabelValues(p.addr).Observe(time.Since(start).Seconds())
RequestDuration.WithLabelValues(p.addr, rc, qtype).Observe(time.Since(start).Seconds())
return ret, nil
}