-
Couldn't load subscription status.
- Fork 569
Description
Environment
How do you use Sentry?
Sentry SaaS (sentry.io)
Which SDK and version?
Python/Django: django-sentry-1.13.5, sentry-sdk-1.3.0 (also tried sentry-sdk-1.1.0)
Steps to Reproduce
We're using Sentry in Django and Graphene (for GraphQL support). We would like to set the transaction name based on GraphQL operation name.
urlpatterns = [
# ...snip
path(
'graphql',
csrf_exempt(MyGraphQLView.as_view(graphiql=settings.GRAPHIQL_ENABLED)),
),
]
class MyGraphQLView(graphene_django.views.GraphQLView):
def execute_graphql_request(
self, request, data, query, variables, operation_name, show_graphiql=False
):
with sentry_sdk.configure_scope() as scope:
transaction_name = f'graphql.{operation_name}' # graphql.OperationName
scope.transaction = transaction_name
# This works:
scope._span._containing_transaction.name = transaction_name
return super().execute_graphql_request(
request, data, query, variables, operation_name, show_graphiql
)From the trace view in Sentry, the GraphQLView span is nested several spans down (in Django middlewares). From my understanding of the sentry documentation: set transaction name It seems like the scope.transaction = 'name' setter should be enough, but doesn't seem to work from child spans.
Expected Result
Sentry transaction name updated to graphql.OperationName.
Actual Result
Sentry transaction name stays as /graphql