mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-13 15:04:42 +00:00
70230c6484
This commit adds the OpenTracing filter (hereinafter we will use the abbreviated name 'the OT filter') to the contrib tree. The OT filter adds native support for using distributed tracing in HAProxy. This is enabled by sending an OpenTracing compliant request to one of the supported tracers; such as Datadog, Jaeger, Lightstep and Zipkin tracers. Please note: tracers are not listed by any preference, but alphabetically. The OT filter is a standard HAProxy filter, so what applies to others also applies to this one (of course, by that I mean what is described in the documentation, more precisely in the doc/internals/filters.txt file). The OT filter activation is done explicitly by specifying it in the HAProxy configuration. If this is not done, the OT filter in no way participates in the work of HAProxy. As for the impact on HAProxy speed, this is documented with several tests located in the test directory, and the result is found in the README-speed-* files. In short, the speed of operation depends on the way it is used and the complexity of the configuration, from an almost immeasurable impact to a significant deceleration (5x and more). I think that in some normal use the speed of HAProxy with the filter on will be quite satisfactory with a slowdown of less than 4%. The OT filter allows intensive use of ACLs, which can be defined anywhere in the configuration. Thus, it is possible to use the filter only for those connections that are of interest to us. More detailed documentation related to the operation, configuration and use of the filter can be found in the contrib/opentracing directory. To make the OpenTracing filter easier to configure and compile, several entries have been added to the Makefile. When running the make utility, it is possible to use several new arguments: USE_OT=1 : enable the OpenTracing filter OT_DEBUG=1 : compile the OpenTracing filter in debug mode OT_INC=path : force the include path to libopentracing-c-wrapper OT_LIB=path : force the lib path to libopentracing-c-wrapper OT_RUNPATH=1 : add libopentracing-c-wrapper RUNPATH to haproxy executable If USE_OT is set, then an additional Makefile from the contrib/opentracing directory is included in the compilation process.
110 lines
4.4 KiB
C
110 lines
4.4 KiB
C
/***
|
|
* Copyright 2020 HAProxy Technologies
|
|
*
|
|
* This file is part of the HAProxy OpenTracing filter.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
#ifndef _OPENTRACING_UTIL_H_
|
|
#define _OPENTRACING_UTIL_H_
|
|
|
|
#define HTTP_METH_STR_OPTIONS "OPTIONS"
|
|
#define HTTP_METH_STR_GET "GET"
|
|
#define HTTP_METH_STR_HEAD "HEAD"
|
|
#define HTTP_METH_STR_POST "POST"
|
|
#define HTTP_METH_STR_PUT "PUT"
|
|
#define HTTP_METH_STR_DELETE "DELETE"
|
|
#define HTTP_METH_STR_TRACE "TRACE"
|
|
#define HTTP_METH_STR_CONNECT "CONNECT"
|
|
|
|
/* Defined in include/haproxy/channel-t.h. */
|
|
#define FLT_OT_AN_DEFINES \
|
|
FLT_OT_AN_DEF(AN_REQ_INSPECT_FE) \
|
|
FLT_OT_AN_DEF(AN_REQ_WAIT_HTTP) \
|
|
FLT_OT_AN_DEF(AN_REQ_HTTP_BODY) \
|
|
FLT_OT_AN_DEF(AN_REQ_HTTP_PROCESS_FE) \
|
|
FLT_OT_AN_DEF(AN_REQ_SWITCHING_RULES) \
|
|
FLT_OT_AN_DEF(AN_REQ_INSPECT_BE) \
|
|
FLT_OT_AN_DEF(AN_REQ_HTTP_PROCESS_BE) \
|
|
FLT_OT_AN_DEF(AN_REQ_HTTP_TARPIT) \
|
|
FLT_OT_AN_DEF(AN_REQ_SRV_RULES) \
|
|
FLT_OT_AN_DEF(AN_REQ_HTTP_INNER) \
|
|
FLT_OT_AN_DEF(AN_REQ_PRST_RDP_COOKIE) \
|
|
FLT_OT_AN_DEF(AN_REQ_STICKING_RULES) \
|
|
FLT_OT_AN_DEF(AN_REQ_HTTP_XFER_BODY) \
|
|
FLT_OT_AN_DEF(AN_REQ_WAIT_CLI) \
|
|
FLT_OT_AN_DEF(AN_RES_INSPECT) \
|
|
FLT_OT_AN_DEF(AN_RES_WAIT_HTTP) \
|
|
FLT_OT_AN_DEF(AN_RES_STORE_RULES) \
|
|
FLT_OT_AN_DEF(AN_RES_HTTP_PROCESS_BE) \
|
|
FLT_OT_AN_DEF(AN_RES_HTTP_PROCESS_FE) \
|
|
FLT_OT_AN_DEF(AN_RES_HTTP_XFER_BODY) \
|
|
FLT_OT_AN_DEF(AN_RES_WAIT_CLI)
|
|
|
|
#define FLT_OT_PROXIES_LIST_START() \
|
|
do { \
|
|
struct flt_conf *fconf; \
|
|
struct proxy *px; \
|
|
\
|
|
for (px = proxies_list; px != NULL; px = px->next) \
|
|
list_for_each_entry(fconf, &(px->filter_configs), list) \
|
|
if (fconf->id == ot_flt_id) { \
|
|
struct flt_ot_conf *conf = fconf->conf;
|
|
#define FLT_OT_PROXIES_LIST_END() \
|
|
} \
|
|
} while (0)
|
|
|
|
#ifdef DEBUG_OT
|
|
# define FLT_OT_ARGS_DUMP() do { if (flt_ot_debug.level & (1 << 2)) flt_ot_args_dump(args); } while (0)
|
|
#else
|
|
# define FLT_OT_ARGS_DUMP() while (0)
|
|
#endif
|
|
|
|
|
|
#ifndef DEBUG_OT
|
|
# define flt_ot_filters_dump() while (0)
|
|
#else
|
|
void flt_ot_args_dump(char **args);
|
|
void flt_ot_filters_dump(void);
|
|
const char *flt_ot_chn_label(const struct channel *chn);
|
|
const char *flt_ot_pr_mode(const struct stream *s);
|
|
const char *flt_ot_stream_pos(const struct stream *s);
|
|
const char *flt_ot_type(const struct filter *f);
|
|
const char *flt_ot_analyzer(uint an_bit);
|
|
const char *flt_ot_str_hex(const void *data, size_t size);
|
|
const char *flt_ot_str_ctrl(const void *data, size_t size);
|
|
const char *flt_ot_list_debug(const struct list *head);
|
|
#endif
|
|
|
|
ssize_t flt_ot_chunk_add(struct buffer *chk, const void *src, size_t n, char **err);
|
|
int flt_ot_args_count(char **args);
|
|
void flt_ot_args_to_str(char **args, int idx, char **str);
|
|
double flt_ot_strtod(const char *nptr, double limit_min, double limit_max, char **err);
|
|
int64_t flt_ot_strtoll(const char *nptr, int64_t limit_min, int64_t limit_max, char **err);
|
|
int flt_ot_sample_to_str(const struct sample_data *data, char *value, size_t size, char **err);
|
|
int flt_ot_sample_to_value(const char *key, const struct sample_data *data, struct otc_value *value, char **err);
|
|
int flt_ot_sample_add(struct stream *s, uint dir, struct flt_ot_conf_sample *sample, struct flt_ot_scope_data *data, int type, char **err);
|
|
|
|
#endif /* _OPENTRACING_UTIL_H_ */
|
|
|
|
/*
|
|
* Local variables:
|
|
* c-indent-level: 8
|
|
* c-basic-offset: 8
|
|
* End:
|
|
*
|
|
* vi: noexpandtab shiftwidth=8 tabstop=8
|
|
*/
|