mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user