mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
Dont log per qtype - fun and all, but not really useful
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
func (m Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
||||
state := middleware.State{W: w, Req: r}
|
||||
qname := state.Name()
|
||||
qtype := state.Type()
|
||||
net := state.Proto()
|
||||
zone := middleware.Zones(m.ZoneNames).Matches(qname)
|
||||
if zone == "" {
|
||||
zone = "."
|
||||
@@ -22,21 +22,21 @@ func (m Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||
rw := middleware.NewResponseRecorder(w)
|
||||
status, err := m.Next.ServeDNS(ctx, rw, r)
|
||||
|
||||
Report(zone, qtype, rw.Rcode(), rw.Size(), rw.Start())
|
||||
Report(zone, net, rw.Rcode(), rw.Size(), rw.Start())
|
||||
|
||||
return status, err
|
||||
}
|
||||
|
||||
// Report is a plain reporting function that the server can use for REFUSED and other
|
||||
// queries that are turned down because they don't match any middleware.
|
||||
func Report(zone, qtype, rcode string, size int, start time.Time) {
|
||||
func Report(zone, net, rcode string, size int, start time.Time) {
|
||||
if requestCount == nil {
|
||||
// no metrics are enabled
|
||||
return
|
||||
}
|
||||
|
||||
requestCount.WithLabelValues(zone, qtype).Inc()
|
||||
requestDuration.WithLabelValues(zone, qtype).Observe(float64(time.Since(start) / time.Second))
|
||||
responseSize.WithLabelValues(zone, qtype).Observe(float64(size))
|
||||
responseRcode.WithLabelValues(zone, rcode, qtype).Inc()
|
||||
requestCount.WithLabelValues(zone, net).Inc()
|
||||
requestDuration.WithLabelValues(zone).Observe(float64(time.Since(start) / time.Second))
|
||||
responseSize.WithLabelValues(zone).Observe(float64(size))
|
||||
responseRcode.WithLabelValues(zone, rcode).Inc()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user