Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow filtering out metrics for pools with no connections #58

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

maartenberg
Copy link

This PR adds a new config option filter_empty_pools. When enabled, this option causes the exporter to not emit pool metrics for pools with no active connections (all values zero).

This filtering is useful when you use PgBouncer with temporary database users: currently PgBouncer will never "forget" a user and keep reporting an empty pool for each user it has ever seen (pgbouncer/pgbouncer#1085).
Enabling this filtering speeds up metric collection and (for us) greatly reduces the amount of emitted metrics.

The new config option is added to the README and has a unit test to verify it works as described.

This PR also contains two other changes:

  • Fixes a SyntaxWarning related to comparing strings using is by using == instead.
  • Slightly speeds up metrics filtering by making _filterMetricsByIncludeDatabases and _filterMetricsByExcludeDatabases return generators instead of lists.
    This way the exporter needs to loop over the results only once (when actually generating metrics), instead of once for every filter that's enabled.

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.

1 participant