File tree 1 file changed +11
-4
lines changed
instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 25
25
26
26
import aiopg
27
27
from opentelemetry.instrumentation.aiopg import AiopgInstrumentor
28
-
28
+ # Call instrument() to wrap all database connections
29
29
AiopgInstrumentor().instrument()
30
30
31
31
cnx = await aiopg.connect(database='Database')
42
42
cursor.close()
43
43
cnx.close()
44
44
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()
47
54
await cursor.execute("INSERT INTO test (testField) VALUES (123)")
48
55
cursor.close()
49
- cnx .close()
56
+ instrumented_cnx .close()
50
57
51
58
API
52
59
---
You can’t perform that action at this time.
0 commit comments