跳转到内容
面向编程代理的 Telemetry 配置说明

Skill.md 可观测性包装示例

复制经过审核的 Skill.md,其中包含 TypeScript 和 Python 遥测包装示例、安全事件边界、SQL 验证以及 Claude Code、Codex、Cursor 或其他编程智能体的仪表板工作流程。

将技能运用到工作中

为一个代理工作流添加事件

从准备好的 API 密钥和智能体提示开始,运行一个代表性工作流程,并在构建仪表板之前验证生成的事件。

检测我的第一次智能体运行

技能涵盖什么

以可检查数据结尾的指令

稳定的事件合约

智能体被引导至命名事件、有界 snake_case 字段、显式单元和在 SQL 中仍然有用的标识符。

不要记录私密数据

默认情况下,原始提示、完成、凭据、授权标头和私有有效负载不会进入分析路径。

确认事件已到达

直到代表性事件到达并且查询或仪表板证明工作流可见时,检测才完成。

Telemetry 包装示例

为智能体提供一个小的、可审查的摄取边界

从可信的服务器端配置传入 API 密钥,并用 SQL 验证真实事件。匿名密钥也支持这些步骤。创建仪表板前,请将工作区关联到你的账户。保留 Python 的 User-Agent 请求头,确保请求能到达 API。

打字稿

TypeScript 遥测包装器

javascript
type TelemetryEvent = Record<string, unknown>;

export async function emitTelemetry(
  apiKey: string,
  table: string,
  data: TelemetryEvent,
) {
  const response = await fetch("https://api.telemetry.sh/log", {
    method: "POST",
    headers: {
      Authorization: apiKey,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ table, data }),
    signal: AbortSignal.timeout(5_000),
  });

  if (!response.ok) {
    throw new Error(`Telemetry ingestion failed: ${response.status}`);
  }
}
蟒蛇

Python 遥测包装器

python
import json
from urllib.request import Request, urlopen

def emit_telemetry(api_key: str, table: str, data: dict) -> int:
    request = Request(
        "https://api.telemetry.sh/log",
        data=json.dumps({"table": table, "data": data}).encode(),
        headers={
            "Authorization": api_key,
            "Content-Type": "application/json",
            "User-Agent": "telemetry-agent/1.0",
        },
        method="POST",
    )
    with urlopen(request, timeout=5) as response:
        return response.status

从这里开始

粘贴一份有界摘要

将占位符替换为服务器端 API 密钥,然后要求智能体在选择事件边界之前检查存储库。

代理提示

AI智能体可观测性提示

text
Instrument this project with structured logs using /skill.md. Use this Telemetry API key 中 server-side code only: YOUR_API_KEY Anonymous keys support logging and synchronous SQL without signup. Claim the existing workspace at https://telemetry.sh/register with the same key before creating dashboards or alerts. If it is unclaimed, query the event to verify delivery and report which features need signup. Please: 1. Find the most important user-facing flows, background jobs, and AI/tooling workflows. 2. Add structured logging with snake_case table and field names. 3. Capture the key signals for each workflow, including status, latency, identifiers, and error context when relevant. 4. Run one real user-facing or operational flow through the instrumented application and verify its event appears in Telemetry. Do not use telemetry_quickstart for this milestone. 5. Run a read-only query over that real event, then create a high-level dashboard with charts and tables that summarize the most important signals in this project. 6. Tell me what you instrumented, which real flow you verified, which tables you created, and which dashboard views I should review first. Keep event payloads small and focused. Do not log credentials, raw request bodies, prompts, completions, tool arguments, or customer content. Keep telemetry delivery best-effort with bounded timeouts so a telemetry failure does not fail the application action. Make dashboard labels and charts easy to scan.

审核边界

让人类控制合同

该技能可帮助智能体找到有用的工作流程边界,但您的团队仍然拥有事件含义、允许的字段、保留策略和操作阈值。

  • 在部署之前检查每个新表和字段。
  • 使用有界标识符而不是私有有效负载。
  • 验证成功、失败和最终结果。

继续工作流程

添加事件,然后检查结果

使用预配置的工作区、API 密钥、智能体提示和入门仪表板免费开始。连接一个真实的工作流程,验证事件,并保存第一个有用的查询。