Skip to content

PgBouncer: add prepared statement statistics - #24607

Open
maufl wants to merge 2 commits into
DataDog:masterfrom
maufl:felix/add-pgbouncer-prepared-statements-support
Open

PgBouncer: add prepared statement statistics#24607
maufl wants to merge 2 commits into
DataDog:masterfrom
maufl:felix/add-pgbouncer-prepared-statements-support

Conversation

@maufl

@maufl maufl commented Jul 20, 2026

Copy link
Copy Markdown

What does this PR do?

Adds prepared statement metrics to the PgBouncer check:

  • From SHOW STATS (PgBouncer 1.24+): pgbouncer.stats.{client_parse_count,server_parse_count,bind_count}_per_second and their avg_* gauges.
  • From SHOW CLIENTS / SHOW SERVERS (PgBouncer 1.21+): pgbouncer.clients.prepared_statements and pgbouncer.servers.prepared_statements, collected under the existing collect_per_client_metrics / collect_per_server_metrics options.

On older PgBouncer versions the columns are absent and the metrics are simply not emitted. Adds a 1.24 entry to the test matrix and version-gated e2e assertions; verified against live PgBouncer 1.24.1 (values populated in transaction pooling mode with max_prepared_statements > 0) and 1.23.1.

Motivation

PgBouncer supports protocol-level named prepared statements since 1.21 and exposes usage counters since 1.24; the integration didn't collect them, leaving prepared statement behavior through the pooler invisible.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Collect the prepared statement counters PgBouncer 1.24+ exposes in
SHOW STATS (client/server parse counts and bind counts) and the
prepared_statements column from SHOW CLIENTS and SHOW SERVERS (1.21+),
so prepared statement usage through the pooler is observable.

Co-Authored-By: Fable 5 (nono) <noreply@anthropic.com>
Co-Authored-By: Fable 5 (nono) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants