Skip to main content

tencentcloud-cls-sdk-langchain

腾讯云 CLS(日志服务)LangChain/LangGraph 可观测插件。

自动采集 LangChain/LangGraph 应用的调用链路,生成 6 层 Span 层级模型,直接上报到 CLS。

安装

pip install tencentcloud-cls-sdk-langchain

插件不包含 LangChain/LangGraph 本身,如未安装请先:pip install langchain langgraph langchain-openai

快速接入

1. 配置 CLS 凭据(一次性)

python -m tencentcloud_cls_sdk_langchain.cls_config init

按提示输入 CLS 接入点、Topic ID、SecretId/SecretKey,配置保存到 .env。

2. 代码接入

在应用启动代码中加入 3 行:

from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from tencentcloud_cls_sdk_langchain import LangChainInstrumentor
from tencentcloud_cls_sdk_langchain.cls_cloud_exporter import CLSCloudExporter

provider = TracerProvider()
provider.add_span_processor(BatchSpanProcessor(CLSCloudExporter()))
LangChainInstrumentor().instrument(tracer_provider=provider)

# 下面正常写你的 LangChain/LangGraph 代码,无需任何改动

3. 验证

运行应用后约 30 秒,到 CLS 控制台 → 日志主题 → 检索分析,应能看到 6 类 Span。

Span 层级模型

entry (应用入口)
 └─ session (对话窗口)
     └─ agent (每次提问)
         └─ step (每轮 ReAct)
             ├─ chat (LLM 调用)
             └─ tool (工具调用)

环境变量

配置命令 cls_config init 会自动写入 .env,也可以手动设置:

变量 必填 说明
CLS_ENDPOINT 是 CLS API 接入点
CLS_TOPIC_ID 是 CLS 日志主题 ID
CLS_SECRET_ID 是 腾讯云 SecretId
CLS_SECRET_KEY 是 腾讯云 SecretKey
CLS_SERVICE_NAME 否 服务名称(默认 langchain-app)

License

Apache-2.0

Metadata

Release files for tencentcloud-cls-sdk-langchain 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tencentcloud-cls-sdk-langchain 1.0.5
File Size Uploaded Provenance
tencentcloud_cls_sdk_langchain-1.0.5.tar.gz 25.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tencentcloud-cls-sdk-langchain 1.0.5
File Interpreter ABI Platform
tencentcloud_cls_sdk_langchain-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 54.2 kB

Release files / tencentcloud_cls_sdk_langchain-1.0.5.tar.gz

Download URL tencentcloud_cls_sdk_langchain-1.0.5.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
973ff0f0126d4f1dadd251f1b66a44df9bb68f2071f7cc74fdc334ff3766d991
BLAKE2b-256 checksum
How to use checksums
7529067f1634fbbc0a409d4dfc3b1ca917a261b489c3c9a0dff1d91225f126c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / tencentcloud_cls_sdk_langchain-1.0.5-py3-none-any.whl

Download URL tencentcloud_cls_sdk_langchain-1.0.5-py3-none-any.whl
Size 28.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3182fd35c523a841d1aa21508ccf0f71eb08f369bcc0a870490d48b6106acc81
BLAKE2b-256 checksum
How to use checksums
998eaff96930c47265cd687bd882843e7f189a082df7b785f8ae69d04e006df6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for tencentcloud-cls-sdk-langchain 1.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page