supabase / pg_graphql

GraphQL support for PostgreSQL
https://supabase.github.io/pg_graphql
Apache License 2.0
2.92k stars 104 forks source link

Logging Warnings/Errors and Debugging info #398

Open olirice opened 1 year ago

olirice commented 1 year ago

GraphQL queries are typically passed as arguments to a prepared statement and are not logged. Transpired SQL queries executed via SPI are similarly unlogged. That makes it difficult for users to debug their own queries

This issue is to add debug level logging for:

with a trace_id

We should also add logging at the warning or error level for things like like naming collisions

olirice commented 1 year ago

cc @kav

olirice commented 1 year ago

current hold up on this is that we want to log the graphql queries at LOG level (which is just log!("graphql {statement}"); from pgrx prelude), but only if the log_statement in postgresql.conf is set to mod or all

@imor any ideas of how to check that setting efficiently?

imor commented 1 year ago

Executing the following SQL once for each GraphQL query shouldn't add too much overhead:

select setting from pg_settings
where name = 'log_statement';
olirice commented 1 year ago

I'd rather not do that if we can avoid it. for now I'll add debug level logging since that isn't impacted

imor commented 1 year ago

I'd rather not do that if we can avoid it. for now I'll add debug level logging since that isn't impacted

Is that because reading from pg_settings can be expensive, or there's some other reason? If the concern is inefficiency, we can also move this to when we read the context. That should be infrequent enough.

olirice commented 1 year ago

yeah the concern was efficiency. adding to the context is a good idea, I'll check that out