From 11093fc2ed2b2d6261dec2e65c5b761581dc9b2e Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Fri, 12 Jun 2026 11:58:15 -0400 Subject: [PATCH 1/8] feat(scope): Add process runtime attributes to span context Set process.runtime.name, process.runtime.version, and process.runtime.description attributes on the scope to include Python runtime information in spans and events. This allows better runtime identification across different Python implementations (CPython, PyPy, etc.) and versions. --- sentry_sdk/scope.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index 5cf48ffc48..9e1b1f4b9d 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -1,4 +1,5 @@ import os +import platform import sys import warnings from collections import deque @@ -379,6 +380,16 @@ def set_global_attributes(self) -> None: self.set_attribute(SPANDATA.SENTRY_SDK_NAME, SDK_INFO["name"]) self.set_attribute(SPANDATA.SENTRY_SDK_VERSION, SDK_INFO["version"]) + self.set_attribute( + "process.runtime.name", + platform.python_implementation(), + ) + self.set_attribute( + "process.runtime.version", + f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + ) + self.set_attribute("process.runtime.description", sys.version) + options = sentry_sdk.get_client().options server_name = options.get("server_name") From c9c2dedb6cb5c8e165e1c91d4acdd71a3e398793 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Tue, 16 Jun 2026 13:46:41 -0400 Subject: [PATCH 2/8] set the process.runtime.description on the segment as part of the global event processor --- sentry_sdk/integrations/stdlib.py | 18 +++++++++++++++++- sentry_sdk/scope.py | 1 - 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sentry_sdk/integrations/stdlib.py b/sentry_sdk/integrations/stdlib.py index ad01672d41..1b77052c6c 100644 --- a/sentry_sdk/integrations/stdlib.py +++ b/sentry_sdk/integrations/stdlib.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING import sentry_sdk +from sentry_sdk.api import get_current_scope from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations import Integration from sentry_sdk.scope import add_global_event_processor @@ -52,7 +53,22 @@ def setup_once() -> None: def add_python_runtime_context( event: "Event", hint: "Hint" ) -> "Optional[Event]": - if sentry_sdk.get_client().get_integration(StdlibIntegration) is not None: + client = sentry_sdk.get_client() + if client.get_integration(StdlibIntegration) is not None: + is_span_streaming_enabled = has_span_streaming_enabled(client.options) + if is_span_streaming_enabled: + current_scope = get_current_scope() + segment = ( + current_scope.streamed_span._segment + if current_scope.streamed_span + else None + ) + + if segment: + segment.set_attribute( + "process.runtime.description", sys.version + ) + contexts = event.setdefault("contexts", {}) if isinstance(contexts, dict) and "runtime" not in contexts: contexts["runtime"] = _RUNTIME_CONTEXT diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index 9e1b1f4b9d..cb6723922b 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -388,7 +388,6 @@ def set_global_attributes(self) -> None: "process.runtime.version", f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", ) - self.set_attribute("process.runtime.description", sys.version) options = sentry_sdk.get_client().options From bb23e2b046e07fff58c8257b8d6fd4d781307aad Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Tue, 16 Jun 2026 14:07:45 -0400 Subject: [PATCH 3/8] update some of the tests --- sentry_sdk/integrations/stdlib.py | 6 +----- tests/integrations/logging/test_logging.py | 4 ++++ tests/integrations/loguru/test_loguru.py | 4 ++++ tests/integrations/openai/test_openai.py | 4 ++++ tests/test_logs.py | 17 +++++++++++++++++ tests/test_metrics.py | 9 +++++++++ tests/tracing/test_span_streaming.py | 9 +++++++++ 7 files changed, 48 insertions(+), 5 deletions(-) diff --git a/sentry_sdk/integrations/stdlib.py b/sentry_sdk/integrations/stdlib.py index 1b77052c6c..edde36d208 100644 --- a/sentry_sdk/integrations/stdlib.py +++ b/sentry_sdk/integrations/stdlib.py @@ -58,11 +58,7 @@ def add_python_runtime_context( is_span_streaming_enabled = has_span_streaming_enabled(client.options) if is_span_streaming_enabled: current_scope = get_current_scope() - segment = ( - current_scope.streamed_span._segment - if current_scope.streamed_span - else None - ) + segment = getattr(current_scope.streamed_span, "_segment", None) if segment: segment.set_attribute( diff --git a/tests/integrations/logging/test_logging.py b/tests/integrations/logging/test_logging.py index 6b54baa0c5..618cc3d07c 100644 --- a/tests/integrations/logging/test_logging.py +++ b/tests/integrations/logging/test_logging.py @@ -1,4 +1,6 @@ import logging +import platform +import sys import warnings import pytest @@ -537,6 +539,8 @@ def test_logger_with_all_attributes(sentry_init, capture_items): "logger.name": "test-logger", "sentry.origin": "auto.log.stdlib", "sentry.message.template": "log #%d", + "process.runtime.name": platform.python_implementation(), + "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", "sentry.message.parameter.0": 1, "sentry.environment": "production", "sentry.sdk.version": VERSION, diff --git a/tests/integrations/loguru/test_loguru.py b/tests/integrations/loguru/test_loguru.py index 57b67d74b9..ec7004c785 100644 --- a/tests/integrations/loguru/test_loguru.py +++ b/tests/integrations/loguru/test_loguru.py @@ -1,4 +1,6 @@ +import platform import re +import sys from unittest.mock import MagicMock, patch import pytest @@ -466,6 +468,8 @@ def test_logger_with_all_attributes( "logger.name": "tests.integrations.loguru.test_loguru", "sentry.origin": "auto.log.loguru", "sentry.environment": "production", + "process.runtime.name": platform.python_implementation(), + "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", "sentry.sdk.version": VERSION, "sentry.severity_number": 13, "sentry.severity_text": "warn", diff --git a/tests/integrations/openai/test_openai.py b/tests/integrations/openai/test_openai.py index 5ca4cb7d5a..313c06a807 100644 --- a/tests/integrations/openai/test_openai.py +++ b/tests/integrations/openai/test_openai.py @@ -1,4 +1,6 @@ import json +import platform +import sys import pytest @@ -4975,6 +4977,8 @@ async def test_ai_client_span_streaming_responses_async_api( "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", + "process.runtime.name": platform.python_implementation(), + "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", "sentry.release": mock.ANY, "sentry.sdk.name": "sentry.python", "sentry.sdk.version": mock.ANY, diff --git a/tests/test_logs.py b/tests/test_logs.py index 384e2c9464..a7cc1d2dfb 100644 --- a/tests/test_logs.py +++ b/tests/test_logs.py @@ -1,5 +1,6 @@ import logging import os +import platform import sys import time from unittest import mock @@ -495,6 +496,14 @@ def test_transport_format(sentry_init, capture_envelopes): "type": "integer", "value": 13, }, + "process.runtime.name": { + "type": "string", + "value": platform.python_implementation(), + }, + "process.runtime.version": { + "type": "string", + "value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + }, "sentry.severity_text": { "type": "string", "value": "warn", @@ -574,6 +583,14 @@ def record_lost_event(reason, data_category=None, item=None, *, quantity=1): "type": "integer", "value": 9, }, + "process.runtime.name": { + "type": "string", + "value": platform.python_implementation(), + }, + "process.runtime.version": { + "type": "string", + "value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + }, "sentry.severity_text": { "type": "string", "value": "info", diff --git a/tests/test_metrics.py b/tests/test_metrics.py index c05a0fad7e..7eaf0fbe9c 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -1,4 +1,5 @@ import os +import platform import sys from unittest import mock @@ -284,6 +285,14 @@ def test_transport_format(sentry_init, capture_envelopes): "type": "string", "value": "1.0.0", }, + "process.runtime.name": { + "type": "string", + "value": platform.python_implementation(), + }, + "process.runtime.version": { + "type": "string", + "value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + }, "sentry.sdk.name": { "type": "string", "value": mock.ANY, diff --git a/tests/tracing/test_span_streaming.py b/tests/tracing/test_span_streaming.py index d8537ea779..bacf780911 100644 --- a/tests/tracing/test_span_streaming.py +++ b/tests/tracing/test_span_streaming.py @@ -1,4 +1,5 @@ import asyncio +import platform import re import sys import time @@ -1722,4 +1723,12 @@ def test_default_attributes(sentry_init, capture_envelopes): "sentry.dist": {"value": "1.0", "type": "string"}, "sentry.origin": {"value": "manual", "type": "string"}, "sentry.sdk.integrations": {"value": mock.ANY, "type": "array"}, + "process.runtime.name": { + "type": "string", + "value": platform.python_implementation(), + }, + "process.runtime.version": { + "type": "string", + "value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + }, } From 7404b69c6c71452ace29574f16c62e180721cafa Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Tue, 16 Jun 2026 14:50:50 -0400 Subject: [PATCH 4/8] add process.runtime variables to the _serialized_v1_span_to_serialized_v2_span function --- sentry_sdk/client.py | 7 +++++++ tests/integrations/openai/test_openai.py | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index 5ea7c00478..81fb8c385c 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -1,7 +1,9 @@ import json import os +import platform import random import socket +import sys import uuid import warnings from collections.abc import Iterable, Mapping @@ -241,6 +243,11 @@ def _serialized_v1_span_to_serialized_v2_span( if "version" in sdk_info: attributes["sentry.sdk.version"] = sdk_info["version"] + attributes["process.runtime.name"] = platform.python_implementation() + attributes["process.runtime.version"] = ( + f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}" + ) + if not attributes: return res diff --git a/tests/integrations/openai/test_openai.py b/tests/integrations/openai/test_openai.py index 313c06a807..425555e178 100644 --- a/tests/integrations/openai/test_openai.py +++ b/tests/integrations/openai/test_openai.py @@ -3834,6 +3834,8 @@ def test_ai_client_span_responses_api_no_pii( "gen_ai.usage.output_tokens": 10, "gen_ai.usage.output_tokens.reasoning": 8, "gen_ai.usage.total_tokens": 30, + "process.runtime.name": platform.python_implementation(), + "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", @@ -3880,6 +3882,8 @@ def test_ai_client_span_responses_api_no_pii( "gen_ai.usage.output_tokens": 10, "gen_ai.usage.output_tokens.reasoning": 8, "gen_ai.usage.total_tokens": 30, + "process.runtime.name": platform.python_implementation(), + "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", @@ -4141,6 +4145,8 @@ def test_ai_client_span_responses_api( "gen_ai.request.messages": safe_serialize(expected_request_messages), "gen_ai.request.model": "gpt-4o", "gen_ai.response.text": "the model response", + "process.runtime.name": platform.python_implementation(), + "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", @@ -4193,6 +4199,8 @@ def test_ai_client_span_responses_api( "gen_ai.request.messages": safe_serialize(expected_request_messages), "gen_ai.request.model": "gpt-4o", "gen_ai.response.text": "the model response", + "process.runtime.name": platform.python_implementation(), + "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", @@ -4628,6 +4636,8 @@ async def test_ai_client_span_responses_async_api( "gen_ai.usage.output_tokens.reasoning": 8, "gen_ai.usage.total_tokens": 30, "gen_ai.response.text": "the model response", + "process.runtime.name": platform.python_implementation(), + "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", @@ -4680,6 +4690,8 @@ async def test_ai_client_span_responses_async_api( "gen_ai.usage.output_tokens.reasoning": 8, "gen_ai.usage.total_tokens": 30, "gen_ai.response.text": "the model response", + "process.runtime.name": platform.python_implementation(), + "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", From 62459470f749d3f307a2a56e28d2333fe5f7ed47 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Wed, 17 Jun 2026 08:31:40 -0400 Subject: [PATCH 5/8] update huggingface tests. migrate over to ANY in the other tests --- .../huggingface_hub/test_huggingface_hub.py | 14 ++++++++++ tests/integrations/logging/test_logging.py | 4 +-- tests/integrations/loguru/test_loguru.py | 4 +-- tests/integrations/openai/test_openai.py | 28 +++++++++---------- tests/test_logs.py | 8 +++--- tests/test_metrics.py | 4 +-- tests/tracing/test_decorator.py | 12 ++++++++ tests/tracing/test_span_streaming.py | 4 +-- 8 files changed, 52 insertions(+), 26 deletions(-) diff --git a/tests/integrations/huggingface_hub/test_huggingface_hub.py b/tests/integrations/huggingface_hub/test_huggingface_hub.py index 028e710ad2..91e0909731 100644 --- a/tests/integrations/huggingface_hub/test_huggingface_hub.py +++ b/tests/integrations/huggingface_hub/test_huggingface_hub.py @@ -521,6 +521,8 @@ def test_text_generation( "gen_ai.response.finish_reasons": "length", "gen_ai.response.streaming": False, "gen_ai.usage.total_tokens": 10, + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.text_completion", "sentry.origin": "auto.ai.huggingface_hub", @@ -658,6 +660,8 @@ def test_text_generation_streaming( "gen_ai.response.finish_reasons": "length", "gen_ai.response.streaming": True, "gen_ai.usage.total_tokens": 10, + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.text_completion", "sentry.origin": "auto.ai.huggingface_hub", @@ -799,6 +803,8 @@ def test_chat_completion( "gen_ai.usage.input_tokens": 10, "gen_ai.usage.output_tokens": 8, "gen_ai.usage.total_tokens": 18, + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.chat", "sentry.origin": "auto.ai.huggingface_hub", @@ -948,6 +954,8 @@ def test_chat_completion_streaming( "gen_ai.response.finish_reasons": "stop", "gen_ai.response.model": "test-model-123", "gen_ai.response.streaming": True, + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.chat", "sentry.origin": "auto.ai.huggingface_hub", @@ -1095,6 +1103,8 @@ def test_chat_completion_api_error( expected_data = { "gen_ai.operation.name": "chat", "gen_ai.request.model": "test-model", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.chat", "sentry.origin": "auto.ai.huggingface_hub", @@ -1294,6 +1304,8 @@ def test_chat_completion_with_tools( "gen_ai.usage.input_tokens": 10, "gen_ai.usage.output_tokens": 8, "gen_ai.usage.total_tokens": 18, + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.chat", "sentry.origin": "auto.ai.huggingface_hub", @@ -1454,6 +1466,8 @@ def test_chat_completion_streaming_with_tools( "gen_ai.response.finish_reasons": "tool_calls", "gen_ai.response.model": "test-model-123", "gen_ai.response.streaming": True, + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.chat", "sentry.origin": "auto.ai.huggingface_hub", diff --git a/tests/integrations/logging/test_logging.py b/tests/integrations/logging/test_logging.py index 618cc3d07c..ced01ed6ce 100644 --- a/tests/integrations/logging/test_logging.py +++ b/tests/integrations/logging/test_logging.py @@ -539,8 +539,8 @@ def test_logger_with_all_attributes(sentry_init, capture_items): "logger.name": "test-logger", "sentry.origin": "auto.log.stdlib", "sentry.message.template": "log #%d", - "process.runtime.name": platform.python_implementation(), - "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.message.parameter.0": 1, "sentry.environment": "production", "sentry.sdk.version": VERSION, diff --git a/tests/integrations/loguru/test_loguru.py b/tests/integrations/loguru/test_loguru.py index ec7004c785..b5e5cb44fd 100644 --- a/tests/integrations/loguru/test_loguru.py +++ b/tests/integrations/loguru/test_loguru.py @@ -468,8 +468,8 @@ def test_logger_with_all_attributes( "logger.name": "tests.integrations.loguru.test_loguru", "sentry.origin": "auto.log.loguru", "sentry.environment": "production", - "process.runtime.name": platform.python_implementation(), - "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.sdk.version": VERSION, "sentry.severity_number": 13, "sentry.severity_text": "warn", diff --git a/tests/integrations/openai/test_openai.py b/tests/integrations/openai/test_openai.py index 425555e178..976d90cd85 100644 --- a/tests/integrations/openai/test_openai.py +++ b/tests/integrations/openai/test_openai.py @@ -3834,8 +3834,8 @@ def test_ai_client_span_responses_api_no_pii( "gen_ai.usage.output_tokens": 10, "gen_ai.usage.output_tokens.reasoning": 8, "gen_ai.usage.total_tokens": 30, - "process.runtime.name": platform.python_implementation(), - "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", @@ -3882,8 +3882,8 @@ def test_ai_client_span_responses_api_no_pii( "gen_ai.usage.output_tokens": 10, "gen_ai.usage.output_tokens.reasoning": 8, "gen_ai.usage.total_tokens": 30, - "process.runtime.name": platform.python_implementation(), - "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", @@ -4145,8 +4145,8 @@ def test_ai_client_span_responses_api( "gen_ai.request.messages": safe_serialize(expected_request_messages), "gen_ai.request.model": "gpt-4o", "gen_ai.response.text": "the model response", - "process.runtime.name": platform.python_implementation(), - "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", @@ -4199,8 +4199,8 @@ def test_ai_client_span_responses_api( "gen_ai.request.messages": safe_serialize(expected_request_messages), "gen_ai.request.model": "gpt-4o", "gen_ai.response.text": "the model response", - "process.runtime.name": platform.python_implementation(), - "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", @@ -4636,8 +4636,8 @@ async def test_ai_client_span_responses_async_api( "gen_ai.usage.output_tokens.reasoning": 8, "gen_ai.usage.total_tokens": 30, "gen_ai.response.text": "the model response", - "process.runtime.name": platform.python_implementation(), - "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", @@ -4690,8 +4690,8 @@ async def test_ai_client_span_responses_async_api( "gen_ai.usage.output_tokens.reasoning": 8, "gen_ai.usage.total_tokens": 30, "gen_ai.response.text": "the model response", - "process.runtime.name": platform.python_implementation(), - "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", @@ -4989,8 +4989,8 @@ async def test_ai_client_span_streaming_responses_async_api( "sentry.environment": "production", "sentry.op": "gen_ai.responses", "sentry.origin": "auto.ai.openai", - "process.runtime.name": platform.python_implementation(), - "process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.release": mock.ANY, "sentry.sdk.name": "sentry.python", "sentry.sdk.version": mock.ANY, diff --git a/tests/test_logs.py b/tests/test_logs.py index a7cc1d2dfb..c4472c92e3 100644 --- a/tests/test_logs.py +++ b/tests/test_logs.py @@ -498,11 +498,11 @@ def test_transport_format(sentry_init, capture_envelopes): }, "process.runtime.name": { "type": "string", - "value": platform.python_implementation(), + "value": mock.ANY, }, "process.runtime.version": { "type": "string", - "value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "value": mock.ANY, }, "sentry.severity_text": { "type": "string", @@ -585,11 +585,11 @@ def record_lost_event(reason, data_category=None, item=None, *, quantity=1): }, "process.runtime.name": { "type": "string", - "value": platform.python_implementation(), + "value": mock.ANY, }, "process.runtime.version": { "type": "string", - "value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "value": mock.ANY, }, "sentry.severity_text": { "type": "string", diff --git a/tests/test_metrics.py b/tests/test_metrics.py index 7eaf0fbe9c..188826a4fd 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -287,11 +287,11 @@ def test_transport_format(sentry_init, capture_envelopes): }, "process.runtime.name": { "type": "string", - "value": platform.python_implementation(), + "value": mock.ANY, }, "process.runtime.version": { "type": "string", - "value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "value": mock.ANY, }, "sentry.sdk.name": { "type": "string", diff --git a/tests/tracing/test_decorator.py b/tests/tracing/test_decorator.py index bfb652b529..a1a824553f 100644 --- a/tests/tracing/test_decorator.py +++ b/tests/tracing/test_decorator.py @@ -187,6 +187,8 @@ def my_agent(): assert agent_span["attributes"] == { "gen_ai.agent.name": "test_decorator.test_span_templates_ai_dicts..my_agent", "gen_ai.operation.name": "invoke_agent", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.invoke_agent", "sentry.origin": "manual", @@ -210,6 +212,8 @@ def my_agent(): "gen_ai.usage.input_tokens": 10, "gen_ai.usage.output_tokens": 20, "gen_ai.usage.total_tokens": 30, + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.execute_tool", "sentry.origin": "manual", @@ -239,6 +243,8 @@ def my_agent(): "gen_ai.usage.input_tokens": 11, "gen_ai.usage.output_tokens": 22, "gen_ai.usage.total_tokens": 33, + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.chat", "sentry.origin": "manual", @@ -384,6 +390,8 @@ def my_agent(): assert agent_span["attributes"] == { "gen_ai.agent.name": "test_decorator.test_span_templates_ai_objects..my_agent", "gen_ai.operation.name": "invoke_agent", + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.invoke_agent", "sentry.origin": "manual", @@ -408,6 +416,8 @@ def my_agent(): "gen_ai.usage.input_tokens": 10, "gen_ai.usage.output_tokens": 20, "gen_ai.usage.total_tokens": 30, + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.execute_tool", "sentry.origin": "manual", @@ -436,6 +446,8 @@ def my_agent(): "gen_ai.usage.input_tokens": 11, "gen_ai.usage.output_tokens": 22, "gen_ai.usage.total_tokens": 33, + "process.runtime.name": mock.ANY, + "process.runtime.version": mock.ANY, "sentry.environment": "production", "sentry.op": "gen_ai.chat", "sentry.origin": "manual", diff --git a/tests/tracing/test_span_streaming.py b/tests/tracing/test_span_streaming.py index bacf780911..3a132f560a 100644 --- a/tests/tracing/test_span_streaming.py +++ b/tests/tracing/test_span_streaming.py @@ -1725,10 +1725,10 @@ def test_default_attributes(sentry_init, capture_envelopes): "sentry.sdk.integrations": {"value": mock.ANY, "type": "array"}, "process.runtime.name": { "type": "string", - "value": platform.python_implementation(), + "value": mock.ANY, }, "process.runtime.version": { "type": "string", - "value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}", + "value": mock.ANY, }, } From ed5dafaf9a6ecf6ca8b1072763d9024de48b7a9c Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Wed, 17 Jun 2026 08:36:22 -0400 Subject: [PATCH 6/8] remove unused imports --- tests/integrations/logging/test_logging.py | 3 +-- tests/integrations/loguru/test_loguru.py | 8 +++----- tests/integrations/openai/test_openai.py | 2 -- tests/test_logs.py | 1 - tests/test_metrics.py | 1 - tests/tracing/test_span_streaming.py | 1 - 6 files changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/integrations/logging/test_logging.py b/tests/integrations/logging/test_logging.py index ced01ed6ce..16275eeb3d 100644 --- a/tests/integrations/logging/test_logging.py +++ b/tests/integrations/logging/test_logging.py @@ -1,7 +1,6 @@ import logging -import platform -import sys import warnings +from unittest import mock import pytest diff --git a/tests/integrations/loguru/test_loguru.py b/tests/integrations/loguru/test_loguru.py index b5e5cb44fd..52ff4635bd 100644 --- a/tests/integrations/loguru/test_loguru.py +++ b/tests/integrations/loguru/test_loguru.py @@ -1,7 +1,5 @@ -import platform import re -import sys -from unittest.mock import MagicMock, patch +from unittest.mock import ANY, MagicMock, patch import pytest from loguru import logger @@ -468,8 +466,8 @@ def test_logger_with_all_attributes( "logger.name": "tests.integrations.loguru.test_loguru", "sentry.origin": "auto.log.loguru", "sentry.environment": "production", - "process.runtime.name": mock.ANY, - "process.runtime.version": mock.ANY, + "process.runtime.name": ANY, + "process.runtime.version": ANY, "sentry.sdk.version": VERSION, "sentry.severity_number": 13, "sentry.severity_text": "warn", diff --git a/tests/integrations/openai/test_openai.py b/tests/integrations/openai/test_openai.py index 976d90cd85..df9e7079de 100644 --- a/tests/integrations/openai/test_openai.py +++ b/tests/integrations/openai/test_openai.py @@ -1,6 +1,4 @@ import json -import platform -import sys import pytest diff --git a/tests/test_logs.py b/tests/test_logs.py index c4472c92e3..0cf33cd6c5 100644 --- a/tests/test_logs.py +++ b/tests/test_logs.py @@ -1,6 +1,5 @@ import logging import os -import platform import sys import time from unittest import mock diff --git a/tests/test_metrics.py b/tests/test_metrics.py index 188826a4fd..e62a868dbe 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -1,5 +1,4 @@ import os -import platform import sys from unittest import mock diff --git a/tests/tracing/test_span_streaming.py b/tests/tracing/test_span_streaming.py index 3a132f560a..d379bbc9d7 100644 --- a/tests/tracing/test_span_streaming.py +++ b/tests/tracing/test_span_streaming.py @@ -1,5 +1,4 @@ import asyncio -import platform import re import sys import time From 35b3161dce80ae5acdf3dbbd49d90a84f070a2cb Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Thu, 18 Jun 2026 08:27:24 -0400 Subject: [PATCH 7/8] remove process.runtime.description --- sentry_sdk/integrations/stdlib.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/sentry_sdk/integrations/stdlib.py b/sentry_sdk/integrations/stdlib.py index edde36d208..4e31f36415 100644 --- a/sentry_sdk/integrations/stdlib.py +++ b/sentry_sdk/integrations/stdlib.py @@ -55,16 +55,6 @@ def add_python_runtime_context( ) -> "Optional[Event]": client = sentry_sdk.get_client() if client.get_integration(StdlibIntegration) is not None: - is_span_streaming_enabled = has_span_streaming_enabled(client.options) - if is_span_streaming_enabled: - current_scope = get_current_scope() - segment = getattr(current_scope.streamed_span, "_segment", None) - - if segment: - segment.set_attribute( - "process.runtime.description", sys.version - ) - contexts = event.setdefault("contexts", {}) if isinstance(contexts, dict) and "runtime" not in contexts: contexts["runtime"] = _RUNTIME_CONTEXT From 7b15d1549bcaa222dc9e79aeaa824db5e29a330e Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Thu, 18 Jun 2026 08:28:39 -0400 Subject: [PATCH 8/8] lint --- sentry_sdk/integrations/stdlib.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sentry_sdk/integrations/stdlib.py b/sentry_sdk/integrations/stdlib.py index 4e31f36415..4e813a8345 100644 --- a/sentry_sdk/integrations/stdlib.py +++ b/sentry_sdk/integrations/stdlib.py @@ -6,7 +6,6 @@ from typing import TYPE_CHECKING import sentry_sdk -from sentry_sdk.api import get_current_scope from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations import Integration from sentry_sdk.scope import add_global_event_processor