DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to trace a script with spans and structured logs with Logfire

Use Logfire.info and Logfire.span to record named, parameterised events around a block of work.

Short answer: Install with pip install logfire; then add import Logfire and call Logfire.configure(); log with Logfire.info('Hello, {name}!', name='world'). All steps.

Who it is forA developer debugging slow or odd behaviour in a script.

The problemPlain print statements lose structure and timing.

The outcomeStructured logs and a timed span for the block you wrapped.

What you need first

  • Python with pip
  • A Logfire account, since the backend is a closed source hosted service
  • uv for the uvx commands

Steps

  1. Install with pip install logfire
  2. Add import Logfire and call Logfire.configure()
  3. Log with Logfire.info('Hello, {name}!', name='world')
  4. Wrap work in with Logfire.span('Asking the user their {question}', question='age'): and log inside it with Logfire.debug

Prompt for your agent

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.

Caveat. You need a connected Logfire project to view the results.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for pydantic/logfire and "Trace a script with spans and structured logs"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer