Support the postgres wire protocol
Description
Using SQL to query traces is a truly remarkable feature. Currently, it appears to be locked behind the UI or MCP, though. I want to use a query tool like psql. I LIVE in psql. I am primarily using Claude Code with MCP to explore my tracing data, but I'm fully capable of writing my own SQL queries to get exactly what I want. Supporting the postgres wire protocol and exposing an endpoint that I could use with general-purpose query tools like psql would unlock so much power.
Currently, it appears to be locked behind the UI or MCP, though
No, you can use https://logfire.pydantic.dev/docs/how-to-guides/query-api/
(but btw please set a min_timestamp when you do)
Thanks for the link to the docs to the API. I share John's desire to be able to connect to the query API directly within a SQL client as that'd be really cool I think to leverage the tooling that exists around SQL query writing into interacting with the API (vs using a HTTP client as suggested in the docs).
I made a PoC of what that could look like with regards to the postgresql wire protocol to make @jgpruitt happy, which is available at https://github.com/timescale/logfire-pg.
oh nice! We actually had this before - @adriangb implemented the entire PG wire protocol in python. We removed it when we switched database.
It's definitely something we want to re-add, but haven't had time yet.
I always throught it would be better implemented in Rust than Python, maybe @adriangb would be keener on doing it in rust now?
@MasterOdin curious how you'd feel about using Arrow Flight SQL as the wire protocol instead?
Personally, psql is my preferred database query tool by a long shot. Arrow Flight SQL would not work for it, though I believe it works for others.
My only potential concern would be on client support for Arrow Flight SQL as I've not heard it. I do use duckdb some, and I think that the airport extension should work, but I'm not totally certain.
Like I think having something that is postgres wire compatible would ease adoption, so long as it's not too onerous to use Flight SQL, should be fine, and then there's still the project I linked above for someone who absolutely needed postgres wire compatibility to analyse logfire records.