Skip to content

Prisma Spans don't include SQL #5780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
silent1mezzo opened this issue Sep 20, 2022 · 1 comment
Closed

Prisma Spans don't include SQL #5780

silent1mezzo opened this issue Sep 20, 2022 · 1 comment

Comments

@silent1mezzo
Copy link

Problem Statement

Prisma spans show the query type in the description instead of the SQL that was generated (findMany, findUnique, update, etc...)

Other SDKs (Python, Ruby, PHP) for specific frameworks (Django, Rails, Laravel) show the actual SQL that's being generated. Having the SQL makes it easy to see what's happening under the hood and solve things like n+1 queries.

Solution Brainstorm

Having the ORM details is useful, especially for finding them in the codebase.

1. Update the span description
We could update the span description to include the raw SQL ORM call - raw SQL

e.g. Expense findOne - SELECT expenses_expense.* FROM expenses_expenseWHEREexpenses_expense`.id = %s

2. Update the span op
If we wanted to keep it similar to the other SDKs we could have the description as just the raw SQL call and update the Span op to include the ORM call.

span.op: db.prisma.findOne
span.description: SELECT expenses_expense.* FROM expenses_expenseWHEREexpenses_expense.id = %s

@AbhiPrasad
Copy link
Member

AbhiPrasad commented Apr 6, 2023

I investigated this further and there is no way to show SQL. justindsmith/opentelemetry-instrumentations-js#22 has more details about it.

The sql generation / execution is happening inside the prisma/prisma-engines package, which is a rust-based, compiled binary. The prisma client operates with a graphql based intermediary that gets sent down into the engine for execution, but no real execution details (like the executed query) are sent back.

Therefore this is the best we can do for now.

Important to note that prisma themselves is adding otel instrumentation to their code: https://www.prisma.io/docs/concepts/components/prisma-client/opentelemetry-tracing, so eventually it'll be ideal to switch to that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants