레디스¶
logfire.instrument_redis() 방법은 다음과 같습니다. 레디스 클라이언트 측에서 실행하는 각 명령은 스팬을 생성합니다.
설치¶
redis 엑스트라를 사용하여 logfire 를 설치하십시오.
{{ install_logfire(extras=['redis']) }}
사용법¶
다음 최소 예를 살펴보겠습니다.
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() 에 대한 키워드 인수는 OpenTelemetry Redis 계측 패키지의 RedisInstrumentor().instrument() 메서드로 전달됩니다.여기에서에 대해 자세히 알아보십시오.
本文总阅读量次