sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

GrapheneIntegration: Enhance Transaction Naming for Errors in Graphene GraphQL Operations

Open czyber opened this issue 1 year ago • 5 comments

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.

image

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.

image

This should be just a small change - i'm happy to do it 😄

czyber avatar Feb 26 '24 19:02 czyber

Hey @czyber thanks for writing in. What Version of the SDK are you using?

antonpirker avatar Feb 27 '24 07:02 antonpirker

I used 1.40.0 for the above example

czyber avatar Feb 27 '24 07:02 czyber

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?

sentrivana avatar Feb 28 '24 13:02 sentrivana

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.

czyber avatar Mar 05 '24 18:03 czyber

Thanks @czyber, we will take a look!

sentrivana avatar Mar 07 '24 11:03 sentrivana

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!

antonpirker avatar Jun 06 '24 15:06 antonpirker