{
 "schema_version": 1,
 "generated": "2026-11-09",
 "id": "pydantic-logfire--trace-a-script-with-logfire-spans",
 "repo": "pydantic/logfire",
 "repo_url": "https://github.com/pydantic/logfire",
 "repo_slug": "pydantic-logfire",
 "title": "Trace a script with spans and structured logs",
 "page_title": "How to trace a script with spans and structured logs with Logfire",
 "summary": "Use Logfire.info and Logfire.span to record named, parameterised events around a block of work.",
 "who": "A developer debugging slow or odd behaviour in a script.",
 "problem": "Plain print statements lose structure and timing.",
 "outcome": "Structured logs and a timed span for the block you wrapped.",
 "steps": [
  "Install with `pip install logfire`",
  "Add import Logfire and call Logfire.configure()",
  "Log with Logfire.info('Hello, {name}!', name='world')",
  "Wrap work in with Logfire.span('Asking the user their {question}', question='age'): and log inside it with Logfire.debug"
 ],
 "agent_prompt": "With pydantic/logfire, add logfire.configure(), a logfire.info call and a logfire.span around the main function of <my script>, then explain what each field in the output means.",
 "agents": [
  "claude-code",
  "codex",
  "cursor",
  "gemini-cli"
 ],
 "difficulty": "Beginner",
 "time": "15 minutes",
 "basis": "readme",
 "caveat": "You need a connected Logfire project to view the results.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "python",
 "requirements": [
  "Python with pip",
  "A Logfire account, since the backend is a closed source hosted service",
  "uv for the uvx commands"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.9,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/pydantic-logfire/trace-a-script-with-logfire-spans/",
 "md": "https://dedupedai.com/use-cases/pydantic-logfire/trace-a-script-with-logfire-spans/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/pydantic-logfire--trace-a-script-with-logfire-spans.json",
 "api_version": "v1"
}
