OpenTelemetry asyncio 仪表盘
项目描述
AsyncioInstrumentor: 跟踪由 Asyncio 库发出的请求
opentelemetry-instrumentation-asyncio 软件包允许跟踪 asyncio 应用程序。它还包括协程和未来的持续时间及计数的度量。即使协程没有被跟踪,也会生成度量。
设置您想要跟踪的协程的名称。
export OTEL_PYTHON_ASYNCIO_COROUTINE_NAMES_TO_TRACE=coro_name,coro_name2,coro_name3
如果您想跟踪使用 asyncio 的 to_thread 函数执行的特定阻塞函数,请在 OTEL_PYTHON_ASYNCIO_TO_THREAD_FUNCTION_NAMES_TO_TRACE 中设置函数的名称。
export OTEL_PYTHON_ASYNCIO_TO_THREAD_FUNCTION_NAMES_TO_TRACE=func_name,func_name2,func_name3
您可以通过 OTEL_PYTHON_ASYNCIO_FUTURE_TRACE_ENABLED 启用未来的跟踪
export OTEL_PYTHON_ASYNCIO_FUTURE_TRACE_ENABLED=true
运行已配置的应用程序
1. 协程
# export OTEL_PYTHON_ASYNCIO_COROUTINE_NAMES_TO_TRACE=sleep
import asyncio
from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor
AsyncioInstrumentor().instrument()
async def main():
await asyncio.create_task(asyncio.sleep(0.1))
asyncio.run(main())
2. 未来
# export OTEL_PYTHON_ASYNCIO_FUTURE_TRACE_ENABLED=true
loop = asyncio.get_event_loop()
future = asyncio.Future()
future.set_result(1)
task = asyncio.ensure_future(future)
loop.run_until_complete(task)
3. to_thread
# export OTEL_PYTHON_ASYNCIO_TO_THREAD_FUNCTION_NAMES_TO_TRACE=func
import asyncio
from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor
AsyncioInstrumentor().instrument()
async def main():
await asyncio.to_thread(func)
def func():
pass
asyncio.run(main())
asyncio 度量类型
asyncio.process.duration (秒) - asyncio 进程的持续时间
asyncio.process.count (计数) - asyncio 进程的数量
API
安装
pip install opentelemetry-instrumentation-asyncio
参考
项目详情
关闭
opentelemetry_instrumentation_asyncio-0.48b0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | f932eb49cb6050eb85905f600124e06868d4712b117ad7ac7c0af048f03b8fd4 |
|
MD5 | 00169e7797e8bfccfd92f0ace50714b5 |
|
BLAKE2b-256 | 2dcbf7232878b8ce2ff5bf8f1801c691d596dc7292e62ae00488f357874f475c |
关闭
opentelemetry_instrumentation_asyncio-0.48b0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | dfa8e80ba4c6ba9c17a9f1a0f7d9a8d09787a5407254efd2c9ed5ab7c478b027 |
|
MD5 | 77f116057a64037ad8d0967f5602ca1a |
|
BLAKE2b-256 | af5b35eaaaa57c26f698c0d47a5bb2512805f7bc4cb47c6727c329f38acd9675 |