Redis par¶
La méthode logfire.instrument_redis() va créer un intervalle pour chaque commande exécutée par le client Redis.
Installation de¶
Installation de logfire avec redis extra:
{{ install_logfire(extras=['redis']) }}
Utilisation de¶
Regardons l'exemple minimal suivant:
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())
Le paramètre de mot-clé de logfire.instrument_redis() est passé à la méthode RedisInstrumentor().instrument() du paquet OpenTelemetry Redis Instrumentation,Veuillez lire plus ici.
本文总阅读量次