Skip to content

Setting transaction name doesn't work from child span. #1155

Description

@CoatedMoose

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= [
# ...snippath(
'graphql',
csrf_exempt(MyGraphQLView.as_view(graphiql=settings.GRAPHIQL_ENABLED)),
),
]
classMyGraphQLView(graphene_django.views.GraphQLView):
defexecute_graphql_request(
self, request, data, query, variables, operation_name, show_graphiql=False
):
withsentry_sdk.configure_scope() asscope:
transaction_name=f'graphql.{operation_name}'# graphql.OperationNamescope.transaction=transaction_name# This works:scope._span._containing_transaction.name=transaction_namereturnsuper().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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions