GrapheneIntegration: Enhance Transaction Naming for Errors in Graphene GraphQL Operations
Problem Statement
Currently when an exception or error occurs during the processing of a GraphQL operation by Graphene, the transaction name assigned to the reported issue is often not as descriptive as it could be. This lack of specificity in the transaction naming makes it challenging to quickly identify and address the source of the problem, and there are already existing workarounds such as described in this article.
Solution Brainstorm
Setting the transaction name of the current scope to the operation type and the operation name, would add more meaning to the issues, and one could see which operation was called at first glance.
This should be just a small change - i'm happy to do it 😄
Hey @czyber thanks for writing in. What Version of the SDK are you using?
I used 1.40.0 for the above example
Hey @czyber, I'm not sure if we should rename the transaction -- the transaction is coming from the WSGI integration. (We should also not create a separate transaction because nested transactions are not supported.) What we do in a similar case (strawberry-graphql) is leave the WSGI transaction as is, but create a child span with all the important GraphQL data: https://github.com/getsentry/sentry-python/blob/f87440749ccda8c7dcf3f0403a6cf9650fedd843/sentry_sdk/integrations/strawberry.py#L169 What do you think about that approach?
Hi @sentrivana, i think creating a child span should be sufficient for most cases. After thinking a bit about it, setting the transaction name of the wsgi integration is really not the way 😅
I added a child span, analogous to the way it is done for strawberry-graphql.
Thanks @czyber, we will take a look!
Hey @czyber !
We are really not the fastest at looking at contributions right now. (didnt know you also did some graphene contributions)
Is this the change you want to contribute: https://github.com/getsentry/sentry-python/compare/master...czyber:sentry-python:feature/add-graphene-child-span
(could you update your branch to the lastest sentry master and create a PR? or if there is already one, please link me to it) Thanks!