Spans and Traces in Logfire
Discover Logfire's powerful spans and traces for deep system insights
- Product
- Pydantic
- Sent from
- pydantic.dev
- Sent
No dark-mode styles — this email renders the same in a dark client.
Logfire
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Hello!
If you've ever wanted an easy way to see the request flows, performance, and bottlenecks in your production system, Logfire has you covered. Let me introduce you to one of Logfire's most powerful features: traces as logs.
Think of spans as "logging++" they do everything regular logs do, but with extras. Here's what makes them powerful:
* They measure execution time automatically
* They capture relationships between operations
* Capture exceptions that occur within a span
Let me show you a real-world example. Imagine you need to analyze file sizes in a directory:
from pathlib import Path
import logfire
logfire.configure()
cwd = Path.cwd()
total_size = 0
with logfire.span('counting size of {cwd=}', cwd=cwd):
for path in cwd.iterdir():
if path.is_file():
with logfire.span('reading {path}', path=path.relative_to(cwd)):
total_size += len(path.read_bytes())
logfire.info('total size of {cwd} is {size} bytes', cwd=cwd, size=total_size)
What's happening here?
* The outer span tracks the total operation time
* Each file gets its own span, showing individual processing times
* All spans are connected into a trace, showing the full picture
* Context (like file paths) is automatically captured
This means you can:
1. Identify slow files instantly
2. Track total processing time
3. See exactly where your code spends time
4. Debug issues with specific files
Here's how the above example looks in the Logfire UI:
Logfire UI Trace View ( https://logfire.pydantic.dev/docs/guides/onboarding-checklist/add-manual-tracing/ )
This is also extremely useful when dealing with multiple microservices, async pipeline jobs, LLM calls and many more. For more details, check out our docs ( https://logfire.pydantic.dev/docs/ ).
Still have questions? Feel free to get in touch ( https://logfire.pydantic.dev/docs/help/ ) or just hit reply to this email.
Best,
The Pydantic Team
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Pydantic Services, Inc. ・
https://pydantic.dev ・
github/pydantic ( https://github.com/pydantic )
Unsubscribe ( https://track.customer.io/unsubscribe/dgSI0QoAAMmABMiABAGhYGAGRICWrmC3VqbPq_Y= ) or manage your tracking preferences ( https://track.customer.io/tracking_consent/dgSI0QoAAMmABMiABAGhYGAGRICWrmC3VqbPq_Y= )- Accession
- nse/pydantic/2026-10-21/4721
- From
- Pydantic Team · hello@pydantic.dev
- Sent
- 21 October 2026 · 21:00 UTC






