Skip to content

Commit 51527a6

Browse files
committed
update docs and pyproject
1 parent 1c0e964 commit 51527a6

5 files changed

Lines changed: 54 additions & 24 deletions

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,25 @@ FastroAI wraps [PydanticAI](https://ai.pydantic.dev/) with production essentials
3232
- **Cost Tracking**: Automatic cost calculation in microcents. No floating-point drift.
3333
- **Pipelines**: DAG-based workflows with automatic parallelization.
3434
- **Safe Tools**: Timeout, retry, and graceful error handling for AI tools.
35-
- **Tracing**: Protocol-based integration with any observability platform.
35+
- **Tracing**: Built-in Logfire integration, or bring your own observability platform.
3636

3737
## Installation
3838

3939
```bash
4040
pip install fastroai
4141
```
4242

43+
With Logfire tracing:
44+
45+
```bash
46+
pip install fastroai[logfire]
47+
```
48+
4349
Or with uv:
4450

4551
```bash
4652
uv add fastroai
53+
uv add "fastroai[logfire]" # With Logfire tracing
4754
```
4855

4956
## Quick Start

docs/api/tracing.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Tracing
22

3-
The tracing module provides a protocol-based interface for distributed tracing integration. Implement the `Tracer` protocol to connect FastroAI with your observability platform.
3+
The tracing module provides a protocol-based interface for distributed tracing integration. Implement the `Tracer` protocol to connect FastroAI with your observability platform, or use one of the built-in tracers.
44

55
## Tracer
66

@@ -16,6 +16,13 @@ The tracing module provides a protocol-based interface for distributed tracing i
1616
show_root_heading: true
1717
show_source: false
1818

19+
## LogfireTracer
20+
21+
::: fastroai.tracing.LogfireTracer
22+
options:
23+
show_root_heading: true
24+
show_source: false
25+
1926
## NoOpTracer
2027

2128
::: fastroai.tracing.NoOpTracer

docs/guides/tracing.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,30 @@ The trace ID appears in every log line, so you can grep for it:
7979
grep "abc12345" app.log
8080
```
8181

82+
### LogfireTracer
83+
84+
Integrates with [Pydantic Logfire](https://logfire.pydantic.dev/), a modern observability platform built by the Pydantic team. Install with:
85+
86+
```bash
87+
pip install fastroai[logfire]
88+
```
89+
90+
Usage:
91+
92+
```python
93+
import logfire
94+
from fastroai import FastroAgent, LogfireTracer
95+
96+
# Configure logfire once at startup
97+
logfire.configure()
98+
99+
tracer = LogfireTracer()
100+
agent = FastroAgent(model="openai:gpt-4o")
101+
response = await agent.run("Hello!", tracer=tracer)
102+
```
103+
104+
View your traces in the Logfire dashboard at [logfire.pydantic.dev](https://logfire.pydantic.dev).
105+
82106
### NoOpTracer
83107

84108
Does nothing. Use when tracing is disabled, in tests, or when you need trace IDs for compatibility but don't want actual tracing:
@@ -124,27 +148,7 @@ Three methods. That's it. `span()` creates a context manager that yields a trace
124148

125149
### Logfire
126150

127-
```python
128-
import uuid
129-
import logfire
130-
from contextlib import asynccontextmanager
131-
132-
class LogfireTracer:
133-
@asynccontextmanager
134-
async def span(self, name: str, **attrs):
135-
trace_id = str(uuid.uuid4())
136-
with logfire.span(name, trace_id=trace_id, **attrs):
137-
yield trace_id
138-
139-
def log_metric(self, trace_id: str, name: str, value):
140-
logfire.metric(name, value, trace_id=trace_id)
141-
142-
def log_error(self, trace_id: str, error: Exception, context=None):
143-
logfire.error(str(error), trace_id=trace_id, **(context or {}))
144-
145-
tracer = LogfireTracer()
146-
response = await agent.run("Hello!", tracer=tracer)
147-
```
151+
FastroAI includes a built-in `LogfireTracer`. See the [LogfireTracer](#logfiretracer) section above for usage.
148152

149153
Logfire gives you a nice UI to explore traces, and the Pydantic team maintains it, so it plays well with PydanticAI.
150154

@@ -238,6 +242,8 @@ Log the trace ID in your application code, and you can trace from "user clicked
238242
The real value of tracing is correlation. Here's how to connect AI calls with your request handling:
239243

240244
```python
245+
from fastroai import LogfireTracer
246+
241247
async def handle_request(request):
242248
tracer = LogfireTracer()
243249

@@ -277,6 +283,7 @@ Without tracing, you're debugging blind.
277283
|-----------|----------|
278284
| Tracer protocol | `fastroai/tracing/tracer.py` |
279285
| SimpleTracer | `fastroai/tracing/tracer.py` |
286+
| LogfireTracer | `fastroai/tracing/tracer.py` |
280287
| NoOpTracer | `fastroai/tracing/tracer.py` |
281288

282289
---

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fastroai"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
description = "Lightweight AI orchestration built on PydanticAI"
55
readme = "README.md"
66
requires-python = ">=3.11"
@@ -28,6 +28,9 @@ dependencies = [
2828

2929
[project.optional-dependencies]
3030
dev = []
31+
logfire = [
32+
"logfire>=4.15.1",
33+
]
3134

3235
[build-system]
3336
requires = ["hatchling"]

uv.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)