Is there a way to add comments to the generated SQ...
# orm-help
j
Is there a way to add comments to the generated SQL queries? I really want to use Prisma, but I really need to be able to tag the query logs to include the
requestId
of the request that spawned the query.
n
Hey Jason 👋 this is an interesting feature request but unfortunately not possible at the moment… this does sound like useful functionality though and I’d love to see an official feature request in a GitHub issue for it if you find the time to create one! https://github.com/prisma/prisma/issues/new/choose
j
Thanks for answering. Will do. It seems like the sort of thing that shouldn’t be too difficult to implement, since it doesn’t actually cause the code to behave any differently. While I am doing that, do you know of any way that users are adding any sort of query tracking/telemetry as a middleware or something?
m
I don't know if you're using graphql server, but Daniel has a nice repo here that uses Open Telemetry: https://github.com/2color/fastify-graphql-nexus-prisma
👍 1
d
i’m a little confused because it seemed like this capability was added in 3.6.0? https://github.com/prisma/prisma/issues/10006
though this issue is still open https://github.com/prisma/prisma/issues/7596
j
@Maciek K I’ve kept this up for research. It looks like it is tracing time that Prisma takes to run, with some additional attributes, but it does not relate that to the actual SQL queries. Am I misunderstanding something about this?
m
Sorry I have yet to incorporate that in my projects. I've used this repo before he added Open Telemetry. Maybe this thread will shed some light for you: https://twitter.com/daniel2color/status/1404524804896608256?s=20
j
Yeah, this is tracing the GraphQL requests. Super important, but I’m not sure that it is enough… This might work with manually creating the spans for prisma, but it sure is a lot of overhead… Then again… We can wrap the Prisma client in a Proxy that is bound to the context that can automatically create tracers. I’d still like to be able to trace the requests to the SQL queries themselves, but maybe that isn’t necessary…
👍 1