summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2024-05-20 13:32:52 +0200
committerOto Šťáva <oto.stava@nic.cz>2024-05-20 13:32:52 +0200
commit8f5194835bf7038edf4e47a1485d5fd1a3a427e1 (patch)
treeb7eaf123f02c1f0d488c4335fb8fbb360c28e945 /modules
parentmodules/stats: add answer.sum_ms metric (diff)
downloadknot-resolver-8f5194835bf7038edf4e47a1485d5fd1a3a427e1.tar.xz
knot-resolver-8f5194835bf7038edf4e47a1485d5fd1a3a427e1.zip
modules/stats: split request.* metrics to IPv4 and IPv6
Let's have .total4 and .total6, too. Then .total could be expressed as a sum of *three* (including .internal), so it's still counted separately, as an exception.
Diffstat (limited to 'modules')
-rw-r--r--modules/stats/stats.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/modules/stats/stats.c b/modules/stats/stats.c
index c93401cf..285e9486 100644
--- a/modules/stats/stats.c
+++ b/modules/stats/stats.c
@@ -46,8 +46,9 @@
X(answer,aa) X(answer,tc) X(answer,rd) X(answer,ra) X(answer, ad) X(answer,cd) \
X(answer,edns0) X(answer,do) \
X(query,edns) X(query,dnssec) \
- X(request,total) X(request,udp) X(request,tcp) X(request,xdp) \
- X(request,dot) X(request,doh) X(request,internal) \
+ X(request,total) X(request,total4) X(request,total6) X(request,internal) \
+ X(request,udp4) X(request,tcp4) X(request,xdp4) X(request,dot4) X(request,doh4) \
+ X(request,udp6) X(request,tcp6) X(request,xdp6) X(request,dot6) X(request,doh6) \
X(const,end)
enum const_metric {
@@ -185,19 +186,26 @@ static int collect_transport(kr_layer_t *ctx)
}
/**
- * Count each transport only once,
+ * Apart from the "total" stats, count each transport only once,
* i.e. DoT does not count as TCP and XDP does not count as UDP.
+ * We have two counts for each - IPv6 and IPv4 separately.
*/
+ const bool isIPv6 = req->qsource.addr->sa_family == AF_INET6;
+ #define INC_PROTO(proto) \
+ stat_const_add(data, isIPv6 ? metric_request_ ## proto ## 6 \
+ : metric_request_ ## proto ## 4, 1)
+ INC_PROTO(total);
if (req->qsource.flags.http)
- stat_const_add(data, metric_request_doh, 1);
+ INC_PROTO(doh);
else if (req->qsource.flags.tls)
- stat_const_add(data, metric_request_dot, 1);
+ INC_PROTO(dot);
else if (req->qsource.flags.tcp)
- stat_const_add(data, metric_request_tcp, 1);
+ INC_PROTO(tcp);
else if (req->qsource.flags.xdp)
- stat_const_add(data, metric_request_xdp, 1);
+ INC_PROTO(xdp);
else
- stat_const_add(data, metric_request_udp, 1);
+ INC_PROTO(udp);
+ #undef INC_PROTO
return ctx->state;
}