Skip to content

feat(asyncpg): add capture_connection_cleanup option to silence pool cleanup spans#4373

Open
RiyaChaturvedi37 wants to merge 5 commits intoopen-telemetry:mainfrom
RiyaChaturvedi37:fix/asyncpg-silence-cleanup
Open

feat(asyncpg): add capture_connection_cleanup option to silence pool cleanup spans#4373
RiyaChaturvedi37 wants to merge 5 commits intoopen-telemetry:mainfrom
RiyaChaturvedi37:fix/asyncpg-silence-cleanup

Conversation

@RiyaChaturvedi37
Copy link
Copy Markdown
Contributor

Closes #4264

Description

Adds a new capture_connection_cleanup option to AsyncPGInstrumentor
to allow silencing connection cleanup spans when using a pool.

When using a connection pool, asyncpg executes cleanup statements after
each invocation:

  • SELECT pg_advisory_unlock_all()
  • CLOSE ALL
  • UNLISTEN *
  • RESET ALL

These can pollute traces, especially for tasks that periodically query
the database. This option allows users to silence these spans.

Usage:

AsyncPGInstrumentor(capture_connection_cleanup=False).instrument()

The option defaults to True to maintain backward compatibility.

Type of change

  • New feature (non-breaking change which adds functionality)

@RiyaChaturvedi37 RiyaChaturvedi37 force-pushed the fix/asyncpg-silence-cleanup branch from 5547d9b to 73f9258 Compare March 28, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

asyncpg: ability to silence connection cleanup when using a pool

1 participant