概述
opentracing_instrumentation 是 Uber 开源的一套分布式Tracer Lib库。
可以在 Python 中快速注入 requests 等相关的 Trace 追踪任务。
QuickStart
from opentracing_instrumentation.client_hooks import requests as requests_hooksdef request_hook(response, span):"""# 注入 Response 信息"""if response.status_code >= 300:span.log_kv({"event": "send requests response code abnormal","response.status_code": str(response.status_code),"response.content": str(response.text),"request.headers": str(response.request.headers),"request.body": str(response.request.body)})request_patcher = requests_hooks.RequestsPatcher()request_patcher.set_response_handler_hook(response_handler_hook=request_hook)request_patcher.install_patches()
