agentleFS
bigbagbigbag/lfsnag/skills/trace/SKILL.md

trace

Skill2 starsChanged 2 months agoMITView on GitHub

Investigate Pydantic Logfire traces - one-command save plus peek, local SQLite search, API SQL, and debug production issues

  • Deletes or force-pushes

30 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ai-slop-cleaner, ralplan and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • Jurel89Skill

    ai-slop-cleaner

    Clean AI-generated code slop with a regression-safe, deletion-first workflow and optional reviewer-only mode

    Also in 4 projects that use this

  • ibahgatSkill

    ralplan

    Create a strict, quality-first execution plan with explicit gates and rollback-ready sequencing.

    Also in 4 projects that use this

  • woosikkimSkill

    deepinit

    Generate hierarchical AGENTS.md codebase maps for agent context

    Also in 3 projects that use this

  • klauswgSkill

    deep-interview

    在明确批准执行之前,通过数学化歧义门控进行苏格拉底式深度访谈

    Also in 4 projects that use this

  • AWSSkill

    map

    Map verified service capabilities against customer-provided control framework and threat model. Produces mapping-results.json, controls-catalog.md, and framework-mapping.md. Supports pluggable frameworks: CCMv4, NIST 800-53, CIS Benchmarks, ISO 27001, etc. Split into 4 focused sub-skills for better accuracy; this skill orchestrates them.

    Also in 4 projects that use this

  • buddyhSkill

    deep-dive

    Deep dive on any topic. Decomposes into subtopics, researches each in parallel with thorough source gathering, then synthesizes into a comprehensive report (4,000-10,000+ words, 40-100+ sources). Scales depth dynamically based on topic complexity. Use when asked for a deep dive, deep research, comprehensive analysis, or thorough investigation of a topic.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 26 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use lfsnag (./bin/lfsnag or PATH).

    line 9

“Common” is measured: kept by at least 6 in 10 of the 26 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

lfsnag: Logfire Trace Investigation

Use lfsnag (./bin/lfsnag or PATH). Token: ~/.config/lfsnag/config.json, LOGFIRE_READ_TOKEN, or --token.

The three commands

# 1. SAVE + PEEK: pass a traceId or a full Logfire URL.
#    Streams all records into SQLite (RAM-bounded), then prints a small summary
#    that includes the "db" path for step 3. URL org/project auto-picks the env profile.
lfsnag 'https://logfire-us.pydantic.dev/org/proj?traceId=<traceId>'
lfsnag -e stage <traceId>                      # -e overrides URL/auto selection
lfsnag --save /tmp/t.sqlite -e stage <traceId> # custom path instead of cache dir

# 2. API SQL (DataFusion). Cross-trace queries. No local file.
lfsnag -e stage --sql "SELECT span_name, count() cnt FROM records WHERE trace_id = '<traceId>' GROUP BY span_name ORDER BY cnt DESC"

# 3. LOCAL SQL (SQLite). Search the saved file offline. No token and no rate limit.
lfsnag --db ~/.cache/lfsnag/<traceId>.sqlite --peek
lfsnag --db ~/.cache/lfsnag/<traceId>.sqlite --sql "SELECT span_name FROM records WHERE is_exception = 1"

Rules the CLI enforces:

  • --peek works only with --db. A bare traceId already peeks.
  • --db needs --sql or --peek. It rejects a traceId and --save.
  • --sql rejects --peek, --save, and a traceId.

Cache: fetches write <UserCacheDir>/lfsnag/<traceId>.sqlite. The path follows XDG_CACHE_HOME. The flag --save F sets a different path. A re-fetch replaces the file atomically. Clear the cache with rm -rf -- "${XDG_CACHE_HOME:-$HOME/.cache}/lfsnag". Do this when no lfsnag process runs. A delete during a fetch loses the data of that fetch.

Reading the peek

{"db": "…", "n": 107, "n_roots": 1, "n_exceptions": 4, "n_slow": 19,
 "roots": […], "exceptions": […], "slow": […], "top": […]}
  • n_* are exact totals. The arrays hold at most 20 samples.
  • The peek limits each exceptions[].message to 200 characters. Read the full text with --db --sql.
  • path on exceptions/slow is the ancestry root › … › span. The path holds at most 8 hops.
  • top lists the most frequent span_name with max_dur.
  • Slim -f fetches lack peek columns. The output then holds {"db","n","note"} only. An absent n_* key means unknown. Fetch without -f for a full peek.

SQL tips

API --sql runs DataFusion (postgres-ish): attributes->>'key'. Prefer span_name over message. The API limit is 10000. A SQL LIMIT alone does not lift this cap.

SELECT count(*) n FROM records WHERE trace_id = '<traceId>'
SELECT span_name, count() cnt, max(duration) max_dur FROM records WHERE trace_id = '<traceId>' GROUP BY span_name ORDER BY cnt DESC
SELECT span_name, exception_type, exception_message FROM records WHERE trace_id = '<traceId>' AND is_exception
SELECT ... WHERE level >= 'error'          -- errors without exception
SELECT ... WHERE parent_span_id IS NULL    -- roots

Local --db --sql runs SQLite. Read JSON with json_extract. Logfire keys contain dots. Quote the path for this reason. Bools are 0/1.

SELECT count(*) n FROM records
SELECT span_name, exception_type, exception_message FROM records WHERE is_exception = 1
SELECT span_name, duration FROM records WHERE duration > 2 ORDER BY duration DESC
SELECT span_name FROM records WHERE attributes LIKE '%gen_ai%'   -- cheap key probe
SELECT span_name, json_extract(attributes, '$."gen_ai.request.model"') model FROM records WHERE json_extract(attributes, '$."gen_ai.request.model"') IS NOT NULL
SELECT sum(json_extract(attributes, '$."gen_ai.aggregated_usage.input_tokens"')) FROM records
SELECT span_name, message, attributes FROM records WHERE span_id = '<spanId>'

jq: lfsnag -c --db F --peek | jq '.exceptions'

Available fields

  • start_timestamp - The time when the span/log started (UTC)
  • end_timestamp - When the span/log completed (UTC)
  • duration - Elapsed time in seconds (NULL for logs)
  • trace_id - Trace identifier (32 hex chars)
  • span_id - Span identifier (16 hex chars)
  • parent_span_id - Parent span reference (NULL for root)
  • kind - span, log, span_event, or pending_span
  • span_name - Short name shared by similar records
  • message - Human-readable description
  • level - Severity level
  • is_exception - Whether the span holds an exception
  • exception_type - Exception class name
  • exception_message - Exception message
  • exception_stacktrace - Formatted traceback
  • attributes - Arbitrary structured data (JSON)
  • tags - Grouping labels
  • otel_status_code - Span status (UNSET, OK, ERROR)
  • otel_status_message - Span error description
  • service_name - Service/application name
  • deployment_environment - Environment (production, staging)
  • http_response_status_code - HTTP status code
  • http_method - HTTP method
  • http_route - HTTP route pattern
  • url_full - Complete URL
  • url_path - URL path
  • service_version - Service version
  • service_instance_id - Service instance identifier
  • service_namespace - Service namespace
  • process_pid - Process ID
  • url_query - URL query string
  • log_body - Body of OpenTelemetry log records
  • otel_events - Span events (JSON)
  • otel_links - Span links (JSON)
  • otel_resource_attributes - Resource metadata (JSON)
  • otel_scope_name - Instrumenting library name
  • otel_scope_version - Instrumenting library version
  • otel_scope_attributes - Scope metadata (JSON)
  • telemetry_sdk_name - Telemetry SDK name
  • telemetry_sdk_language - SDK language
  • telemetry_sdk_version - SDK version

CLI flags

  • <traceId | URL> - Fetch the trace into SQLite. The path is the cache dir or --save. The output is a peek with db.
  • --db FILE - Query local SQLite with --sql or --peek. Local queries need no token.
  • --sql - Raw SQL (API without --db, local with --db)
  • --save FILE - Override the SQLite path for a fetch
  • -f, --fields - Columns to save (default all)
  • -e, --env - Profile. The URL org/project sets it automatically. The flag -e wins.
  • -c, --compact - One-line JSON
  • -v, --verbose - HTTP debug
  • --token - Override read token

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.