# langsmith-trace > Use this skill for ANY LangChain observability question. Covers querying traces, debugging agent behavior, analyzing execution flow, filtering runs, and exporting trace data from LangSmith. - Author: Robert Xu - Repository: langchain-ai/langchain-skills - Version: 20260131183618 - Stars: 9 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/langchain-ai/langchain-skills - Web: https://mule.run/skillshub/@@langchain-ai/langchain-skills~langsmith-trace:20260131183618 --- --- name: langsmith-trace description: Use this skill for ANY LangChain observability question. Covers querying traces, debugging agent behavior, analyzing execution flow, filtering runs, and exporting trace data from LangSmith. --- # LangSmith Trace Query, analyze, and export LangSmith traces for debugging and analysis. ## Setup ### Environment Variables ```bash LANGSMITH_API_KEY=lsv2_pt_your_api_key_here # Required LANGSMITH_PROJECT=your-project-name # Optional: default project LANGSMITH_WORKSPACE_ID=your-workspace-id # Optional: for org-scoped keys ``` ### Dependencies ```bash pip install langsmith click rich python-dotenv ``` ## Usage Navigate to `skills/langsmith-trace/scripts/` to run commands. ### Quick Reference ```bash # Show recent traces python query_traces.py recent --limit 10 --project my-project # Show with metadata (timing, tokens, costs) python query_traces.py recent --limit 10 --include-metadata # Filter by time python query_traces.py recent --last-n-minutes 60 python query_traces.py recent --since 2025-01-20T10:00:00Z # Get specific trace details python query_traces.py trace --show-hierarchy # Export traces to directory (recommended for bulk collection) python query_traces.py export ./traces --limit 50 --include-metadata python query_traces.py export /tmp/traces --limit 20 # Use temp files # Search by name pattern python query_traces.py search "agent" --project my-project # Output as JSON python query_traces.py recent --format json --limit 5 ``` ## Commands **`recent`** - List recent traces (`--limit`, `--project`, `--last-n-minutes`, `--include-metadata`, `--format`) **`trace `** - Get specific trace (`--show-hierarchy`, `--include-metadata`, `--output`) **`export `** - Bulk export to directory (`--limit`, `--include-metadata`, `--max-concurrent`) **`search `** - Find runs by name (`--limit`, `--last-n-minutes`) ## Tips - Use `export` for bulk data, always specify `--project`, use `/tmp` for temp files - Include `--include-metadata` for performance/cost analysis - Increase `--max-concurrent 10` for large exports - Use `--format json` with jq for analysis ## Next Steps - Use **langsmith-dataset** skill to generate evaluation datasets from traces - Use **langsmith-evaluator** skill to create evaluators and measure performance