diff --git a/instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg/__init__.py b/instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg/__init__.py index 88ae8be0d3..ad8632b88a 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg/__init__.py @@ -205,6 +205,18 @@ def instrument_connection( enable_commenter: bool = False, commenter_options: dict = None, ): + """Enable instrumentation of a Psycopg connection. + + Args: + connection: The connection to instrument. + tracer_provider: Optional tracer provider to use. If omitted + the current globally configured one is used. + enable_commenter: Optional flag to enable/disable sqlcommenter (default disabled). + commenter_options: Optional configurations for tags to be appended at the sql query. + + Returns: + An instrumented connection. + """ if not hasattr(connection, "_is_instrumented_by_opentelemetry"): connection._is_instrumented_by_opentelemetry = False diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py index 9db5700256..9235a994bf 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py @@ -169,6 +169,18 @@ def instrument_connection( enable_commenter: bool = False, commenter_options: dict = None, ): + """Enable instrumentation of a Psycopg2 connection. + + Args: + connection: The connection to instrument. + tracer_provider: Optional tracer provider to use. If omitted + the current globally configured one is used. + enable_commenter: Optional flag to enable/disable sqlcommenter (default disabled). + commenter_options: Optional configurations for tags to be appended at the sql query. + + Returns: + An instrumented connection. + """ if not hasattr(connection, "_is_instrumented_by_opentelemetry"): connection._is_instrumented_by_opentelemetry = False