Skip to content

Commit ab94d6d

Browse files
authored
Merge branch 'main' into b/grpc-socket-context
2 parents cd9f3f0 + 27d5d93 commit ab94d6d

File tree

1 file changed

+18
-3
lines changed
  • instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg

1 file changed

+18
-3
lines changed

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,31 @@
1919
Usage
2020
-----
2121
22+
Start PostgreSQL:
23+
24+
::
25+
26+
docker run -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -e POSTGRES_DATABASE=database -p 5432:5432 postgres
27+
28+
Run instrumented code:
29+
2230
.. code-block:: python
2331
32+
import asyncio
2433
import asyncpg
2534
from opentelemetry.instrumentation.asyncpg import AsyncPGInstrumentor
2635
2736
# You can optionally pass a custom TracerProvider to AsyncPGInstrumentor.instrument()
2837
AsyncPGInstrumentor().instrument()
29-
conn = await asyncpg.connect(user='user', password='password',
30-
database='database', host='127.0.0.1')
31-
values = await conn.fetch('''SELECT 42;''')
38+
39+
async def main():
40+
conn = await asyncpg.connect(user='user', password='password')
41+
42+
await conn.fetch('''SELECT 42;''')
43+
44+
await conn.close()
45+
46+
asyncio.run(main())
3247
3348
API
3449
---

0 commit comments

Comments
 (0)