Skip to content

feat: LangSmith OTel 观测方案对接 AgentKit APMPlus#228

Open
bigerous wants to merge 1 commit into
bytedance:mainfrom
bigerous:feat/langchain-otel-observability
Open

feat: LangSmith OTel 观测方案对接 AgentKit APMPlus#228
bigerous wants to merge 1 commit into
bytedance:mainfrom
bigerous:feat/langchain-otel-observability

Conversation

@bigerous

@bigerous bigerous commented Jun 24, 2026

Copy link
Copy Markdown

概述

增加一个使用 LangChain 的 LangSmith OTel 观测方案,对接到 AgentKit 平台 APMPlus 观测后端的示例。

改动内容

  • 新增 langchain_otel_agent.py:LangGraph 多步骤 Agent + LangSmith OTel 自动追踪,通过 OTLP gRPC 导出 trace 到 APMPlus
  • 新增 langchain_otel_guide.md:观测方案接入指南
  • 更新 requirements.txt:合并 OTel 相关依赖

核心方案

LangGraph 节点/LLM/工具调用
    ↓ (LangSmith OTel 自动生成 span)
OpenTelemetry SDK
    ↓ (OTLP gRPC + x-byteapm-appkey header)
AgentKit APMPlus 后端

特性

  • 零侵入追踪:通过 OtelSpanProcessor 挂到已有 TracerProvider,自动为所有 LangGraph 节点、LLM 调用、工具调用生成 span
  • APMPlus 对接:OTLP exporter 带 x-byteapm-appkey header 鉴权(gRPC 要求全小写)
  • Resource attributeapmplus.business_carrier=agentkit_runtime
  • FastAPI 自动打点:HTTP 请求级 span 自动注入
  • 多路径工作流演示:classify → simple_qa / research+tools / escalation 三条路径

运行方式

uv pip install -r requirements.txt
uv run langchain_otel_agent.py test  # 本地测试三条流程
uv run langchain_otel_agent.py       # 启动 HTTP 服务

观测示例:
image

- Add langchain_otel_agent.py: LangGraph multi-step agent with LangSmith OTel
  auto-tracing, exporting traces to AgentKit APMPlus via OTLP gRPC
- Add langchain_otel_guide.md: integration guide for the observability approach
- Update requirements.txt: add OTel and LangSmith dependencies

Key features:
- Zero-invasive tracing via OtelSpanProcessor on existing TracerProvider
- APMPlus integration with gRPC header auth (x-byteapm-appkey)
- Resource attribute: apmplus.business_carrier=agentkit_runtime
- FastAPI auto-instrumentation for HTTP-level spans
- Multi-path workflow demo (classify → simple_qa / research+tools / escalation)

Co-Authored-By: Claude <noreply@anthropic.com>
@bigerous
bigerous force-pushed the feat/langchain-otel-observability branch from c805c18 to 214a598 Compare June 24, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant