File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 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')
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
5158API
5259---
You can’t perform that action at this time.
0 commit comments