]> git.kaiwu.me - haproxy.git/commit
MEDIUM: otel: added memory pool and runtime scope layer
authorMiroslav Zagorac <mzagorac@haproxy.com>
Sun, 12 Apr 2026 07:47:18 +0000 (09:47 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Mon, 13 Apr 2026 07:23:26 +0000 (09:23 +0200)
commitf05a6735b15235c6ae9f60c4ce9a0f888aed7c02
tree51cb6ad5982b935f1e4f90027e0c2ca2945b3fec
parentc0fd39457fb11afa3c572274288571490e09cc0c
MEDIUM: otel: added memory pool and runtime scope layer

Added the memory pool management and the runtime scope layer that track
per-stream OTel spans and contexts during request processing.

The pool layer in pool.c manages HAProxy memory pools for the runtime
structures used by the filter: scope spans, scope contexts, runtime
contexts, and span contexts.  Each pool is conditionally compiled via
USE_POOL_OTEL_* macros defined in config.h and registered with
REGISTER_POOL().  The allocation functions (flt_otel_pool_alloc,
flt_otel_pool_strndup, flt_otel_pool_free) transparently fall back to
heap allocation when the corresponding pool is not enabled.  Trash buffer
helpers (flt_otel_trash_alloc, flt_otel_trash_free) provide scratch space
using either HAProxy's trash chunk pool or direct heap allocation.

The scope layer in scope.c implements the per-stream runtime state.  The
flt_otel_runtime_context structure is allocated when a stream starts and
holds the stream and filter references, hard-error/disabled/logging flags
copied from the instrumentation configuration, idle timeout state, a
generated UUID, and lists of active scope spans and extracted scope
contexts.  Scope spans (flt_otel_scope_span) carry the operation name,
fetch direction, the OTel span handle, and optional parent references
resolved from other spans or extracted contexts.  Scope contexts
(flt_otel_scope_context) hold an extracted span context obtained from
a carrier text map via the tracer.  The scope data structures
(flt_otel_scope_data) aggregate growable key-value arrays for attributes
and baggage, a linked list of named events with their own attribute
arrays, and a span status code with description, representing the
telemetry collected during a single event execution.
addons/otel/Makefile
addons/otel/include/config.h
addons/otel/include/include.h
addons/otel/include/pool.h [new file with mode: 0644]
addons/otel/include/scope.h [new file with mode: 0644]
addons/otel/src/pool.c [new file with mode: 0644]
addons/otel/src/scope.c [new file with mode: 0644]