Skip to content

Commit 8e8b759

Browse files
Document psycopg(2) instrument_connection
1 parent 58daeb6 commit 8e8b759

File tree

2 files changed

+24
-0
lines changed
  • instrumentation
    • opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2
    • opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg

2 files changed

+24
-0
lines changed

instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@ def instrument_connection(
205205
enable_commenter: bool = False,
206206
commenter_options: dict = None,
207207
):
208+
"""Enable instrumentation of a Psycopg connection.
209+
210+
Args:
211+
connection: The connection to instrument.
212+
tracer_provider: Optional tracer provider to use. If omitted
213+
the current globally configured one is used.
214+
enable_commenter: Optional flag to enable/disable sqlcommenter (default disabled).
215+
commenter_options: Optional configurations for tags to be appended at the sql query.
216+
217+
Returns:
218+
An instrumented connection.
219+
"""
208220
if not hasattr(connection, "_is_instrumented_by_opentelemetry"):
209221
connection._is_instrumented_by_opentelemetry = False
210222

instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,18 @@ def instrument_connection(
169169
enable_commenter: bool = False,
170170
commenter_options: dict = None,
171171
):
172+
"""Enable instrumentation of a Psycopg2 connection.
173+
174+
Args:
175+
connection: The connection to instrument.
176+
tracer_provider: Optional tracer provider to use. If omitted
177+
the current globally configured one is used.
178+
enable_commenter: Optional flag to enable/disable sqlcommenter (default disabled).
179+
commenter_options: Optional configurations for tags to be appended at the sql query.
180+
181+
Returns:
182+
An instrumented connection.
183+
"""
172184
if not hasattr(connection, "_is_instrumented_by_opentelemetry"):
173185
connection._is_instrumented_by_opentelemetry = False
174186

0 commit comments

Comments
 (0)