Skip to content

Commit ad7531b

Browse files
authored
feat(argv): Support span streaming (#6227)
### Description Reintroducing the argv integration port from #6147. Work on full support for array attributes in the product is still ongoing, but at least the trace will now load (the attribute won't be displayed), so we're not breaking anything with this change. #### Issues - Closes #5998 - Closes https://linear.app/getsentry/issue/PY-2300/migrate-argv-to-span-first #### Reminders - Please add tests to validate your changes, and lint your code using `tox -e linters`. - Add GH Issue ID _&_ Linear ID (if applicable) - PR title should use [conventional commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type) style (`feat:`, `fix:`, `ref:`, `meta:`) - For external contributors: [CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md), [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/Ww9hbqr)
1 parent 4dbc80e commit ad7531b

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

sentry_sdk/traces.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
sentry_sdk.init(_experiments={"trace_lifecycle": "stream"}).
88
"""
99

10+
import sys
1011
import uuid
1112
import warnings
1213
from datetime import datetime, timedelta, timezone
@@ -306,6 +307,8 @@ def __init__(
306307
self._start_profile()
307308
self._set_profile_id(get_profiler_id())
308309

310+
self._set_segment_attributes()
311+
309312
self._start()
310313

311314
def __repr__(self) -> str:
@@ -564,6 +567,12 @@ def _start_profile(self) -> None:
564567

565568
self._continuous_profile = try_profile_lifecycle_trace_start()
566569

570+
def _set_segment_attributes(self) -> None:
571+
if not self._is_segment():
572+
return
573+
574+
self.set_attribute("process.command_args", sys.argv)
575+
567576

568577
class NoOpStreamedSpan(StreamedSpan):
569578
__slots__ = (

tests/tracing/test_span_streaming.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,7 @@ def test_default_attributes(sentry_init, capture_envelopes):
15101510
assert item.payload.json["items"][0]["attributes"] == {
15111511
"thread.id": {"value": mock.ANY, "type": "string"},
15121512
"thread.name": {"value": "MainThread", "type": "string"},
1513+
"process.command_args": {"value": mock.ANY, "type": "array"},
15131514
"sentry.segment.id": {"value": mock.ANY, "type": "string"},
15141515
"sentry.segment.name": {"value": "test", "type": "string"},
15151516
"sentry.sdk.name": {"value": "sentry.python", "type": "string"},

0 commit comments

Comments
 (0)