跳至主要內容
Telemetry
程式設計代理的審查埋點技能

Skill.md 可觀測性包裝範例

複製經過審查的 Skill.md,其中包含 TypeScript 和 Python 遙測包裝範例、安全事件邊界、SQL 驗證以及 Claude Code、Codex、Cursor 或其他程式設計代理的儀表板工作流程。

將技能運用到工作中

立即使用一種真實代理工作流程

從準備好的 API 金鑰和代理提示開始,執行一個代表性工作流程,並在建置儀表板之前驗證生成的事件。

連線代理遙測

技能涵蓋什麼

以可檢查資料結尾的指令

穩定的事件合約

代理被引導至命名事件、有界 snake_case 欄位、顯式單元和在 SQL 中仍然有用的識別符號。

安全收集邊界

預設情況下,原始提示、完成、憑據、授權標頭和私有有效負載不會進入分析路徑。

端到端的結果

直到代表性事件到達並且查詢或儀表板證明工作流程可見時,檢測才完成。

Telemetry 包裝範例

為代理提供一個小的、可審查的攝取邊界

Pass the API key from trusted server-side configuration and verify a real event with SQL. Anonymous keys support this workflow; claim the workspace before creating dashboards. Keep the Python User-Agent header so requests reach the 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 }),
  });

  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: YOUR_API_KEY Anonymous keys: logging and synchronous SQL work without signup. Claim the existing workspace at https://telemetry.sh/register with the same key before creating dashboards or alerts. If it is unclaimed, finish with verified event readback and mark account features as pending signup. Please: 1. Find the most important user-facing flows, background jobs, and AI/tooling workflows. 2. Add structured logging with pragmatic snake_case tables and fields. 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 中 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. Prefer small, composable events over giant payloads, and optimize for dashboards that humans can scan quickly.

審查邊界

讓人類控制合約

該技能可幫助代理找到有用的工作流程邊界,但您的團隊仍然擁有事件含義、允許的欄位、保留策略和操作閾值。

  • 在部署之前檢查每個新資料表和欄位。
  • 使用有界識別符號而不是私有有效負載。
  • 驗證成功、失敗和最終結果。

繼續工作流程

檢測第一個工作流程,然後檢查結果

使用預設定的工作區、API 金鑰、代理提示和入門儀表板免費開始。連線一個真實的工作流程,驗證事件,並儲存第一個有用的查詢。