Skip to content

Commit c9c2ded

Browse files
committed
set the process.runtime.description on the segment as part of the global event processor
1 parent 11093fc commit c9c2ded

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

sentry_sdk/integrations/stdlib.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import TYPE_CHECKING
77

88
import sentry_sdk
9+
from sentry_sdk.api import get_current_scope
910
from sentry_sdk.consts import OP, SPANDATA
1011
from sentry_sdk.integrations import Integration
1112
from 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

sentry_sdk/scope.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)