tencent-cls-agent-obs-setup
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "tencent-cls-agent-obs-setup" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-953f68fd372c41980e4d1a467e0b6f4bfa582a47a1bfc9b7722e05c7bfedded2. Verify the upstream source and version against https://skillhub.cn/skills/user_5b951003/tencent-cls-agent-obs-setup before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Helps users integrate TypeScript/Node.js or Python AI Agent/LLM applications with Tencent Cloud CLS Agent observability by using OpenTelemetry Spans produced by the Langfuse SDK and reporting them via the custom CLS SpanExporter direct-upload scheme described in CLS/iWiki documentation. Suitable for scenarios requiring Agent observability, Langfuse-to-CLS direct upload, CLS trace reporting, or LLM trace monitoring. This Skill implements only the application-side custom SpanExporter direct path; unless the user explicitly requests otherwise, it does not use Langfuse Server, OTLP/HTTP standard direct upload, or OpenTelemetry Collector.
Introduction source: third_party · user_5b951003 · 1.0.2 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Inputs and outputs
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: cls-agent-obs-setup
description: |
帮用户将 TypeScript/Node.js 或 Python 的 AI Agent/LLM 应用接入腾讯云 CLS Agent 可观测,使用 Langfuse SDK 产生的 OTel Span,并按 CLS/iWiki 文档中的自定义 CLS SpanExporter 直传方案上报。适用于用户要求接入 Agent 可观测、Langfuse 到 CLS、CLS trace 上报、LLM trace 监控、AI observability setup、Tencent Cloud CLS Agent tracing、CLS SpanExporter 等场景。本 Skill 只实现应用侧自定义 SpanExporter 直传路径;除非用户明确要求,不要使用 Langfuse Server、OTLP/HTTP 标准直传或 OpenTelemetry Collector。腾讯云 CLS Agent 可观测接入
接入方式
实现 CLS/iWiki 文档中的自定义 SpanExporter 直传方案:
Application -> Langfuse SDK / OTel spans -> custom CLS SpanExporter -> CLS Log Topic
不要部署 Langfuse Server。不要为该方案配置 OpenTelemetry Collector。如果用户要求快速使用 OTLP/HTTP 标准直传,说明那是文档中的另一种手工接入方案,并单独给出最小 OTLP/HTTP 配置。
必要输入
在修改项目之前,先收集或推断以下值:
| 输入 | 是否必填 | 说明 |
|---|---|---|
CLS_DEFAULT_REGION |
是 | CLS 日志主题所在地域,例如 ap-guangzhou。 |
CLS_TOPIC_ID |
是 | CLS 日志主题 ID。它是 UUID,不是 agent-app-xxxx 形式的 Agent 可观测应用 ID。 |
TENCENTCLOUD_SECRET_ID |
是 | 具备 CLS 写入权限的腾讯云 SecretId。 |
TENCENTCLOUD_SECRET_KEY |
是 | 腾讯云 SecretKey。 |
TENCENTCLOUD_TOKEN |
否 | 使用 TypeScript 临时密钥时传入的 Token。 |
SERVICE_NAME |
否 | Resource 中的 service.name;默认使用 my-llm-app。 |
根据地域和语言推导 CLS_ENDPOINT:
- TypeScript/Node.js:
ap-guangzhou.cls.tencentcs.com,不带协议。 - Python:
https://ap-guangzhou.cls.tencentcs.com,带https://。
工作流
- 识别项目语言:
- TypeScript/Node.js:查看
package.json、tsconfig.json、.ts/.js入口文件。 - Python:查看
requirements.txt、pyproject.toml、.py入口文件。
- TypeScript/Node.js:查看
- 生成代码前,先读取对应模板:
- TypeScript/Node.js:
references/typescript-templates.md - Python:
references/python-templates.md
- TypeScript/Node.js:
- 补齐依赖并生成语言对应文件:
- TypeScript/Node.js:
cls-span-exporter.ts和instrumentation.ts - Python:
cls_span_exporter.py和instrumentation.py
- TypeScript/Node.js:
- 创建或更新
.env,并确保.env已加入 git 忽略。 - 在应用入口文件最顶部注入 instrumentation,必须早于 OpenAI、LangChain、Langfuse 或其他被观测库的 import。
- 仅当项目中没有可运行示例时,才补充最小 Langfuse/OpenAI 示例。
- 提供 CLS 侧验证步骤。除非已经成功查询 CLS,否则不要声称真实上报成功。
字段契约
自定义 SpanExporter 必须写入以下 CLS LogItem 字段,并与 iWiki 的自定义 SpanExporter 路径保持一致:
| CLS 字段 | 来源 |
|---|---|
traceID |
OTel trace ID 十六进制字符串 |
spanID |
OTel span ID 十六进制字符串 |
parentSpanID |
父 Span ID,没有则为空字符串 |
name |
Span 名称 |
kind |
Span kind |
start |
Span 开始时间,单位纳秒 |
end |
Span 结束时间,单位纳秒 |
duration |
end - start,单位纳秒 |
statusCode |
Span 状态码 |
statusMessage |
Span 状态信息,没有则为空字符串 |
attribute |
span.attributes 的 JSON 字符串 |
resource |
span.resource.attributes 的 JSON 字符串 |
规则:
- CLS 日志时间必须使用 Span 结束时间:
- TypeScript:
item.setTime(Math.floor(endNs / 1e6)) - Python:
log.time = span.end_time // 1_000_000
- TypeScript:
start、end、duration保持纳秒单位,不要除以1000。resource写为 CLS 顶层字段。不要把 resource attributes 放到attribute.resourceAttribute。- 不要默认抽取顶层
userId、sessionId或model字段。它们保留在attribute中;用户可通过 JSON 函数提取,或后续按需增加顶层索引字段。 - TypeScript 必须使用
span.parentSpanContext?.spanId,不要使用span.parentSpanId。 - TypeScript 的
statusCode必须写成String(span.status.code),不要写成UNSET/OK/ERROR标签。
验证
应用运行并 flush spans 后,让用户在 CLS 检索分析中验证:
* | SELECT traceID, spanID, name, duration, statusCode ORDER BY __TIMESTAMP__ DESC LIMIT 10
查询指定 trace:
traceID:"4bf92f3577b34da6a3ce929d0e0e4736"
做模型维度分析时,从 attribute 中提取 JSON 字段,例如:
* | SELECT json_extract_scalar(attribute,'$."gen_ai.request.model"') AS model,
AVG(duration) AS avg_duration_ns
GROUP BY model
约束
- 不要为该方案配置 OpenTelemetry Collector。OpenTelemetry Collector Contrib 中官方
tencentcloudlogserviceexporter仅支持 logs,不支持 traces。 - 进程退出前必须 flush:
- TypeScript:
await sdk.shutdown() - Python:
get_client().flush()或provider.shutdown()
- TypeScript:
- 凭证必须放在环境变量中。不要把 SecretId 或 SecretKey 硬编码到代码里。
- 如果缺少必要 CLS 参数,停止并向用户确认,不要猜测。
Current listing version
1.0.2
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决 AI Agent/LLM 应用接入腾讯云 CLS 可观测性的实际工程痛点
- 提供端到端自定义 SpanExporter 直传方案,避免依赖 Langfuse Server 或 OpenTelemetry Collector
- 适用于高频生产环境监控需求
Highlights
- 触发词覆盖全面,包括 Langfuse 到 CLS、CLS trace 上报、AI observability setup 等核心场景
- 边界清晰,明确排除 OTLP/HTTP 标准直传和 OpenTelemetry Collector 路径
Areas to improve
-
description 写错位置 Reported severity: Minor
顶层 frontmatter 中 description 为空,实质描述内容位于 skill_body 内部
Recommendation: 将 description 内容移至顶层 frontmatter 的 description 字段
-
缺少 When to Use 章节 Reported severity: Minor
文档未明确设置 When to Use 章节说明使用时机
Recommendation: 在接入方式前增加 When to Use 章节,说明适用场景和前提条件
-
缺少端到端完整代码示例 Reported severity: Minor
仅提供代码片段,未提供完整可运行的 TypeScript/Python 示例文件
Recommendation: 补充完整的 cls-span-exporter.ts/instrumentation.ts 或 cls_span_exporter.py/instrumentation.py 示例代码
Highlights
- 工作流步骤清晰,包含语言识别、模板读取、依赖补齐、环境变量配置等完整流程
- 字段契约详细,明确 CLS LogItem 字段与 OTel Span 的映射关系
- 验证步骤具体,提供 CLS 检索分析 SQL 示例
Highlights
- 工具来源明确,基于腾讯云 CLS SDK、Langfuse SDK 和 OpenTelemetry 标准
- 覆盖主要异常场景,如凭证缺失时停止并确认
- 进程退出前强制 flush,确保 spans 上报完整性
- 凭证通过环境变量管理,避免硬编码
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 29
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- ap-guangzhou.cls.tencentcs.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.