Skip to content

Commit dd5cd5d

Browse files
committed
separate out instrument_connection() in aiopg doc strings
1 parent 8adb093 commit dd5cd5d

File tree

1 file changed

+11
-4
lines changed
  • instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg

1 file changed

+11
-4
lines changed

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

+11-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
2626
import aiopg
2727
from opentelemetry.instrumentation.aiopg import AiopgInstrumentor
28-
28+
# Call instrument() to wrap all database connections
2929
AiopgInstrumentor().instrument()
3030
3131
cnx = await aiopg.connect(database='Database')
@@ -42,11 +42,18 @@
4242
cursor.close()
4343
cnx.close()
4444
45-
cnx = AiopgInstrumentor().instrument_connection(cnx)
46-
cursor = await cnx.cursor()
45+
.. code-block:: python
46+
47+
import aiopg
48+
from opentelemetry.instrumentation.aiopg import AiopgInstrumentor
49+
50+
# Alternatively, use instrument_connection for an individual connection
51+
cnx = await aiopg.connect(database='Database')
52+
instrumented_cnx = AiopgInstrumentor().instrument_connection(cnx)
53+
cursor = await instrumented_cnx.cursor()
4754
await cursor.execute("INSERT INTO test (testField) VALUES (123)")
4855
cursor.close()
49-
cnx.close()
56+
instrumented_cnx.close()
5057
5158
API
5259
---

0 commit comments

Comments
 (0)