Skip to content

Redis

The logfire.instrument_redis() method creates a span for each command executed by the Redis client.

install

Install logfire using redis extra:

{{ install_logfire(extras=['redis']) }}

usage

Let's look at the smallest example below:

main.py
import logfire
import redis


logfire.configure()
logfire.instrument_redis()

# This will report a span with the default settings
client = redis.StrictRedis(host="localhost", port=6379)
client.get("my-key")

# This will report a span with the default settings
async def main():
    client = redis.asyncio.Redis(host="localhost", port=6379)
    await client.get("my-key")

if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

logfire.instrument_redis() Keyword parameters are passed to OpenTelemetry Redis Instrumentation package RedisInstrumentor().instrument() Methods,replace this text with Read more about it.


本文总阅读量次