From 22891c8019583390e760d762394414edb13cf200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Fri, 30 Oct 2020 12:14:11 +0100 Subject: [PATCH 1/6] Specify process.runtime for Python. --- .../resource/semantic_conventions/process.md | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/specification/resource/semantic_conventions/process.md b/specification/resource/semantic_conventions/process.md index 28c651d6153..ef3273913fd 100644 --- a/specification/resource/semantic_conventions/process.md +++ b/specification/resource/semantic_conventions/process.md @@ -88,16 +88,41 @@ TODO(): Conf ***Python Runtimes:*** -TODO(): 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)) + ``` + +- `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)
[GCC 10.2.0] | +| PyPy 3 7.3.2 on Linux | pypy | 3.7.4 | 3.7.4 (?, Sep 27 2020, 15:12:26)
[PyPy 7.3.2-alpha0 with GCC 10.2.0] | + +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. ***Ruby Runtimes:*** From 963b4914a6a44e4720b357f0127b9645c2bc9e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Fri, 30 Oct 2020 12:29:41 +0100 Subject: [PATCH 2/6] Add Jython, add note on PyPy version. --- specification/resource/semantic_conventions/process.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/specification/resource/semantic_conventions/process.md b/specification/resource/semantic_conventions/process.md index ef3273913fd..81495cd283a 100644 --- a/specification/resource/semantic_conventions/process.md +++ b/specification/resource/semantic_conventions/process.md @@ -120,10 +120,15 @@ Examples for some Python runtimes: | 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)
[GCC 10.2.0] | | PyPy 3 7.3.2 on Linux | pypy | 3.7.4 | 3.7.4 (?, Sep 27 2020, 15:12:26)
[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)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] | 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`. + +Jython does not support Python 3, so there the fallbacks without `sys.implementation` were used. + ***Ruby Runtimes:*** Ruby instrumentation should fill in the values by copying from built-in runtime constants. From fc4d621e98dce0ae5a6786fb1a4ba9260c89807c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Fri, 30 Oct 2020 17:19:15 +0100 Subject: [PATCH 3/6] Remove Jython, Py<3.3 fallbacks. --- specification/resource/semantic_conventions/process.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/specification/resource/semantic_conventions/process.md b/specification/resource/semantic_conventions/process.md index 81495cd283a..457890590ff 100644 --- a/specification/resource/semantic_conventions/process.md +++ b/specification/resource/semantic_conventions/process.md @@ -92,10 +92,8 @@ Python instrumentation should fill in the values as follows: - `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). @@ -120,15 +118,12 @@ Examples for some Python runtimes: | 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)
[GCC 10.2.0] | | PyPy 3 7.3.2 on Linux | pypy | 3.7.4 | 3.7.4 (?, Sep 27 2020, 15:12:26)
[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)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] | 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`. -Jython does not support Python 3, so there the fallbacks without `sys.implementation` were used. - ***Ruby Runtimes:*** Ruby instrumentation should fill in the values by copying from built-in runtime constants. From 98f9beb9d73729fabbf8ca6298bbf7ebf92384bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Fri, 30 Oct 2020 17:25:05 +0100 Subject: [PATCH 4/6] Update specification/resource/semantic_conventions/process.md --- specification/resource/semantic_conventions/process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/resource/semantic_conventions/process.md b/specification/resource/semantic_conventions/process.md index 457890590ff..7bccb281f1b 100644 --- a/specification/resource/semantic_conventions/process.md +++ b/specification/resource/semantic_conventions/process.md @@ -104,7 +104,7 @@ Python instrumentation should fill in the values as follows: vinfo = sys.implementation.version result = '.'.join(map(str, vinfo[:3])) + ( '' if vinfo.releaselevel == "final" and not vinfo.serial - else vinfo.releaselevel + str(vinfo.serial)) + else vinfo.releaselevel + '.' + str(vinfo.serial)) ``` - `process.runtime.description` - Fill in the value of [`sys.version`](https://docs.python.org/3/library/sys.html#sys.version) as-is. From 2c0e8ba0fa6b685a09786660bc792875a3b95db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Fri, 30 Oct 2020 17:27:24 +0100 Subject: [PATCH 5/6] Normalize quotes --- specification/resource/semantic_conventions/process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/resource/semantic_conventions/process.md b/specification/resource/semantic_conventions/process.md index 7bccb281f1b..31b14c34f09 100644 --- a/specification/resource/semantic_conventions/process.md +++ b/specification/resource/semantic_conventions/process.md @@ -103,7 +103,7 @@ Python instrumentation should fill in the values as follows: ```python vinfo = sys.implementation.version result = '.'.join(map(str, vinfo[:3])) + ( - '' if vinfo.releaselevel == "final" and not vinfo.serial + '' if vinfo.releaselevel == 'final' and not vinfo.serial else vinfo.releaselevel + '.' + str(vinfo.serial)) ``` From 1709b13914584f03cdfac296c7f3140ed274b4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Fri, 30 Oct 2020 17:52:24 +0100 Subject: [PATCH 6/6] Fix another missing dot, simplify expression. --- specification/resource/semantic_conventions/process.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/specification/resource/semantic_conventions/process.md b/specification/resource/semantic_conventions/process.md index 31b14c34f09..fd538451ea5 100644 --- a/specification/resource/semantic_conventions/process.md +++ b/specification/resource/semantic_conventions/process.md @@ -102,9 +102,12 @@ Python instrumentation should fill in the values as follows: ```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)) + result = ".".join(map( + str, + vinfo[:3] + if vinfo.releaselevel == "final" and not vinfo.serial + else vinfo + )) ``` - `process.runtime.description` - Fill in the value of [`sys.version`](https://docs.python.org/3/library/sys.html#sys.version) as-is.