Skip to content

Skip zlib metrics in Prometheus exporter when built with libslz#22

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/improve-prometheus-metrics
Draft

Skip zlib metrics in Prometheus exporter when built with libslz#22
Copilot wants to merge 2 commits intomasterfrom
copilot/improve-prometheus-metrics

Conversation

Copy link

Copilot AI commented Feb 6, 2026

When HAProxy is built with libslz instead of zlib, the Prometheus exporter exports haproxy_process_current_zlib_memory and haproxy_process_max_zlib_memory metrics with NaN values, as these metrics are only populated when USE_ZLIB is defined.

Changes

  • Added preprocessor guard in promex_dump_global_metrics() to skip ST_I_INF_ZLIB_MEM_USAGE and ST_I_INF_MAX_ZLIB_MEM_USAGE when USE_ZLIB is not defined
  • Metrics are now conditionally exported based on actual compression backend in use
#ifndef USE_ZLIB
    case ST_I_INF_ZLIB_MEM_USAGE:
    case ST_I_INF_MAX_ZLIB_MEM_USAGE:
        /* Skip zlib metrics when built with libslz */
        continue;
#endif

This aligns the Prometheus exporter behavior with the stats subsystem, which already conditionally populates these fields under #ifdef USE_ZLIB.

Original prompt

This section details on the original issue you should resolve

<issue_title>improve prometheus metrics</issue_title>
<issue_description>when haproxy is built with libslz (not zlib), the following metrics are irrelevant

# HELP haproxy_process_current_zlib_memory Amount of memory currently used by HTTP compression on the current worker process (in bytes)
# TYPE haproxy_process_current_zlib_memory gauge
haproxy_process_current_zlib_memory NaN
# HELP haproxy_process_max_zlib_memory Limit on the amount of memory used by HTTP compression above which it is automatically disabled (in bytes, see global.maxzlibmem)
# TYPE haproxy_process_max_zlib_memory gauge
haproxy_process_max_zlib_memory NaN

we need not to add that metric if haproxy is built with slz</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

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
Copilot AI requested a review from chipitsine February 6, 2026 19:45
@chipitsine chipitsine force-pushed the master branch 2 times, most recently from a8bc83b to 2a07dc9 Compare February 7, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

improve prometheus metrics

2 participants

Comments