Skip to content

Commit

Permalink
Document psycopg(2) instrument_connection
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Dec 7, 2024
1 parent 58daeb6 commit 8e8b759
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8e8b759

Please sign in to comment.