middleware/metrics: export actual size (#448)

The `*_size*` metrics now export the actual packet length, not the
advertised one (although that might be nice as well).
This commit is contained in:
Miek Gieben
2016-11-29 11:02:43 +00:00
committed by GitHub
parent 4cfd19c7c9
commit 8c8b37a30e
5 changed files with 12 additions and 9 deletions

View File

@@ -25,7 +25,7 @@ func (m *Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
rw := dnsrecorder.New(w)
status, err := m.Next.ServeDNS(ctx, rw, r)
vars.Report(state, zone, rcode.ToString(rw.Rcode), rw.Size, rw.Start)
vars.Report(state, zone, rcode.ToString(rw.Rcode), rw.Len, rw.Start)
return status, err
}

View File

@@ -10,7 +10,7 @@ import (
// Report reports the metrics data associcated with request.
func Report(req request.Request, zone, rcode string, size int, start time.Time) {
// Proto and Family
// Proto and Family.
net := req.Proto()
fam := "1"
if req.Family() == 2 {
@@ -33,7 +33,7 @@ func Report(req request.Request, zone, rcode string, size int, start time.Time)
}
ResponseSize.WithLabelValues(zone, net).Observe(float64(size))
RequestSize.WithLabelValues(zone, net).Observe(float64(req.Size()))
RequestSize.WithLabelValues(zone, net).Observe(float64(req.Len()))
ResponseRcode.WithLabelValues(zone, rcode).Inc()
}