diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py index 92f966e4cb..735f011c08 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py @@ -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') @@ -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 ---