2016-10-26 10:01:52 +01:00
|
|
|
package vars
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
2017-02-21 22:51:47 -08:00
|
|
|
"github.com/coredns/coredns/request"
|
2016-10-26 10:01:52 +01:00
|
|
|
)
|
|
|
|
|
|
2019-03-25 19:04:03 +00:00
|
|
|
// Report reports the metrics data associated with request. This function is exported because it is also
|
|
|
|
|
// called from core/dnsserver to report requests hitting the server that should not be handled and are thus
|
|
|
|
|
// not sent down the plugin chain.
|
2019-03-25 17:46:44 +00:00
|
|
|
func Report(server string, req request.Request, zone, rcode string, size int, start time.Time) {
|
2016-11-29 11:02:43 +00:00
|
|
|
// Proto and Family.
|
2016-10-26 10:01:52 +01:00
|
|
|
net := req.Proto()
|
|
|
|
|
fam := "1"
|
|
|
|
|
if req.Family() == 2 {
|
|
|
|
|
fam = "2"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if req.Do() {
|
2018-04-18 09:42:20 +01:00
|
|
|
RequestDo.WithLabelValues(server, zone).Inc()
|
2016-10-26 10:01:52 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-28 10:50:23 +02:00
|
|
|
qType := qTypeString(req.QType())
|
|
|
|
|
RequestCount.WithLabelValues(server, zone, net, fam, qType).Inc()
|
2021-03-19 12:59:26 +01:00
|
|
|
|
|
|
|
|
RequestDuration.WithLabelValues(server, zone).Observe(time.Since(start).Seconds())
|
2016-10-26 10:01:52 +01:00
|
|
|
|
2018-04-18 09:42:20 +01:00
|
|
|
ResponseSize.WithLabelValues(server, zone, net).Observe(float64(size))
|
|
|
|
|
RequestSize.WithLabelValues(server, zone, net).Observe(float64(req.Len()))
|
2016-10-26 10:01:52 +01:00
|
|
|
|
2018-04-18 09:42:20 +01:00
|
|
|
ResponseRcode.WithLabelValues(server, zone, rcode).Inc()
|
|
|
|
|
}
|