Skip to content
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

Ability to See the Stacktrace for Query Issues #87502

Open
Ahmed-Elkholy opened this issue Mar 20, 2025 · 5 comments
Open

Ability to See the Stacktrace for Query Issues #87502

Ahmed-Elkholy opened this issue Mar 20, 2025 · 5 comments

Comments

@Ahmed-Elkholy
Copy link

Environment

SaaS (https://sentry.io/)

What are you trying to accomplish?

We want to easily identify the source of N+1 queries or slow queries by seeing their stacktrace. This would help us pinpoint where in the code the query is being generated, as it is not always straightforward to trace.

How are you getting stuck?

Currently, when investigating performance issues related to N+1 queries or slow queries, it is difficult to determine exactly where in our codebase they originate. While we can see query execution details, we don’t always get a clear stacktrace showing the function or file responsible for triggering them.

Is there a way in Sentry to view the stacktrace of these queries to help us debug more efficiently? If not, is there an alternative approach or workaround you recommend?

Where in the product are you?

Performance - Queries

Link

No response

DSN

No response

Version

No response

@getsantry
Copy link
Contributor

getsantry bot commented Mar 20, 2025

Assigning to @getsentry/support for routing ⏲️

@getsantry
Copy link
Contributor

getsantry bot commented Mar 24, 2025

Routing to @getsentry/product-owners-performance for triage ⏲️

@getsantry getsantry bot moved this from Waiting for: Support to Waiting for: Product Owner in GitHub Issues with 👀 3 Mar 24, 2025
@gggritso
Copy link
Member

@Ahmed-Elkholy thanks for raising this! I think Query Sources will help you. If you set up the SDK correctly, when you look at the Query Details page, you'll see the line of code where the query originated (though not the full stack trace). Watch out, we only gather query sources for slow queries (100ms or slower) so if you're seeing fast N+1s you might need to turn down the slow query threshold.

If you're not using one of the SDKs that supports Query Sources, you can still manually instrument them, though it's more work.

Would that work?

@Ahmed-Elkholy
Copy link
Author

@gggritso Thanks so much for your reply. We have a spring boot application and we are using JDBC Instrumentation https://docs.sentry.io/platforms/java/tracing/instrumentation/jdbc/. It seems like it does not support Query Source automatically, but I am not sure who can we manually instrument this. Can you guide me to the documentation for this? Thanks!

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Mar 26, 2025
@gggritso
Copy link
Member

@Ahmed-Elkholy I think you're the first person to ask how to do this manually! We don't have a lot of documentation on this topic, but I can link you to what I know:

You also might be able to ask for help from SDK folks in our Discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants