diff --git a/sentry_sdk/integrations/strawberry.py b/sentry_sdk/integrations/strawberry.py index da3c31a967..12676b53eb 100644 --- a/sentry_sdk/integrations/strawberry.py +++ b/sentry_sdk/integrations/strawberry.py @@ -181,19 +181,12 @@ def on_operation(self) -> "Generator[None, None, None]": event_processor = _make_request_event_processor(self.execution_context) scope.add_event_processor(event_processor) - span = sentry_sdk.get_current_span() - if span: - self.graphql_span = span.start_child( - op=op, - name=description, - origin=StrawberryIntegration.origin, - ) - else: - self.graphql_span = sentry_sdk.start_span( - op=op, - name=description, - origin=StrawberryIntegration.origin, - ) + self.graphql_span = sentry_sdk.start_span( + op=op, + name=description, + origin=StrawberryIntegration.origin, + ) + self.graphql_span.__enter__() self.graphql_span.set_data("graphql.operation.type", operation_type) self.graphql_span.set_data("graphql.operation.name", self._operation_name) @@ -208,7 +201,7 @@ def on_operation(self) -> "Generator[None, None, None]": transaction.source = TransactionSource.COMPONENT transaction.op = op - self.graphql_span.finish() + self.graphql_span.__exit__(None, None, None) def on_validate(self) -> "Generator[None, None, None]": self.validation_span = self.graphql_span.start_child(