-
Notifications
You must be signed in to change notification settings - Fork 893
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
Changes from 2 commits
22891c8
963b491
fc4d621
98f9beb
2c0e8ba
1709b13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,16 +88,46 @@ TODO(<https://github.com/open-telemetry/opentelemetry-dotnet/issues/1281>): Conf | |
|
||
***Python Runtimes:*** | ||
|
||
TODO(<https://github.com/open-telemetry/opentelemetry-python/issues/1127>): Confirm the contents here | ||
Python instrumentation should fill in the values as follows: | ||
|
||
| Value | Description | | ||
| --- | --- | | ||
| `cpython` | CPython | | ||
| `graalvm` | GraalVM | | ||
| `ironpython` | IronPython | | ||
| `jython` | Jython | | ||
| `pypy` | PyPy| | ||
| `pythonnet` | PythonNet | | ||
- `process.runtime.name` - | ||
Fill in the value of [`sys.implementation.name`][py_impl] | ||
(fall back to [`platform.python_implementation().lower()`](https://docs.python.org/3/library/platform.html#platform.python_implementation) if `sys.implementation` is not available) | ||
- `process.runtime.version` - | ||
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. | ||
Leave out the release level and serial if the release level | ||
equals `final` and the serial equals zero | ||
(leave out either both or none). | ||
|
||
This can be implemented with the following Python snippet: | ||
|
||
```python | ||
vinfo = sys.implementation.version | ||
result = '.'.join(map(str, vinfo[:3])) + ( | ||
'' if vinfo.releaselevel == "final" and not vinfo.serial | ||
else vinfo.releaselevel + str(vinfo.serial)) | ||
Oberon00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
- `process.runtime.description` - Fill in the value of [`sys.version`](https://docs.python.org/3/library/sys.html#sys.version) as-is. | ||
|
||
[py_impl]: https://docs.python.org/3/library/sys.html#sys.implementation | ||
|
||
Examples for some Python runtimes: | ||
|
||
| Name | `process.runtime.name` | `process.runtime.version` | `process.runtime.description` | | ||
| --- | --- | --- | --- | | ||
| CPython 3.7.3 on Windows | cpython | 3.7.3 | 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] | | ||
| CPython 3.8.6 on Linux | cpython | 3.8.6 | 3.8.6 (default, Sep 30 2020, 04:00:38) <br>[GCC 10.2.0] | | ||
| PyPy 3 7.3.2 on Linux | pypy | 3.7.4 | 3.7.4 (?, Sep 27 2020, 15:12:26)<br>[PyPy 7.3.2-alpha0 with GCC 10.2.0] | | ||
| Jython 2.7.2 on Linux | jython | 2.7.2 | 2.7.2 (v2.7.2:925a3cc3b49d, Mar 21 2020, 10:03:58)<br>[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] | | ||
Oberon00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds reasonable since PyPy is not conforming to the docs here There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
Jython does not support Python 3, so there the fallbacks without `sys.implementation` were used. | ||
Oberon00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
***Ruby Runtimes:*** | ||
|
||
|
There was a problem hiding this comment.
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
:For CPython they are the same but for PyPy they are independent.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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.