File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66from typing import TYPE_CHECKING
77
88import sentry_sdk
9+ from sentry_sdk .api import get_current_scope
910from sentry_sdk .consts import OP , SPANDATA
1011from sentry_sdk .integrations import Integration
1112from sentry_sdk .scope import add_global_event_processor
@@ -52,7 +53,22 @@ def setup_once() -> None:
5253 def add_python_runtime_context (
5354 event : "Event" , hint : "Hint"
5455 ) -> "Optional[Event]" :
55- if sentry_sdk .get_client ().get_integration (StdlibIntegration ) is not None :
56+ client = sentry_sdk .get_client ()
57+ if client .get_integration (StdlibIntegration ) is not None :
58+ is_span_streaming_enabled = has_span_streaming_enabled (client .options )
59+ if is_span_streaming_enabled :
60+ current_scope = get_current_scope ()
61+ segment = (
62+ current_scope .streamed_span ._segment
63+ if current_scope .streamed_span
64+ else None
65+ )
66+
67+ if segment :
68+ segment .set_attribute (
69+ "process.runtime.description" , sys .version
70+ )
71+
5672 contexts = event .setdefault ("contexts" , {})
5773 if isinstance (contexts , dict ) and "runtime" not in contexts :
5874 contexts ["runtime" ] = _RUNTIME_CONTEXT
Original file line number Diff line number Diff line change @@ -388,7 +388,6 @@ def set_global_attributes(self) -> None:
388388 "process.runtime.version" ,
389389 f"{ sys .version_info .major } .{ sys .version_info .minor } .{ sys .version_info .micro } " ,
390390 )
391- self .set_attribute ("process.runtime.description" , sys .version )
392391
393392 options = sentry_sdk .get_client ().options
394393
You can’t perform that action at this time.
0 commit comments