88from sentry_sdk .integrations import DidNotEnable , Integration , _check_minimum_version
99from sentry_sdk .integrations .logging import ignore_logger
1010from sentry_sdk .scope import should_send_default_pii
11+ from sentry_sdk .traces import SegmentSource
1112from sentry_sdk .tracing import Span , TransactionSource
1213from sentry_sdk .tracing_utils import StreamedSpan , has_span_streaming_enabled
1314from sentry_sdk .utils import (
@@ -181,8 +182,7 @@ def on_operation(self) -> "Generator[None, None, None]":
181182 )
182183
183184 scope = sentry_sdk .get_isolation_scope ()
184- execution_context = self .execution_context
185- event_processor = _make_request_event_processor (execution_context )
185+ event_processor = _make_request_event_processor (self .execution_context )
186186 scope .add_event_processor (event_processor )
187187
188188 client = sentry_sdk .get_client ()
@@ -191,7 +191,7 @@ def on_operation(self) -> "Generator[None, None, None]":
191191 additional_attributes : "dict[str, Any]" = {}
192192
193193 if should_send_default_pii ():
194- additional_attributes ["graphql.document" ] = execution_context .query
194+ additional_attributes ["graphql.document" ] = self . execution_context .query
195195
196196 if operation_name :
197197 additional_attributes ["graphql.operation.name" ] = operation_name
@@ -211,12 +211,11 @@ def on_operation(self) -> "Generator[None, None, None]":
211211 name = description ,
212212 origin = StrawberryIntegration .origin ,
213213 )
214-
215- graphql_span .__enter__ ()
214+ graphql_span .__enter__ ()
216215
217216 if type (graphql_span ) is Span :
218217 if should_send_default_pii ():
219- graphql_span .set_data ("graphql.document" , execution_context .query )
218+ graphql_span .set_data ("graphql.document" , self . execution_context .query )
220219
221220 graphql_span .set_data ("graphql.operation.type" , operation_type )
222221 graphql_span .set_data ("graphql.operation.name" , operation_name )
@@ -226,15 +225,15 @@ def on_operation(self) -> "Generator[None, None, None]":
226225 yield
227226
228227 if type (graphql_span ) is StreamedSpan :
229- if execution_context .operation_name :
228+ if self . execution_context .operation_name :
230229 segment = graphql_span ._segment
231- segment .set_attribute ("sentry.span.source" , TransactionSource .COMPONENT )
230+ segment .set_attribute ("sentry.span.source" , SegmentSource .COMPONENT )
232231 segment .set_attribute ("sentry.op" , op )
233- segment .name = execution_context .operation_name
232+ segment .name = self . execution_context .operation_name
234233 elif isinstance (graphql_span , Span ):
235234 transaction = graphql_span .containing_transaction
236- if transaction and execution_context .operation_name :
237- transaction .name = execution_context .operation_name
235+ if transaction and self . execution_context .operation_name :
236+ transaction .name = self . execution_context .operation_name
238237 transaction .source = TransactionSource .COMPONENT
239238 transaction .op = op
240239
@@ -261,7 +260,7 @@ def on_validate(self) -> "Generator[None, None, None]":
261260
262261 yield
263262
264- if is_span_streaming_enabled and isinstance (validation_span , StreamedSpan ):
263+ if isinstance (validation_span , StreamedSpan ):
265264 validation_span .end ()
266265 else :
267266 validation_span .finish ()
@@ -287,7 +286,7 @@ def on_parse(self) -> "Generator[None, None, None]":
287286
288287 yield
289288
290- if is_span_streaming_enabled and isinstance (parsing_span , StreamedSpan ):
289+ if isinstance (parsing_span , StreamedSpan ):
291290 parsing_span .end ()
292291 else :
293292 parsing_span .finish ()
0 commit comments