Skip to content

Commit 6db2e8a

Browse files
committed
nit: drop sys.orig_argv fallback and use PR number in changelog
Two review nits from MikeGoldsmith: - sys.orig_argv has been available since Python 3.10; the SDK now requires 3.10+ so the getattr fallback is dead code. Use sys.orig_argv directly and update the comment. - CHANGELOG entries should reference the PR number, not the issue number. Signed-off-by: Ali <alliasgher123@gmail.com>
1 parent a2914f3 commit 6db2e8a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
([#4907](https://github.com/open-telemetry/opentelemetry-python/issues/4907))
2121
- Drop Python 3.9 support
2222
([#5076](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/5076))
23-
- `opentelemetry-sdk`: Fix `ProcessResourceDetector` to use `sys.orig_argv` when available so that `process.command`, `process.command_line`, and `process.command_args` reflect the original invocation for `python -m <module>` runs (where `sys.argv[0]` is rewritten to the module path)
24-
([#4518](https://github.com/open-telemetry/opentelemetry-python/issues/4518))
23+
- `opentelemetry-sdk`: Fix `ProcessResourceDetector` to use `sys.orig_argv` so that `process.command`, `process.command_line`, and `process.command_args` reflect the original invocation for `python -m <module>` runs (where `sys.argv[0]` is rewritten to the module path)
24+
([#5083](https://github.com/open-telemetry/opentelemetry-python/pull/5083))
2525

2626

2727
## Version 1.41.0/0.62b0 (2026-04-09)

opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,13 @@ def detect(self) -> "Resource":
380380
_process_pid = os.getpid()
381381
_process_executable_name = sys.executable
382382
_process_executable_path = os.path.dirname(_process_executable_name)
383-
# Prefer sys.orig_argv (Python 3.10+), which preserves the original
384-
# arguments received by the interpreter. This correctly captures
385-
# ``python -m <module>`` invocations where sys.argv is rewritten to
386-
# the resolved module path and the ``-m <module>`` information is
387-
# lost. sys.orig_argv also aligns with /proc/<pid>/cmdline, which
388-
# the OTel semantic conventions reference for these attributes.
389-
_process_argv = list(getattr(sys, "orig_argv", sys.argv))
383+
# Use sys.orig_argv, which preserves the original arguments received
384+
# by the interpreter. This correctly captures ``python -m <module>``
385+
# invocations where sys.argv is rewritten to the resolved module path
386+
# and the ``-m <module>`` information is lost. sys.orig_argv also
387+
# aligns with /proc/<pid>/cmdline, which the OTel semantic
388+
# conventions reference for these attributes.
389+
_process_argv = list(sys.orig_argv)
390390
_process_command = _process_argv[0] if _process_argv else ""
391391
_process_command_line = " ".join(_process_argv)
392392
_process_command_args = _process_argv

0 commit comments

Comments
 (0)