blob: adc166799b46f627ad11ef07806ea6beb70d6885 [file] [log] [blame]
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +02001#include <haproxy/quic_stats-t.h>
2#include <haproxy/stats.h>
3
4enum {
5 QUIC_ST_DROPPED_PACKETS,
6 QUIC_ST_RETRY_SENT,
7 QUIC_ST_RETRY_VALIDATED,
8 QUIC_ST_RETRY_ERRORS,
9 QUIC_ST_CONN_OPENINGS,
10 QUIC_ST_HDSHK_FAILS,
11 /* Stream related counters */
12 QUIC_ST_DATA_BLOCKED,
13 QUIC_ST_STREAM_DATA_BLOCKED,
14 QUIC_ST_STREAMS_DATA_BLOCKED_BIDI,
15 QUIC_ST_STREAMS_DATA_BLOCKED_UNI,
16 QUIC_STATS_COUNT /* must be the last */
17};
18
19static struct name_desc quic_stats[] = {
20 [QUIC_ST_DROPPED_PACKETS] = { .name = "quic_dropped_pkt",
21 .desc = "Total number of dropped packets" },
22 [QUIC_ST_RETRY_SENT] = { .name = "quic_retry_sent",
23 .desc = "Total number of Retry sent" },
24 [QUIC_ST_RETRY_VALIDATED] = { .name = "quic_retry_validated",
25 .desc = "Total number of validated Retry tokens" },
26 [QUIC_ST_RETRY_ERRORS] = { .name = "quic_retry_error",
27 .desc = "Total number of Retry tokens errors" },
28 [QUIC_ST_CONN_OPENINGS] = { .name = "quic_conn_opening",
29 .desc = "Total number of connection openings" },
30 [QUIC_ST_HDSHK_FAILS] = { .name = "quic_hdshk_fail",
31 .desc = "Total number of handshake failures" },
32 /* Streams related counters */
33 [QUIC_ST_DATA_BLOCKED] = { .name = "quic_data_blocked",
34 .desc = "Total number of times DATA_BLOCKED frame was received" },
35 [QUIC_ST_STREAM_DATA_BLOCKED] = { .name = "quic_stream_data_blocked",
36 .desc = "Total number of times STREAMS_BLOCKED frame was received" },
37 [QUIC_ST_STREAMS_DATA_BLOCKED_BIDI] = { .name = "quic_streams_data_blocked_bidi",
38 .desc = "Total number of times STREAM_DATA_BLOCKED_BIDI frame was received" },
39 [QUIC_ST_STREAMS_DATA_BLOCKED_UNI] = { .name = "quic_streams_data_blocked_bidi",
40 .desc = "Total number of times STREAM_DATA_BLOCKED_UNI frame was received" },
41};
42
43struct quic_counters quic_counters;
44
45static void quic_fill_stats(void *data, struct field *stats)
46{
47 struct quic_counters *counters = data;
48
49 stats[QUIC_ST_DROPPED_PACKETS] = mkf_u64(FN_COUNTER, counters->dropped_pkt);
50 stats[QUIC_ST_RETRY_SENT] = mkf_u64(FN_COUNTER, counters->retry_sent);
51 stats[QUIC_ST_RETRY_VALIDATED] = mkf_u64(FN_COUNTER, counters->retry_validated);
52 stats[QUIC_ST_RETRY_ERRORS] = mkf_u64(FN_COUNTER, counters->retry_error);
53 stats[QUIC_ST_CONN_OPENINGS] = mkf_u64(FN_GAUGE, counters->conn_opening);
54 stats[QUIC_ST_HDSHK_FAILS] = mkf_u64(FN_COUNTER, counters->hdshk_fail);
55 /* Streams related counters */
56 stats[QUIC_ST_DATA_BLOCKED] = mkf_u64(FN_COUNTER, counters->data_blocked);
57 stats[QUIC_ST_STREAM_DATA_BLOCKED] = mkf_u64(FN_COUNTER, counters->stream_data_blocked);
58 stats[QUIC_ST_STREAMS_DATA_BLOCKED_BIDI] = mkf_u64(FN_COUNTER, counters->streams_data_blocked_bidi);
59 stats[QUIC_ST_STREAMS_DATA_BLOCKED_UNI] = mkf_u64(FN_COUNTER, counters->streams_data_blocked_uni);
60}
61
62struct stats_module quic_stats_module = {
63 .name = "quic",
64 .fill_stats = quic_fill_stats,
65 .stats = quic_stats,
66 .stats_count = QUIC_STATS_COUNT,
67 .counters = &quic_counters,
68 .counters_size = sizeof(quic_counters),
69 .domain_flags = MK_STATS_PROXY_DOMAIN(STATS_PX_CAP_FE),
70 .clearable = 1,
71};
72
73INITCALL1(STG_REGISTER, stats_register_module, &quic_stats_module);