Agent Skillslangwatch/langwatch › debug-instrumentation

debug-instrumentation

GitHub

使用 LangWatch CLI 检查生产环境追踪数据,识别缺失输入输出、断连 Span 及元数据问题,提供修复指南并验证优化效果。

skills/_compiled/native/debug-instrumentation/SKILL.md langwatch/langwatch

Trigger Scenarios

追踪数据异常或中断 追踪缺少输入/输出内容 需要排查 LLM 应用可观测性问题

Install

npx skills add langwatch/langwatch --skill debug-instrumentation -g -y
More Options

Non-standard path

npx skills add https://github.com/langwatch/langwatch/tree/main/skills/_compiled/native/debug-instrumentation -g -y

Use without installing

npx skills use langwatch/langwatch@debug-instrumentation

指定 Agent (Claude Code)

npx skills add langwatch/langwatch --skill debug-instrumentation -a claude-code -g -y

安装 repo 全部 skill

npx skills add langwatch/langwatch --all -g -y

预览 repo 内 skill

npx skills add langwatch/langwatch --list

SKILL.md

Frontmatter
{
    "name": "debug-instrumentation",
    "license": "MIT",
    "metadata": {
        "category": "recipe"
    },
    "description": "Debug and improve your LangWatch traces. Inspects production traces for missing input\/output, disconnected spans, unlabeled traces, and missing metadata. Use when traces look broken or incomplete.",
    "compatibility": "Requires the `langwatch` CLI with a valid `LANGWATCH_API_KEY`. Works with any coding agent."
}

Debug Your LangWatch Instrumentation

This recipe uses the langwatch CLI to inspect your production traces and identify instrumentation issues.

Prerequisites

Step 1: Fetch Recent Traces

langwatch trace search --limit 25 --start-date "$(( ($(date +%s) - 7*24*3600) * 1000 ))" --format json

(Widen or narrow the window as needed. --start-date accepts an ISO string or epoch milliseconds, and defaults to the last 24 hours. The epoch form above is used because date -d '7 days ago' is GNU-only and fails on macOS.)

For each trace, ask:

  • How many traces are there?
  • Do they have inputs and outputs populated, or are they <empty>?
  • Are there labels and metadata (user_id, thread_id)?

langwatch status is a fast sanity check that the CLI is talking to the right project.

Step 2: Inspect Individual Traces

langwatch trace get <traceId>            # Human-readable digest
langwatch trace get <traceId> -f json    # Full span hierarchy as JSON

For traces that look problematic, check for:

  • Empty input/output: The most common issue. Check if autotrack_openai_calls(client) (Python) or experimental_telemetry (TypeScript/Vercel AI) is configured.
  • Disconnected spans: Spans that don't connect to a parent trace. Usually means @langwatch.trace() decorator is missing on the entry function.
  • Missing labels: No way to filter traces by feature/version. Add labels via langwatch.get_current_trace().update(metadata={"labels": ["feature_name"]}).
  • Missing user_id/thread_id: Can't correlate traces to users or conversations. Add via trace metadata.
  • Slow spans: Unusually long completion times may indicate API timeouts or inefficient prompts.

Step 3: Read the Integration Docs

Use the CLI to read the integration guide for the project's framework. Compare the recommended setup with what's in the code.

langwatch docs                                  # Browse the docs index
langwatch docs integration/python/guide         # Python (or your framework)
langwatch docs integration/typescript/guide     # TypeScript (or your framework)

Step 4: Apply Fixes

For each issue found:

  1. Identify the root cause in the code
  2. Apply the fix following the framework-specific docs
  3. Run the application to generate new traces
  4. Re-inspect with langwatch trace search and langwatch trace get to verify the fix

Step 5: Verify Improvement

After fixes, compare before/after:

  • Are inputs/outputs now populated?
  • Are spans properly nested?
  • Are labels and metadata present?

You can also export a sample for diff:

langwatch trace export --format jsonl --limit 50 -o traces.jsonl

Common Issues and Fixes

Issue Cause Fix
All traces show <empty> input/output Missing autotrack or telemetry config Add autotrack_openai_calls(client) or experimental_telemetry: { isEnabled: true }
Spans not connected to traces Missing @langwatch.trace() on entry function Add trace decorator to the main function
No labels on traces Labels not set in trace metadata Add metadata={"labels": ["feature"]} to trace update
Missing user_id User ID not passed to trace Add user_id to trace metadata
Traces from different calls merged Missing langwatch.setup() or trace context not propagated Ensure langwatch.setup() called at startup

Version History

  • 6f9d4a4 Current 2026-08-28 21:09

    移除旧版文档浏览和报告命令说明,新增基于 CLI 的追踪搜索、详情获取及集成文档查阅步骤,强化追踪诊断与修复流程。

  • 12615f1 2026-08-20 10:01

Same Skill Collection

.claude/skills/browser-pair/SKILL.md
.claude/skills/browser-test/SKILL.md
.claude/skills/code-review/SKILL.md
.claude/skills/feature-map/SKILL.md
.claude/skills/haven-setup/SKILL.md
.claude/skills/langwatch-kanban/SKILL.md
plugins/langwatch/skills/langwatch/SKILL.md
services/langy-agent/skills/github/SKILL.md
skills/_compiled/native/agent-best-practices/SKILL.md
skills/_compiled/native/agent-performance/SKILL.md
skills/_compiled/native/connect-agent/SKILL.md
skills/_compiled/native/context-sweet-spot/SKILL.md
skills/_compiled/native/datasets/SKILL.md
skills/_compiled/native/debug-with-langwatch/SKILL.md
skills/_compiled/native/drive-the-ui/SKILL.md
skills/_compiled/native/eval-triage/SKILL.md
skills/_compiled/native/evaluate-multimodal/SKILL.md
skills/_compiled/native/evaluations/SKILL.md
skills/_compiled/native/experiments/SKILL.md
skills/_compiled/native/generate-rag-dataset/SKILL.md
skills/_compiled/native/github/SKILL.md
skills/_compiled/native/level-up/SKILL.md
skills/_compiled/native/lwql-charts/SKILL.md
skills/_compiled/native/online-evaluations/SKILL.md
skills/_compiled/native/prompt-optimization/SKILL.md
skills/_compiled/native/prompts/SKILL.md
skills/_compiled/native/provider-cost-comparison/SKILL.md
skills/_compiled/native/scenarios/SKILL.md
skills/_compiled/native/setup-lw/SKILL.md
skills/_compiled/native/test-cli-usability/SKILL.md
skills/_compiled/native/test-compliance/SKILL.md
skills/_compiled/native/tracing/SKILL.md

Metadata

Files
0
Version
6f9d4a4
Hash
02143e80
Indexed
2026-08-20 10:01

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-29 05:01
浙ICP备14020137号-1 $Carte des visiteurs$