Skip to content

Commit

Permalink
separate out instrument_connection() in aiopg doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
beijiez committed Dec 17, 2024
1 parent 8adb093 commit dd5cd5d
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import aiopg
from opentelemetry.instrumentation.aiopg import AiopgInstrumentor
# Call instrument() to wrap all database connections
AiopgInstrumentor().instrument()
cnx = await aiopg.connect(database='Database')
Expand All @@ -42,11 +42,18 @@
cursor.close()
cnx.close()
cnx = AiopgInstrumentor().instrument_connection(cnx)
cursor = await cnx.cursor()
.. code-block:: python
import aiopg
from opentelemetry.instrumentation.aiopg import AiopgInstrumentor
# Alternatively, use instrument_connection for an individual connection
cnx = await aiopg.connect(database='Database')
instrumented_cnx = AiopgInstrumentor().instrument_connection(cnx)
cursor = await instrumented_cnx.cursor()
await cursor.execute("INSERT INTO test (testField) VALUES (123)")
cursor.close()
cnx.close()
instrumented_cnx.close()
API
---
Expand Down

0 comments on commit dd5cd5d

Please sign in to comment.