Skip to content

asyncpg: ability to silence connection cleanup when using a pool #4264

@takeda

Description

@takeda

What problem do you want to solve?

So whenever a pool is being used, uppon completion, asyncpg executes following statement:

SELECT pg_advisory_unlock_all();\nCLOSE ALL;\nUNLISTEN *;\nRESET ALL;

to cleanup the connection's state so it can be used for another request. I'm wondering if there's a way to exclude those from being instrumented as they can pollute traces (especially if there's a task that periodically queries the database).

Describe the solution you'd like

Perhaps additional option next to capture_parameters in the constructor? For example:

AsyncPGInstrumentor(capture_parameters=True,capture_connection_cleanup=False).instrument()

capture_connection_cleanup could default to True

Describe alternatives you've considered

I was trying to add custom sampler and reading db.statement from attributes, but at that moment the attributes are not available yet.

Additional Context

No response

Would you like to implement a fix?

None

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions