From 8e8b7597dfc0fb9a6e70333f52c8e5361fa48967 Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Fri, 6 Dec 2024 18:22:29 -0800 Subject: [PATCH] Document psycopg(2) instrument_connection --- .../instrumentation/psycopg/__init__.py | 12 ++++++++++++ .../instrumentation/psycopg2/__init__.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) 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