elasticapm/instrumentation/packages/psycopg.py [33:51]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ConnectionProxy,
    CursorProxy,
    DbApi2Instrumentation,
    extract_signature,
)
from elasticapm.instrumentation.packages.psycopg2 import get_destination_info
from elasticapm.traces import capture_span


class PGCursorProxy(CursorProxy):
    provider_name = "postgresql"

    def _bake_sql(self, sql):
        # If this is a Composable object, use its `as_string` method.
        # See https://www.psycopg.org/psycopg3/docs/api/sql.html
        if hasattr(sql, "as_string"):
            sql = sql.as_string(self.__wrapped__)
        # If the sql string is already a byte string, we need to decode it using the connection encoding
        if isinstance(sql, bytes):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



elasticapm/instrumentation/packages/psycopg2.py [35:55]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ConnectionProxy,
    CursorProxy,
    DbApi2Instrumentation,
    extract_signature,
)
from elasticapm.traces import capture_span
from elasticapm.utils import default_ports


class PGCursorProxy(CursorProxy):
    provider_name = "postgresql"

    def _bake_sql(self, sql):
        from psycopg2 import extensions as psycopg2_extensions

        # if this is a Composable object, use its `as_string` method
        # see http://initd.org/psycopg/docs/sql.html
        if hasattr(sql, "as_string"):
            sql = sql.as_string(self.__wrapped__)
        # if the sql string is already a byte string, we need to decode it using the connection encoding
        if isinstance(sql, bytes):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



