mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-22 23:02:34 -04:00
Added HAProxy CLI commands that allow runtime inspection and modification of OTel filter settings without requiring a configuration reload. The new cli.c module registers CLI keywords under the "otel" prefix and implements the following commands: flt_otel_cli_parse_status() displays a comprehensive status report of all OTel filter instances including filter ID, proxy, disabled state, hard-error mode, logging state, rate limit, analyzer bits, and SDK diagnostic message count; flt_otel_cli_parse_disabled() enables or disables filtering across all instances; flt_otel_cli_parse_option() toggles the hard-error mode that controls whether errors disable the filter for a stream or are silently ignored; flt_otel_cli_parse_logging() manages the logging state with support for off, on, and dontlog-normal modes; flt_otel_cli_parse_rate() adjusts the sampling rate limit as a floating-point percentage; and flt_otel_cli_parse_debug() sets the debug verbosity level in debug builds. All modifications are applied atomically across every OTel filter instance in every proxy. The CLI initialization is called from flt_otel_ops_init() during filter startup via flt_otel_cli_init(), which registers the keyword table through cli_register_kw(). Supporting changes include the FLT_OTEL_U32_FLOAT macro for converting the internal uint32_t rate representation to a human-readable percentage, the FLT_OTEL_PROXIES_LIST_START/END iteration macros for traversing all OTel filter instances across the proxy list, and flt_otel_filters_dump() for debug logging of filter instances.
95 lines
3.5 KiB
C
95 lines
3.5 KiB
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
|
|
#ifndef _OTEL_UTIL_H_
|
|
#define _OTEL_UTIL_H_
|
|
|
|
#define FLT_OTEL_HTTP_METH_DEFINES \
|
|
FLT_OTEL_HTTP_METH_DEF(OPTIONS) \
|
|
FLT_OTEL_HTTP_METH_DEF(GET) \
|
|
FLT_OTEL_HTTP_METH_DEF(HEAD) \
|
|
FLT_OTEL_HTTP_METH_DEF(POST) \
|
|
FLT_OTEL_HTTP_METH_DEF(PUT) \
|
|
FLT_OTEL_HTTP_METH_DEF(DELETE) \
|
|
FLT_OTEL_HTTP_METH_DEF(TRACE) \
|
|
FLT_OTEL_HTTP_METH_DEF(CONNECT)
|
|
|
|
/* Iterate over all OTel filter configurations across all proxies. */
|
|
#define FLT_OTEL_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 == otel_flt_id) { \
|
|
struct flt_otel_conf *conf = fconf->conf;
|
|
#define FLT_OTEL_PROXIES_LIST_END() \
|
|
} \
|
|
} while (0)
|
|
|
|
#ifdef DEBUG_OTEL
|
|
# define FLT_OTEL_ARGS_DUMP() do { if (otelc_dbg_level & (1 << OTELC_DBG_LEVEL_LOG)) flt_otel_args_dump((const char **)args); } while (0)
|
|
#else
|
|
# define FLT_OTEL_ARGS_DUMP() while (0)
|
|
#endif
|
|
|
|
|
|
#ifndef DEBUG_OTEL
|
|
# define flt_otel_filters_dump() while (0)
|
|
#else
|
|
/* Dump configuration arguments for debugging. */
|
|
void flt_otel_args_dump(const char **args);
|
|
|
|
/* Dump all OTel filter configurations across all proxies. */
|
|
void flt_otel_filters_dump(void);
|
|
|
|
/* Return a label string identifying a channel direction. */
|
|
const char *flt_otel_chn_label(const struct channel *chn);
|
|
|
|
/* Return the proxy mode string for a stream. */
|
|
const char *flt_otel_pr_mode(const struct stream *s);
|
|
|
|
/* Return the stream processing position as a string. */
|
|
const char *flt_otel_stream_pos(const struct stream *s);
|
|
|
|
/* Return the filter type string for a filter instance. */
|
|
const char *flt_otel_type(const struct filter *f);
|
|
|
|
/* Return the analyzer name string for an analyzer bit. */
|
|
const char *flt_otel_analyzer(uint an_bit);
|
|
|
|
/* Dump a linked list of configuration items as a string. */
|
|
const char *flt_otel_list_dump(const struct list *head);
|
|
#endif
|
|
|
|
/* Count the number of non-NULL arguments in an argument array. */
|
|
int flt_otel_args_count(const char **args);
|
|
|
|
/* Concatenate argument array elements into a single string. */
|
|
int flt_otel_args_concat(const char **args, int idx, int n, char **str);
|
|
|
|
/* Parse a string to double with range validation. */
|
|
bool flt_otel_strtod(const char *nptr, double *value, double limit_min, double limit_max, char **err);
|
|
|
|
/* Parse a string to int64_t with range validation. */
|
|
bool flt_otel_strtoll(const char *nptr, int64_t *value, int64_t limit_min, int64_t limit_max, char **err);
|
|
|
|
/* Convert sample data to a string representation. */
|
|
int flt_otel_sample_to_str(const struct sample_data *data, char *value, size_t size, char **err);
|
|
|
|
/* Convert sample data to an OTel value. */
|
|
int flt_otel_sample_to_value(const char *key, const struct sample_data *data, struct otelc_value *value, char **err);
|
|
|
|
/* Evaluate a sample expression and add the result to scope data. */
|
|
int flt_otel_sample_add(struct stream *s, uint dir, struct flt_otel_conf_sample *sample, struct flt_otel_scope_data *data, int type, char **err);
|
|
|
|
#endif /* _OTEL_UTIL_H_ */
|
|
|
|
/*
|
|
* Local variables:
|
|
* c-indent-level: 8
|
|
* c-basic-offset: 8
|
|
* End:
|
|
*
|
|
* vi: noexpandtab shiftwidth=8 tabstop=8
|
|
*/
|