跳至主要內容
提供給程式開發代理的 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 金鑰、代理提示和入門儀表板免費開始。連線一個真實的工作流程,驗證事件,並儲存第一個有用的查詢。