Token导航 LogoToken导航TokenDH.com
Trace Agent logo
开发工具stdio官方级别未说明来源级核验

Trace Agent

MCP Server

轻量级Python可观测性SDK,用于分布式追踪和Span管理,无需外部收集器。

工具数

3

提示词数

0

GitHub Stars

0

资源数

0
可观测性Python性能监控

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

TECHKNOWMAD-LABS

提供方

TECHKNOWMAD-LABS

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install traceagent # production

详细介绍

示踪剂

![MIT License](LICENSE) ![Python 3.12](https://www.python.org/downloads/) ![Tests](tests/)

用于分布式跟踪和跨度管理的轻量级Python可观测性SDK。不需要外部收集器。

______________________________________________________________________

特性

  • 上下文管理器跨度 --开始和结束跨度 with tracer.start_span(...),自动捕获开始/结束时间和持续时间。
  • 装饰仪器 --用以下命令包裹任何同步或异步函数 @trace / @trace_async;捕获异常,并将范围标记为ERROR。
  • 可插拔存储 --船舶与 InMemoryStorage (默认)和 FileStorage 用于持久的、文件支持的跟踪。
  • MCP服务器 --通过模型上下文协议公开实时跟踪数据 list_traces, get_trace,以及 get_stats 工具。
  • 丰富的终端仪表板 --使用以下工具在终端中呈现跟踪和聚合统计信息 dashboard 模块。
  • 线程和异步安全 --通过螺纹锁保护存储;主动跨度跟踪用途 contextvars.ContextVar 以实现正确的异步隔离。

______________________________________________________________________

安装

pip install traceagent          # production
pip install "traceagent[dev]"   # includes pytest, pytest-asyncio, ruff

或来源:

git clone https://github.com/techknowmad/trace-agent.git
cd trace-agent
pip install -e ".[dev]"

______________________________________________________________________

快速开始

from traceagent import get_tracer, trace, trace_async

# --- Context manager ---
tracer = get_tracer()

with tracer.start_span("db.query", attributes={"table": "users"}) as span:
    span.add_event("cache_miss")
    rows = fetch_rows()          # your code here

# --- Sync decorator ---
@trace(name="process-request")
def handle(request):
    return {"ok": True}

# --- Async decorator ---
@trace_async(name="fetch-data")
async def fetch(url: str):
    async with httpx.AsyncClient() as client:
        return await client.get(url)

# --- Persistent storage ---
from traceagent import FileStorage, Tracer

tracer = Tracer(storage=FileStorage("/tmp/traces"))

with tracer.start_span("batch-job") as span:
    span.set_attribute("records", 1_000)

______________________________________________________________________

MCP服务器

from traceagent.mcp_server import MCPServer

server = MCPServer()

# List all recorded traces
traces = server.call_tool("list_traces")

# Retrieve a specific trace by ID
trace  = server.call_tool("get_trace", {"trace_id": ""})

# Aggregate statistics
stats  = server.call_tool("get_stats")

______________________________________________________________________

建筑

traceagent/
├── models.py        # Span, Trace, SpanStatus — pure dataclasses, no I/O
├── tracer.py        # Tracer — span lifecycle, ContextVar active-span tracking
├── storage.py       # InMemoryStorage, FileStorage — thread-safe backends
├── decorators.py    # @trace, @trace_async — wraps functions, captures errors
├── mcp_server.py    # MCPServer — MCP-protocol tool surface over live storage
└── dashboard.py     # Rich-powered terminal renderer for traces and stats

数据流:

caller
  └─ Tracer.start_span()
       ├─ creates Span (model)
       ├─ sets ContextVar (active span)
       └─ on __exit__ / exception
            ├─ records end_time, duration_ms, SpanStatus
            └─ Storage.save_span()
                  ├─ InMemoryStorage  →  dict in process memory
                  └─ FileStorage      →  JSON files on disk

MCPServer
  └─ reads from Storage → serves list_traces / get_trace / get_stats

______________________________________________________________________

发展

# Run all tests
pytest -v

# Lint
ruff check .

# Run a single test module
pytest tests/test_tracer.py -v

______________________________________________________________________

贡献

贡献.md 用于分支约定、代码风格和拉取请求指南。

______________________________________________________________________

许可证

麻省理工学院 ©2026 TechKnowMad实验室私人有限公司

______________________________________________________________________

建造于 TechKnowMad实验室

目录标签

目录标签

可观测性Python性能监控分布式追踪本地部署Span管理PythonSDK

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP