Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify process.runtime for Python. #1160

Merged

Conversation

Oberon00
Copy link
Member

Fixes open-telemetry/opentelemetry-python#1127

Changes

Specifies process.runtime.* attributes for Python.

CC @open-telemetry/python-approvers

Note that on Linux, there is an actual newline in the `sys.version` string,
and the CPython string had a trailing space in the first line.

Pypy provided a CPython-compatible version in `sys.implementation.version` instead of the actual implementation version which is available in `sys.version`.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit sad. We could another special case for PyPy to the runtime.version determination to use

>>>> sys.pypy_version_info
(major=7, minor=3, micro=2, releaselevel='alpha', serial=0)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable since PyPy is not conforming to the docs here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it is too late to change this in this PR now, unless there is a strong opinion. @open-telemetry/python-approvers feel free to suggest a follow-up spec PR if this comes up again when implementing.

specification/resource/semantic_conventions/process.md Outdated Show resolved Hide resolved
Comment on lines 97 to 98
Fill in the [`sys.implementation.version`][py_impl] values separated by dots.
Fall back to using [`sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info) if that is not available.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may need an additional field for the version of the language (which defines the syntax and standard library API) after reading the docs for sys.implementation:

version is a named tuple, in the same format as sys.version_info. It represents the version of the Python implementation. This has a distinct meaning from the specific version of the Python language to which the currently running interpreter conforms, which sys.version_info represents. For example, for PyPy 1.8 sys.implementation.version might be sys.version_info(1, 8, 0, 'final', 0), whereas sys.version_info would be sys.version_info(2, 7, 2, 'final', 0). For CPython they are the same value, since it is the reference implementation.

For CPython they are the same but for PyPy they are independent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For PyPy they are also the same, unfortunately (see note below). We could add additional fields for that, true, maybe python.runtime.lang_version. But I did not want to add new fields in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, that is funny considering the quote from the python docs no longer holds true for PyPy 😕 . But could this effect other languages and would be worth adding process.runtime.language_version or similar?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be useful, but I think it is out of scope for this PR.

The new attribute might better be Python-specific though. For example, I don't think it makes much sense for JVMs or .NET runtimes which support multiple languages.

Note that on Linux, there is an actual newline in the `sys.version` string,
and the CPython string had a trailing space in the first line.

Pypy provided a CPython-compatible version in `sys.implementation.version` instead of the actual implementation version which is available in `sys.version`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable since PyPy is not conforming to the docs here

specification/resource/semantic_conventions/process.md Outdated Show resolved Hide resolved
Comment on lines +105 to +110
result = ".".join(map(
str,
vinfo[:3]
if vinfo.releaselevel == "final" and not vinfo.serial
else vinfo
))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be OK now. Example result might be

In [1]: from packaging import version

In [2]: version.parse('3.9.1.alpha.3')
Out[2]: <Version('3.9.1a3')>

so it is still a correct version.

Copy link
Contributor

@lzchen lzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@arminru arminru requested a review from codeboten November 3, 2020 11:05
Copy link
Member

@arminru arminru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubber-stamping since we have approvals from an OTel-Python maintainer and an approver

@carlosalberto carlosalberto self-requested a review November 3, 2020 14:39
@carlosalberto
Copy link
Contributor

@codeboten Any opinion/approval?

@arminru arminru merged commit 0dc869a into open-telemetry:master Nov 9, 2020
@arminru arminru deleted the python-runtime-info branch November 9, 2020 15:52
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confirm specification for runtime information
6 participants