blob: 8d59163a37be9b5b6796a043632827a9ed2aab37 [file] [log] [blame]
Miroslav Zagorac70230c62020-12-09 16:54:31 +01001/***
2 * Copyright 2020 HAProxy Technologies
3 *
4 * This file is part of the HAProxy OpenTracing filter.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20#ifndef _OPENTRACING_EVENT_H_
21#define _OPENTRACING_EVENT_H_
22
23/*
24 * This must be defined in order for macro FLT_OT_EVENT_DEFINES
25 * and structure flt_ot_event_data to have the correct contents.
26 */
27#define AN_REQ_NONE 0
28#define AN_REQ_CLIENT_SESS_START 0
29#define AN_REQ_SERVER_UNAVAILABLE 0
30#define AN_REQ_CLIENT_SESS_END 0
31#define AN_RES_SERVER_SESS_START 0
32#define AN_RES_SERVER_SESS_END 0
33#define SMP_VAL_FE_ 0
34#define SMP_VAL_BE_ 0
35
36/*
37 * Event names are selected to be somewhat compatible with the SPOE filter,
38 * from which the following names are taken:
39 * - on-client-session -> on-client-session-start
40 * - on-frontend-tcp-request
41 * - on-frontend-http-request
42 * - on-backend-tcp-request
43 * - on-backend-http-request
44 * - on-server-session -> on-server-session-start
45 * - on-tcp-response
46 * - on-http-response
47 *
48 * FLT_OT_EVENT_NONE is used as an index for 'ot-scope' sections that do not
49 * have an event defined. The 'ot-scope' sections thus defined can be used
50 * within the 'ot-group' section.
51 *
52 * A description of the macro arguments can be found in the structure
53 * flt_ot_event_data definition
54 */
55#define FLT_OT_EVENT_DEFINES \
56 FLT_OT_EVENT_DEF( NONE, REQ, , , 0, "") \
57 FLT_OT_EVENT_DEF( CLIENT_SESS_START, REQ, CON_ACC, , 1, "on-client-session-start") \
58 FLT_OT_EVENT_DEF( INSPECT_FE, REQ, REQ_CNT, , 1, "on-frontend-tcp-request") \
59 FLT_OT_EVENT_DEF( WAIT_HTTP, REQ, , , 1, "on-http-wait-request") \
60 FLT_OT_EVENT_DEF( HTTP_BODY, REQ, , , 1, "on-http-body-request") \
61 FLT_OT_EVENT_DEF( HTTP_PROCESS_FE, REQ, HRQ_HDR, , 1, "on-frontend-http-request") \
62 FLT_OT_EVENT_DEF( SWITCHING_RULES, REQ, , , 1, "on-switching-rules-request") \
63 FLT_OT_EVENT_DEF( INSPECT_BE, REQ, REQ_CNT, REQ_CNT, 1, "on-backend-tcp-request") \
64 FLT_OT_EVENT_DEF( HTTP_PROCESS_BE, REQ, HRQ_HDR, HRQ_HDR, 1, "on-backend-http-request") \
65/* FLT_OT_EVENT_DEF( HTTP_TARPIT, REQ, , , 1, "on-http-tarpit-request") */ \
66 FLT_OT_EVENT_DEF( SRV_RULES, REQ, , , 1, "on-process-server-rules-request") \
67 FLT_OT_EVENT_DEF( HTTP_INNER, REQ, , , 1, "on-http-process-request") \
68 FLT_OT_EVENT_DEF( PRST_RDP_COOKIE, REQ, , , 1, "on-tcp-rdp-cookie-request") \
69 FLT_OT_EVENT_DEF( STICKING_RULES, REQ, , , 1, "on-process-sticking-rules-request") \
70 FLT_OT_EVENT_DEF( CLIENT_SESS_END, REQ, , , 0, "on-client-session-end") \
71 FLT_OT_EVENT_DEF(SERVER_UNAVAILABLE, REQ, , , 0, "on-server-unavailable") \
72 \
73 FLT_OT_EVENT_DEF( SERVER_SESS_START, RES, , SRV_CON, 0, "on-server-session-start") \
74 FLT_OT_EVENT_DEF( INSPECT, RES, RES_CNT, RES_CNT, 0, "on-tcp-response") \
75 FLT_OT_EVENT_DEF( WAIT_HTTP, RES, , , 1, "on-http-wait-response") \
76 FLT_OT_EVENT_DEF( STORE_RULES, RES, , , 1, "on-process-store-rules-response") \
77 FLT_OT_EVENT_DEF( HTTP_PROCESS_BE, RES, HRS_HDR, HRS_HDR, 1, "on-http-response") \
78 FLT_OT_EVENT_DEF( SERVER_SESS_END, RES, , , 0, "on-server-session-end")
79
80enum FLT_OT_EVENT_enum {
81#define FLT_OT_EVENT_DEF(a,b,c,d,e,f) FLT_OT_EVENT_##b##_##a,
82 FLT_OT_EVENT_DEFINES
83 FLT_OT_EVENT_MAX
84#undef FLT_OT_EVENT_DEF
85};
86
87enum FLT_OT_EVENT_SAMPLE_enum {
88 FLT_OT_EVENT_SAMPLE_TAG = 0,
89 FLT_OT_EVENT_SAMPLE_LOG,
90 FLT_OT_EVENT_SAMPLE_BAGGAGE,
91};
92
93struct flt_ot_event_data {
94 uint an_bit; /* Used channel analyser. */
95 uint smp_opt_dir; /* Fetch direction (request/response). */
96 uint smp_val_fe; /* Valid FE fetch location. */
97 uint smp_val_be; /* Valid BE fetch location. */
98 bool flag_http_inject; /* Span context injection allowed. */
99 const char *name; /* Filter event name. */
100};
101
102struct flt_ot_conf_scope;
103
104
105extern const struct flt_ot_event_data flt_ot_event_data[FLT_OT_EVENT_MAX];
106
107
108int flt_ot_scope_run(struct stream *s, struct filter *f, struct channel *chn, struct flt_ot_conf_scope *conf_scope, const struct timespec *ts, uint dir, char **err);
109int flt_ot_event_run(struct stream *s, struct filter *f, struct channel *chn, int event, char **err);
110
111#endif /* _OPENTRACING_EVENT_H_ */
112
113/*
114 * Local variables:
115 * c-indent-level: 8
116 * c-basic-offset: 8
117 * End:
118 *
119 * vi: noexpandtab shiftwidth=8 tabstop=8
120 */