MINOR: h3: Add a statistics module for h3
Add ->inc_err_cnt new callback to qcc_app_ops struct which can
be called from xprt to increment the application level error code counters.
It take the application context as first parameter to be generic and support
new QUIC applications to come.
Add h3_stats.c module with counters for all the frame types and error codes.
diff --git a/src/h3.c b/src/h3.c
index f30d478..14ae2c4 100644
--- a/src/h3.c
+++ b/src/h3.c
@@ -20,6 +20,7 @@
#include <haproxy/connection.h>
#include <haproxy/dynbuf.h>
#include <haproxy/h3.h>
+#include <haproxy/h3_stats.h>
#include <haproxy/http.h>
#include <haproxy/htx.h>
#include <haproxy/intops.h>
@@ -64,6 +65,8 @@
uint64_t max_field_section_size;
struct buffer_wait buf_wait; /* wait list for buffer allocations */
+ /* Stats counters */
+ struct h3_counters *prx_counters;
};
DECLARE_STATIC_POOL(pool_head_h3c, "h3c", sizeof(struct h3c));
@@ -567,6 +570,7 @@
last_stream_frame = (fin && flen == ncb_total_data(rxbuf));
+ h3_inc_frame_type_cnt(h3c->prx_counters, ftype);
switch (ftype) {
case H3_FT_DATA:
ret = h3_data_to_htx(qcs, rxbuf, flen, last_stream_frame);
@@ -982,6 +986,7 @@
static int h3_init(struct qcc *qcc)
{
struct h3c *h3c;
+ struct quic_conn *qc = qcc->conn->handle.qc;
h3c = pool_alloc(pool_head_h3c);
if (!h3c)
@@ -992,6 +997,9 @@
h3c->flags = 0;
qcc->ctx = h3c;
+ h3c->prx_counters =
+ EXTRA_COUNTERS_GET(qc->li->bind_conf->frontend->extra_counters_fe,
+ &h3_stats_module);
LIST_INIT(&h3c->buf_wait.list);
return 1;
@@ -1018,6 +1026,14 @@
return 0;
}
+/* Increment the h3 error code counters for <error_code> value */
+static void h3_stats_inc_err_cnt(void *ctx, int err_code)
+{
+ struct h3c *h3c = ctx;
+
+ h3_inc_err_cnt(h3c->prx_counters, err_code);
+}
+
/* HTTP/3 application layer operations */
const struct qcc_app_ops h3_ops = {
.init = h3_init,
@@ -1028,4 +1044,5 @@
.finalize = h3_finalize,
.is_active = h3_is_active,
.release = h3_release,
+ .inc_err_cnt = h3_stats_inc_err_cnt,
};