Code snippets from:
- this talk at Pycon US on 2024-05-16
- this at EuroPython on 2024-07-12 (most of the talk was a live demo, so only a few slides)
The rest of the example from the logfire-demo project.
- Install uv
- Run
uv sync
to install dependencies - Run
uv run python {example file name}
The queries from the SQL slide were:
select start_timestamp, (attributes->'response_data'->'usage'->>'total_tokens')::int as usage, attributes->'response_data'->'message'->>'content' as message
from records
where otel_scope_name='logfire.openai' and attributes->'response_data'->'message' ? 'content'
order by start_timestamp desc
and
select sum((attributes->'response_data'->'usage'->>'total_tokens')::int)
from records where otel_scope_name='logfire.openai'