Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/objects/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@


if DB_POOL_ENABLED:
# FIXME Workaround for https://github.com/elastic/apm-agent-python/issues/2094
# apm-agent-python does not instrument ConnectionPool yet
import psycopg

class WrapperConnectionClass(psycopg.Connection):
@classmethod
def connect(
cls,
conninfo: str = "",
**kwargs,
) -> "psycopg.Connection[psycopg.rows.TupleRow]":
return psycopg.connect(conninfo, **kwargs)

DATABASES["default"]["OPTIONS"] = {
"pool": {
"min_size": DB_POOL_MIN_SIZE,
Expand All @@ -138,6 +151,7 @@
"max_idle": DB_POOL_MAX_IDLE,
"reconnect_timeout": DB_POOL_RECONNECT_TIMEOUT,
"num_workers": DB_POOL_NUM_WORKERS,
"connection_class": WrapperConnectionClass,
}
}

Expand Down
Loading