Skip zlib metrics in Prometheus exporter when built with libslz#22
Draft
Skip zlib metrics in Prometheus exporter when built with libslz#22
Conversation
Default proxies validation occurs during post-parsing. The objective is to report any tcp/http-rules which could not behave as expected. Previously, this was performed while looping over standard proxies list, when such proxy is referencing a default instance. This was enough as only named referenced proxies were kept after parsing. However, this is not the case anymore in the context of dynamic backends creation at runtime. As such, this patch now performs validation on every named defaults outside of the standard proxies list loop. This should not cause any behavior difference, as defaults are validated without using the proxy which relies on it. Along with this change, PR_FL_READY proxy flag is now removed. Its usage was only really needed for defaults, to avoid validating a same instance multiple times. With the validation of defaults in their own loop, it is now redundant.
A lot of proxies initialization code is delayed on post-parsing stage, as it depends on the configuration fully parsed. This is performed via a loop on proxies_list. Extract this code in a dedicated function proxy_finalize(). This patch will be useful for dynamic backends creation. Note that for the moment the code has been extracted as-is. With each new features, some init code was added there. This has become a giant loop with no real ordering. A future patch may provide some cleanup in order to reorganize this.
If a proxy is referencing a defaults instance, some checks must be performed to ensure that inheritance will be compatible. Refcount of the defaults instance may also be incremented if some settings cannot be copied. This operation is performed when parsing a new proxy of defaults section which references a defaults, either implicitely or explicitely. This patch extracts this code into a dedicated function named proxy_ref_defaults(). This in turn may call defaults_px_ref() (previously called proxy_ref_defaults()) to increment its refcount. The objective of this patch is to be able to reuse defaults inheritance validation for dynamic backends created at runtime, outside of the parsing code.
Define a new utility function str_to_proxy_mode() which is able to convert a string into the corresponding proxy mode if possible. This new function is used for the parsing of "mode" configuration proxy keyword. This patch will be reused for dynamic backend implementation, in order to parse a similar "mode" argument via a CLI handler.
Move backend compatibility checks performed during 'add server' in a dedicated function be_supports_dynamic_srv(). This should simplify addition of future restriction. This function will be reused when implementing backend creation at runtime.
Define a basic CLI handler for "add backend". For now, this handler only performs a parsing of the name argument and return an error if a duplicate already exists. It runs under thread isolation, to guarantee thread safety during the proxy creation. This feature is considered in development. CLI command requires to set experimental-mode.
Add an optional "mode" argument to "add backend" CLI command. This argument allows to specify if the backend is in TCP or HTTP mode. By default, it is mandatory, unless the inherited default proxy already explicitely specifies the mode. To differentiate if TCP mode is implicit or explicit, a new proxy flag PR_FL_DEF_EXPLICIT_MODE is defined. It is set for every defaults instances which explicitely defined their mode.
Defines an extra optional GUID argument for "add backend" command. This can be useful as it is not possible to define it via a default proxy instance.
This commits completes "add backend" handler with some checks performed on the specified default proxy instance. These are additional checks outside of the already existing inheritance rules, specific to dynamic backends. For now, a default proxy is considered not compatible if it is not in mode TCP/HTTP. Also, a default proxy is rejected if it references HTTP errors. This limitation may be lifted in the future, when HTTP errors are partiallay reworked.
Implement the required operations for "add backend" handler. This requires a new proxy allocation, settings copy from the specified default instance and proxy config finalization. All handlers registered via REGISTER_POST_PROXY_CHECK() are also called on the newly created instance. If no error were encountered, the newly created proxy is finally attached in the proxies list.
Implement proxy ID generation for dynamic backends. This is performed through the already function existing proxy_get_next_id(). As an optimization, lookup will performed starting from a global variable <dynpx_next_id>. It is initialized to the greatest ID assigned after parsing, and updated each time a backend instance is created. When backend deletion will be implemented, it could be lowered to the newly available slot.
Add a new regtests to validate backend creation at runtime. A server is then added and requests made to validate the newly created instance before (with force-be-switch) and after publishing.
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove irrelevant metrics for slz build in Prometheus
Skip zlib metrics in Prometheus exporter when built with libslz
Feb 6, 2026
a8bc83b to
2a07dc9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When HAProxy is built with libslz instead of zlib, the Prometheus exporter exports
haproxy_process_current_zlib_memoryandhaproxy_process_max_zlib_memorymetrics with NaN values, as these metrics are only populated whenUSE_ZLIBis defined.Changes
promex_dump_global_metrics()to skipST_I_INF_ZLIB_MEM_USAGEandST_I_INF_MAX_ZLIB_MEM_USAGEwhenUSE_ZLIBis not definedThis aligns the Prometheus exporter behavior with the stats subsystem, which already conditionally populates these fields under
#ifdef USE_ZLIB.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.