Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions sentry_sdk/integrations/strawberry.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,12 @@ def on_operation(self) -> "Generator[None, None, None]":
self.graphql_span.__exit__(None, None, None)

def on_validate(self) -> "Generator[None, None, None]":
self.validation_span = self.graphql_span.start_child(
graphql_span = getattr(self, "graphql_span", None)
if not graphql_span:
yield
return

self.validation_span = graphql_span.start_child(
op=OP.GRAPHQL_VALIDATE,
name="validation",
origin=StrawberryIntegration.origin,
Expand All @@ -213,7 +218,12 @@ def on_validate(self) -> "Generator[None, None, None]":
self.validation_span.finish()

def on_parse(self) -> "Generator[None, None, None]":
self.parsing_span = self.graphql_span.start_child(
graphql_span = getattr(self, "graphql_span", None)
if not graphql_span:
yield
return

self.parsing_span = graphql_span.start_child(
op=OP.GRAPHQL_PARSE,
name="parsing",
origin=StrawberryIntegration.origin,
Expand Down Expand Up @@ -256,9 +266,13 @@ async def resolve(
if self.should_skip_tracing(_next, info):
return await self._resolve(_next, root, info, *args, **kwargs)

graphql_span = getattr(self, "graphql_span", None)
if not graphql_span:
return await self._resolve(_next, root, info, *args, **kwargs)

field_path = "{}.{}".format(info.parent_type, info.field_name)

with self.graphql_span.start_child(
with graphql_span.start_child(
op=OP.GRAPHQL_RESOLVE,
name="resolving {}".format(field_path),
origin=StrawberryIntegration.origin,
Expand All @@ -283,9 +297,13 @@ def resolve(
if self.should_skip_tracing(_next, info):
return _next(root, info, *args, **kwargs)

graphql_span = getattr(self, "graphql_span", None)
if not graphql_span:
return _next(root, info, *args, **kwargs)

field_path = "{}.{}".format(info.parent_type, info.field_name)

with self.graphql_span.start_child(
with graphql_span.start_child(
op=OP.GRAPHQL_RESOLVE,
name="resolving {}".format(field_path),
origin=StrawberryIntegration.origin,
Expand Down
Loading