@@ -273,7 +273,7 @@ def _should_be_included(
273273
274274
275275def add_source (
276- span : "Union[ sentry_sdk.tracing.Span, sentry_sdk. traces.StreamedSpan] " ,
276+ span : "sentry_sdk.traces.StreamedSpan" ,
277277 project_root : "Optional[str]" ,
278278 in_app_include : "Optional[list[str]]" ,
279279 in_app_exclude : "Optional[list[str]]" ,
@@ -317,20 +317,14 @@ def add_source(
317317 except Exception :
318318 lineno = None
319319 if lineno is not None :
320- if isinstance (span , Span ):
321- span .set_data (SPANDATA .CODE_LINENO , lineno )
322- else :
323- span .set_attribute ("code.line.number" , lineno )
320+ span .set_attribute ("code.line.number" , lineno )
324321
325322 try :
326323 namespace = frame .f_globals .get ("__name__" )
327324 except Exception :
328325 namespace = None
329326 if namespace is not None :
330- if isinstance (span , Span ):
331- span .set_data (SPANDATA .CODE_NAMESPACE , namespace )
332- else :
333- span .set_attribute (SPANDATA .CODE_NAMESPACE , namespace )
327+ span .set_attribute (SPANDATA .CODE_NAMESPACE , namespace )
334328
335329 filepath = _get_frame_module_abs_path (frame )
336330 if filepath is not None :
@@ -341,22 +335,16 @@ def add_source(
341335 else :
342336 in_app_path = filepath
343337
344- if isinstance (span , Span ):
345- span .set_data (SPANDATA .CODE_FILEPATH , in_app_path )
346- else :
347- if in_app_path is not None :
348- span .set_attribute ("code.file.path" , in_app_path )
338+ if in_app_path is not None :
339+ span .set_attribute ("code.file.path" , in_app_path )
349340
350341 try :
351342 code_function = frame .f_code .co_name
352343 except Exception :
353344 code_function = None
354345
355346 if code_function is not None :
356- if isinstance (span , Span ):
357- span .set_data (SPANDATA .CODE_FUNCTION , frame .f_code .co_name )
358- else :
359- span .set_attribute (SPANDATA .CODE_FUNCTION , frame .f_code .co_name )
347+ span .set_attribute (SPANDATA .CODE_FUNCTION , frame .f_code .co_name )
360348
361349
362350def add_query_source (
@@ -394,7 +382,7 @@ def add_query_source(
394382
395383
396384def add_http_request_source (
397- span : "Union[ sentry_sdk.tracing.Span, sentry_sdk. traces.StreamedSpan] " ,
385+ span : "sentry_sdk.traces.StreamedSpan" ,
398386) -> None :
399387 """
400388 Adds OTel compatible source code information to a span for an outgoing HTTP request
@@ -403,26 +391,14 @@ def add_http_request_source(
403391 if not client .is_active ():
404392 return
405393
406- if isinstance (span , Span ):
407- # In the StreamedSpan case, we need to add the extra span information before
408- # the span finishes, so it's expected that this will be None. In the Span case,
409- # it should already be finished.
410- if span .timestamp is None :
411- return
412-
413394 if span .start_timestamp is None :
414395 return
415396
416397 should_add_request_source = client .options .get ("enable_http_request_source" , True )
417398 if not should_add_request_source :
418399 return
419400
420- if isinstance (span , StreamedSpan ):
421- end_timestamp = span .end_timestamp
422- else :
423- end_timestamp = span .timestamp
424-
425- end_timestamp = end_timestamp or datetime .now (timezone .utc )
401+ end_timestamp = span .end_timestamp or datetime .now (timezone .utc )
426402
427403 duration = end_timestamp - span .start_timestamp
428404 threshold = client .options .get ("http_request_source_threshold_ms" , 0 )
@@ -1525,7 +1501,6 @@ def _matches(rule: "Any", value: "Any") -> bool:
15251501 BAGGAGE_HEADER_NAME ,
15261502 LOW_QUALITY_TRANSACTION_SOURCES ,
15271503 SENTRY_TRACE_HEADER_NAME ,
1528- Span ,
15291504)
15301505
15311506if TYPE_CHECKING :
0 commit comments