Die Redis¶
Die logfire.instrument_redis() -Methode erzeugt eine Spanne für jeden Befehl , der vom Redis-Client ausgeführt wird .
Installiert¶
Verwenden redis zusätzliche Installation logfire:
{{ install_logfire(extras=['redis']) }}
Verwendung¶
Sehen wir uns das kleinste Beispiel an :
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())
Die Schlüsselwortargumente von logfire.instrument_redis() werden an die RedisInstrumentor().instrument()-Methode des OpenTelemetry Redis Instrumentation-Pakets übergeben , das von hier für weitere Informationen zu zur Verfügung gestellt wird .
[ Rezi ] :https://redis.readthedocs.io/en/stable/ [ Opentelemetry-Redis ] :https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/redis/redis.html
本文总阅读量次