Skip to content

Commit 0498d3e

Browse files
committed
Add message and example to Redis Usage section
1 parent 0765def commit 0498d3e

File tree

1 file changed

+16
-0
lines changed
  • instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis

1 file changed

+16
-0
lines changed

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

+16
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@
3838
client = redis.StrictRedis(host="localhost", port=6379)
3939
client.get("my-key")
4040
41+
Async Redis clients (i.e. redis.asyncio.Redis) are also instrumented in the same way:
42+
43+
.. code:: python
44+
45+
from opentelemetry.instrumentation.redis import RedisInstrumentor
46+
import redis.asyncio
47+
48+
49+
# Instrument redis
50+
RedisInstrumentor().instrument()
51+
52+
# This will report a span with the default settings
53+
async def redis_get():
54+
client = redis.asyncio.Redis(host="localhost", port=6379)
55+
await client.get("my-key")
56+
4157
The `instrument` method accepts the following keyword args:
4258
4359
tracer_provider (TracerProvider) - an optional tracer provider

0 commit comments

Comments
 (0)