question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Prisma Tags to our Sql Commenter tracing for extra information

See original GitHub issue

Problem

At the moment Prisma can add a trace id as a SQL comment when a trace id is passed to the query.

The comment doesn’t give any more information around the query for example it doesn’t mention this query is from Prisma and what operation it was for.

Suggested solution

Allow the ability to add in extra Sql Tags. For example:

SELECT * FROM FOO /* operation='CreateUser', ORM='Prisma',
traceparent='00-5bd66ef5095369c7b0d1f8f4bd33716a-c532cb4098ac3dd2-01',
tracestate='congo%3Dt61rcWkgMzE%2Crojo%3D00f067aa0ba902b7'*/

We could make it that we always add in those SQL comments even if the trace id is not added. So the Query would look like:

SELECT * FROM FOO /* operation='CreateUser', ORM='Prisma'*/

We could do this by default or allow the user to opt into adding them.

Alternatives

Additional context

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
garrensmithcommented, May 19, 2022

I’m away this week but I can try and find an easier ticket to work on next week.


From: Bogdan Soare @.> Sent: Wednesday, May 18, 2022 8:12:44 PM To: prisma/prisma @.> Cc: garren smith @.>; Mention @.> Subject: Re: [prisma/prisma] Add Prisma Tags to our Sql Commenter tracing for extra information (Issue #13360)

Got it, thank you for letting me know.

Once things are more clear if you need any help please let me know.

— Reply to this email directly, view it on GitHubhttps://github.com/prisma/prisma/issues/13360#issuecomment-1130346388, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AABL2ARKY234VXSGKT3C6RLVKUXJZANCNFSM5V3LHVSA. You are receiving this because you were mentioned.Message ID: @.***>

0reactions
matthewmuellercommented, Jun 14, 2022

This looks great! I appreciate the links you provided to get more context too.

Two questions/thoughts:

  1. Would these sqlcomments also be accessible via Prisma’s query logging? Or is the expectation that you have something like rsyslog hooked up to your SQL log files?
  2. Once we’re done, it might be nice to create a PR adding Prisma to their examples: https://github.com/google/sqlcommenter. This repo’s examples are linked from the blog posts, so I’d imagine it gets decent traffic.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Middleware (Reference) - Prisma
Prisma Client middleware allows you to perform actions before or after any query on any model with the prisma.$use method.
Read more >
OpenTelemetry tracing (Preview) - Prisma
Tracing provides a detailed log of the activity that Prisma Client carries out, at an operation level, including the time taken to execute...
Read more >
Raw database access (Reference) - Prisma
Prisma Client supports the option of sending raw queries to your database. You may wish to use raw queries if: you want to...
Read more >
Enable query tagging with Sqlcommenter to understand ...
Query tagging augments your SQL statements with information about your application; you could tag queries by business logic, microservice, route ...
Read more >
Get Posts With selected tags using Prisma - Stack Overflow
Notice how the only difference between your query and this one is the use of the some property. To learn more about it,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found