mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-04 12:41:00 +02:00
Introduced an alternative variable scanning strategy that directly walked
the CEB tree of HAProxy's variable store instead of maintaining a separate
tracking buffer.
The Makefile auto-detected whether struct var carried a "name" member
by inspecting include/haproxy/vars-t.h and conditionally defined
USE_OTEL_VARS_NAME. When enabled, the tracking buffer (flt_otel_ctx) and
its callback type were compiled out and replaced by direct tree walks.
flt_otel_vars_unset() walked the CEB tree for the resolved scope, removed
every variable whose normalized name matched the given prefix followed by
a dot, and adjusted the variable accounting. flt_otel_vars_get()
performed the same prefix scan under a read lock, denormalized each
matching variable name back to its original OTel form, and assembled the
results into an otelc_text_map.
A helper flt_otel_vars_get_scope() was added to resolve scope name strings
("txn", "sess", "proc", "req", "res") to the corresponding HAProxy
variable store. The set path skipped the tracking buffer update when
prefix scanning was available.
53 lines
1.8 KiB
C
53 lines
1.8 KiB
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
|
|
#ifndef _OTEL_VARS_H_
|
|
#define _OTEL_VARS_H_
|
|
|
|
#define FLT_OTEL_VARS_SCOPE "txn"
|
|
#define FLT_OTEL_VAR_CHAR_DASH 'D'
|
|
#define FLT_OTEL_VAR_CHAR_SPACE 'S'
|
|
|
|
#ifndef USE_OTEL_VARS_NAME
|
|
# define FLT_OTEL_VAR_CTX_SIZE int8_t
|
|
|
|
/* Context buffer for storing a single variable value during iteration. */
|
|
struct flt_otel_ctx {
|
|
char value[BUFSIZ]; /* Variable value string. */
|
|
int value_len; /* Length of the value string. */
|
|
};
|
|
|
|
/* Callback type invoked for each context variable during iteration. */
|
|
typedef int (*flt_otel_ctx_loop_cb)(struct sample *, size_t, const char *, const char *, const char *, FLT_OTEL_VAR_CTX_SIZE, char **, void *);
|
|
#endif /* !USE_OTEL_VARS_NAME */
|
|
|
|
|
|
#ifndef DEBUG_OTEL
|
|
# define flt_otel_vars_dump(...) while (0)
|
|
#else
|
|
/* Dump all OTel-related variables for a stream. */
|
|
void flt_otel_vars_dump(struct stream *s);
|
|
#endif
|
|
|
|
/* Register a HAProxy variable for OTel context storage. */
|
|
int flt_otel_var_register(const char *scope, const char *prefix, const char *name, char **err);
|
|
|
|
/* Set an OTel context variable on a stream. */
|
|
int flt_otel_var_set(struct stream *s, const char *scope, const char *prefix, const char *name, const char *value, uint opt, char **err);
|
|
|
|
/* Unset all OTel context variables matching a prefix on a stream. */
|
|
int flt_otel_vars_unset(struct stream *s, const char *scope, const char *prefix, uint opt, char **err);
|
|
|
|
/* Retrieve all OTel context variables matching a prefix into a text map. */
|
|
struct otelc_text_map *flt_otel_vars_get(struct stream *s, const char *scope, const char *prefix, uint opt, char **err);
|
|
|
|
#endif /* _OTEL_VARS_H_ */
|
|
|
|
/*
|
|
* Local variables:
|
|
* c-indent-level: 8
|
|
* c-basic-offset: 8
|
|
* End:
|
|
*
|
|
* vi: noexpandtab shiftwidth=8 tabstop=8
|
|
*/
|