Code snippets from this talk given at Pycon US on 2024-05-16.
The rest of the example from the logfire-demo project.
- Install rye
- Run
rye sync
to install dependencies - Run
rye 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'