From f2d2e6fed229717821a2c32aa3617497f35bc623 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Wed, 8 Apr 2020 11:14:53 -0700 Subject: [PATCH 1/9] adding instructions to port instrumentation --- README.md | 40 ++++++++++++++++++++++++++++- _template/README.rst | 23 +++++++++++++++++ _template/setup.cfg | 60 ++++++++++++++++++++++++++++++++++++++++++++ _template/setup.py | 42 +++++++++++++++++++++++++++++++ _template/version.py | 15 +++++++++++ 5 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 _template/README.rst create mode 100644 _template/setup.cfg create mode 100644 _template/setup.py create mode 100644 _template/version.py diff --git a/README.md b/README.md index e7d56b7bc1..1a5ef45f74 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,40 @@ # opentelemetry-auto-instr-python -Auto-Instrumentation for Python (per OTEP 0001) +The auto-instrumentation for Python (per [OTEP 0001](https://github.com/open-telemetry/oteps/blob/master/text/0001-telemetry-without-manual-instrumentation.md)) instruments each library in a separately installable package to ensure users only need to install the libraries that make sense for their use-case. This repository contains the code initially [donate by DataDog](https://www.datadoghq.com/blog/opentelemetry-instrumentation/) in the `reference` folder. All instrumentation that has been ported lives in the `instrumentors` directory. + +# porting ddtrace/contribs to instrumentors + +The steps below describe the process to port integrations from the reference directory containing the originally donated code to OpenTelemetry. + +1. Move the code into the instrumentors directory + +``` +git mv reference/ddtrace/contribs/jinja2 instrumentors/ +``` + +2. Move the tests + +``` +git mv reference/tests/contrib/jinja2 instrumentors/jinja2/tests +``` + +3. Make the package installable + 1. Move source code to package path + +```bash +mkdir -p instrumentors/jinja2/src/opentelemetry/ext/jinja2 +git mv instrumentors/jinja2/*.py instrumentors/jinja2/src/opentelemetry/ext/jinja2 +``` + + 2. Add `README.rst`, `setup.cfg` and `setup.py` files and update them accordingly + +```bash +cp _template/* instrumentors/jinja2/ +``` + + 3. Add `version.py` file and update it accordingly +```bash +mv instrumentors/jinja2/version.py instrumentors/jinja2/src/opentelemetry/ext/jinja2/version.py +``` + +4. Fix relative import paths to using ddtrace package instead of using relative paths +5. Update the code and tests to use the OpenTelemetry API diff --git a/_template/README.rst b/_template/README.rst new file mode 100644 index 0000000000..e4b2698757 --- /dev/null +++ b/_template/README.rst @@ -0,0 +1,23 @@ +OpenTelemetry Tracing +=========================== + +|pypi| + +.. |pypi| image:: https://badge.fury.io/py/opentelemetry-ext-.svg + :target: https://pypi.org/project/opentelemetry-ext-/ + +This library allows tracing requests made by the library. + +Installation +------------ + +:: + + pip install opentelemetry-ext- + + +References +---------- + +* `OpenTelemetry SQLAlchemy Tracing /.html>`_ +* `OpenTelemetry Project `_ \ No newline at end of file diff --git a/_template/setup.cfg b/_template/setup.cfg new file mode 100644 index 0000000000..badc5b91a6 --- /dev/null +++ b/_template/setup.cfg @@ -0,0 +1,60 @@ +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +[metadata] +# opentelemetry-ext plus the name of the library being instrument e.g +# name = opentelemetry-ext-sqlalchemy +name = "" +# a description of the instrumentation e.g +# description = SQLAlchemy tracing for OpenTelemetry +description = "" +long_description = file: README.rst +long_description_content_type = text/x-rst +author = OpenTelemetry Authors +author_email = cncf-opentelemetry-contributors@lists.cncf.io +# url of the instrumentation e.g +# url = https://github.com/open-telemetry/opentelemetry-python-contrib/instrumentors/sqlalchemy +url = "" +platforms = any +license = Apache-2.0 +classifiers = + Development Status :: 4 - Beta + Intended Audience :: Developers + License :: OSI Approved :: Apache Software License + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + +[options] +python_requires = >=3.4 +package_dir= + =src +packages=find_namespace: + +install_requires = + # add any package dependencies here + "" + +[options.extras_require] +test = + # add any test dependencies here + "" + +[options.packages.find] +where = src + diff --git a/_template/setup.py b/_template/setup.py new file mode 100644 index 0000000000..5f63e144f4 --- /dev/null +++ b/_template/setup.py @@ -0,0 +1,42 @@ +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import os + +import setuptools + +BASE_DIR = os.path.dirname(__file__) +VERSION_FILENAME = os.path.join( + # REPLACE ME: the path to the version file e.g + # BASE_DIR, "src", "opentelemetry", "ext", "sqlalchemy", "version.py" + BASE_DIR, + "src", + "opentelemetry", + "ext", + "", + "version.py", +) +PACKAGE_INFO = {} +with open(VERSION_FILENAME) as f: + exec(f.read(), PACKAGE_INFO) + +setuptools.setup( + version=PACKAGE_INFO["__version__"], + entry_points={ + "opentelemetry_instrumentor": [ + # REPLACE ME: the entrypoint for the instrumentor e.g + # "sqlalchemy = opentelemetry.ext.sqlalchemy:SQLAlchemyInstrumentor" + " = opentelemetry.ext." + ] + }, +) diff --git a/_template/version.py b/_template/version.py new file mode 100644 index 0000000000..2c4d1fa1de --- /dev/null +++ b/_template/version.py @@ -0,0 +1,15 @@ +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +__version__ = "" From 60cdb85191923cd7964423e2d83963fc1758bf33 Mon Sep 17 00:00:00 2001 From: alrex Date: Wed, 8 Apr 2020 11:18:58 -0700 Subject: [PATCH 2/9] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1a5ef45f74..b9e89a609f 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # opentelemetry-auto-instr-python The auto-instrumentation for Python (per [OTEP 0001](https://github.com/open-telemetry/oteps/blob/master/text/0001-telemetry-without-manual-instrumentation.md)) instruments each library in a separately installable package to ensure users only need to install the libraries that make sense for their use-case. This repository contains the code initially [donate by DataDog](https://www.datadoghq.com/blog/opentelemetry-instrumentation/) in the `reference` folder. All instrumentation that has been ported lives in the `instrumentors` directory. -# porting ddtrace/contribs to instrumentors +# porting ddtrace/contrib to instrumentors The steps below describe the process to port integrations from the reference directory containing the originally donated code to OpenTelemetry. 1. Move the code into the instrumentors directory ``` -git mv reference/ddtrace/contribs/jinja2 instrumentors/ +git mv reference/ddtrace/contrib/jinja2 instrumentors/ ``` 2. Move the tests From cc819a6d170eff5548670ea9e85c9421ac1485cd Mon Sep 17 00:00:00 2001 From: alrex Date: Wed, 8 Apr 2020 11:25:04 -0700 Subject: [PATCH 3/9] fixing indentation --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b9e89a609f..b2a672fd4d 100644 --- a/README.md +++ b/README.md @@ -17,24 +17,24 @@ git mv reference/ddtrace/contrib/jinja2 instrumentors/ git mv reference/tests/contrib/jinja2 instrumentors/jinja2/tests ``` -3. Make the package installable - 1. Move source code to package path +3. Make the package installable: move source code to package path ```bash mkdir -p instrumentors/jinja2/src/opentelemetry/ext/jinja2 git mv instrumentors/jinja2/*.py instrumentors/jinja2/src/opentelemetry/ext/jinja2 ``` - 2. Add `README.rst`, `setup.cfg` and `setup.py` files and update them accordingly +4. Add `README.rst`, `setup.cfg` and `setup.py` files and update them accordingly ```bash cp _template/* instrumentors/jinja2/ ``` - 3. Add `version.py` file and update it accordingly +5. Add `version.py` file and update it accordingly + ```bash mv instrumentors/jinja2/version.py instrumentors/jinja2/src/opentelemetry/ext/jinja2/version.py ``` -4. Fix relative import paths to using ddtrace package instead of using relative paths -5. Update the code and tests to use the OpenTelemetry API +6. Fix relative import paths to using ddtrace package instead of using relative paths +7. Update the code and tests to use the OpenTelemetry API From fd69a4e57c4a41cba6fb5bbda376b0a1386409b3 Mon Sep 17 00:00:00 2001 From: alrex Date: Wed, 8 Apr 2020 14:33:51 -0700 Subject: [PATCH 4/9] Update _template/README.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Mauricio Vásquez --- _template/README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_template/README.rst b/_template/README.rst index e4b2698757..fd97bef024 100644 --- a/_template/README.rst +++ b/_template/README.rst @@ -19,5 +19,5 @@ Installation References ---------- -* `OpenTelemetry SQLAlchemy Tracing /.html>`_ -* `OpenTelemetry Project `_ \ No newline at end of file +* `OpenTelemetry / Tracing /.html>`_ +* `OpenTelemetry Project `_ From 95cc8d3647725650aad138945d5370b3099ac7fc Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Wed, 8 Apr 2020 14:41:15 -0700 Subject: [PATCH 5/9] updating readme --- README.md | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index b2a672fd4d..a1cf62204b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # opentelemetry-auto-instr-python -The auto-instrumentation for Python (per [OTEP 0001](https://github.com/open-telemetry/oteps/blob/master/text/0001-telemetry-without-manual-instrumentation.md)) instruments each library in a separately installable package to ensure users only need to install the libraries that make sense for their use-case. This repository contains the code initially [donate by DataDog](https://www.datadoghq.com/blog/opentelemetry-instrumentation/) in the `reference` folder. All instrumentation that has been ported lives in the `instrumentors` directory. +The auto-instrumentation for Python (per [OTEP 0001](https://github.com/open-telemetry/oteps/blob/master/text/0001-telemetry-without-manual-instrumentation.md)) instruments each library in a separately installable package to ensure users only need to install the libraries that make sense for their use-case. This repository contains the code initially [donated by DataDog](https://www.datadoghq.com/blog/opentelemetry-instrumentation/) in the `reference` folder. All instrumentation that has been ported lives in the `instrumentors` directory. # porting ddtrace/contrib to instrumentors @@ -8,7 +8,8 @@ The steps below describe the process to port integrations from the reference dir 1. Move the code into the instrumentors directory ``` -git mv reference/ddtrace/contrib/jinja2 instrumentors/ +mkdir -p instrumentors/jinja2/src/opentelemetry/ext/jinja2 +git mv reference/ddtrace/contrib/jinja2 instrumentors/jinja2/src/opentelemetry/ext/jinja2 ``` 2. Move the tests @@ -17,24 +18,17 @@ git mv reference/ddtrace/contrib/jinja2 instrumentors/ git mv reference/tests/contrib/jinja2 instrumentors/jinja2/tests ``` -3. Make the package installable: move source code to package path - -```bash -mkdir -p instrumentors/jinja2/src/opentelemetry/ext/jinja2 -git mv instrumentors/jinja2/*.py instrumentors/jinja2/src/opentelemetry/ext/jinja2 -``` - -4. Add `README.rst`, `setup.cfg` and `setup.py` files and update them accordingly +3. Add `README.rst`, `setup.cfg` and `setup.py` files and update them accordingly ```bash cp _template/* instrumentors/jinja2/ ``` -5. Add `version.py` file and update it accordingly +4. Add `version.py` file and update it accordingly ```bash mv instrumentors/jinja2/version.py instrumentors/jinja2/src/opentelemetry/ext/jinja2/version.py ``` -6. Fix relative import paths to using ddtrace package instead of using relative paths -7. Update the code and tests to use the OpenTelemetry API +5. Fix relative import paths to using ddtrace package instead of using relative paths +6. Update the code and tests to use the OpenTelemetry API From aab2afa34d8ab7f5aeb54360cbd38d815ebe16af Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Thu, 9 Apr 2020 09:36:00 -0700 Subject: [PATCH 6/9] updating to use instrumentation --- README.md | 16 ++++++++-------- _template/setup.cfg | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a1cf62204b..70ce94f6ba 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,33 @@ # opentelemetry-auto-instr-python -The auto-instrumentation for Python (per [OTEP 0001](https://github.com/open-telemetry/oteps/blob/master/text/0001-telemetry-without-manual-instrumentation.md)) instruments each library in a separately installable package to ensure users only need to install the libraries that make sense for their use-case. This repository contains the code initially [donated by DataDog](https://www.datadoghq.com/blog/opentelemetry-instrumentation/) in the `reference` folder. All instrumentation that has been ported lives in the `instrumentors` directory. +The auto-instrumentation for Python (per [OTEP 0001](https://github.com/open-telemetry/oteps/blob/master/text/0001-telemetry-without-manual-instrumentation.md)) instruments each library in a separately installable package to ensure users only need to install the libraries that make sense for their use-case. This repository contains the code initially [donated by DataDog](https://www.datadoghq.com/blog/opentelemetry-instrumentation/) in the `reference` folder. All instrumentation that has been ported lives in the `instrumentation` directory. -# porting ddtrace/contrib to instrumentors +# porting ddtrace/contrib to instrumentation The steps below describe the process to port integrations from the reference directory containing the originally donated code to OpenTelemetry. -1. Move the code into the instrumentors directory +1. Move the code into the instrumentation directory ``` -mkdir -p instrumentors/jinja2/src/opentelemetry/ext/jinja2 -git mv reference/ddtrace/contrib/jinja2 instrumentors/jinja2/src/opentelemetry/ext/jinja2 +mkdir -p instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/ext/jinja2 +git mv reference/ddtrace/contrib/jinja2 instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/ext/jinja2 ``` 2. Move the tests ``` -git mv reference/tests/contrib/jinja2 instrumentors/jinja2/tests +git mv reference/tests/contrib/jinja2 instrumentation/opentelemetry-instrumentation-jinja2/tests ``` 3. Add `README.rst`, `setup.cfg` and `setup.py` files and update them accordingly ```bash -cp _template/* instrumentors/jinja2/ +cp _template/* instrumentation/opentelemetry-instrumentation-jinja2/ ``` 4. Add `version.py` file and update it accordingly ```bash -mv instrumentors/jinja2/version.py instrumentors/jinja2/src/opentelemetry/ext/jinja2/version.py +mv instrumentation/opentelemetry-instrumentation-jinja2/version.py instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/ext/jinja2/version.py ``` 5. Fix relative import paths to using ddtrace package instead of using relative paths diff --git a/_template/setup.cfg b/_template/setup.cfg index badc5b91a6..f48b53f4bc 100644 --- a/_template/setup.cfg +++ b/_template/setup.cfg @@ -24,7 +24,7 @@ long_description_content_type = text/x-rst author = OpenTelemetry Authors author_email = cncf-opentelemetry-contributors@lists.cncf.io # url of the instrumentation e.g -# url = https://github.com/open-telemetry/opentelemetry-python-contrib/instrumentors/sqlalchemy +# url = https://github.com/open-telemetry/opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-sqlalchemy url = "" platforms = any license = Apache-2.0 From 2fd90b23dc9916b3da708093246528e49f513a77 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Thu, 9 Apr 2020 09:37:36 -0700 Subject: [PATCH 7/9] replace ext w/ instrumentation --- README.md | 6 +++--- _template/README.rst | 8 ++++---- _template/setup.cfg | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 70ce94f6ba..5f3f669bca 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ The steps below describe the process to port integrations from the reference dir 1. Move the code into the instrumentation directory ``` -mkdir -p instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/ext/jinja2 -git mv reference/ddtrace/contrib/jinja2 instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/ext/jinja2 +mkdir -p instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2 +git mv reference/ddtrace/contrib/jinja2 instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2 ``` 2. Move the tests @@ -27,7 +27,7 @@ cp _template/* instrumentation/opentelemetry-instrumentation-jinja2/ 4. Add `version.py` file and update it accordingly ```bash -mv instrumentation/opentelemetry-instrumentation-jinja2/version.py instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/ext/jinja2/version.py +mv instrumentation/opentelemetry-instrumentation-jinja2/version.py instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/version.py ``` 5. Fix relative import paths to using ddtrace package instead of using relative paths diff --git a/_template/README.rst b/_template/README.rst index fd97bef024..5ba2007f7f 100644 --- a/_template/README.rst +++ b/_template/README.rst @@ -3,8 +3,8 @@ OpenTelemetry Tracing |pypi| -.. |pypi| image:: https://badge.fury.io/py/opentelemetry-ext-.svg - :target: https://pypi.org/project/opentelemetry-ext-/ +.. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentation-.svg + :target: https://pypi.org/project/opentelemetry-instrumentation-/ This library allows tracing requests made by the library. @@ -13,11 +13,11 @@ Installation :: - pip install opentelemetry-ext- + pip install opentelemetry-instrumentation- References ---------- -* `OpenTelemetry / Tracing /.html>`_ +* `OpenTelemetry / Tracing /.html>`_ * `OpenTelemetry Project `_ diff --git a/_template/setup.cfg b/_template/setup.cfg index f48b53f4bc..fd86c79889 100644 --- a/_template/setup.cfg +++ b/_template/setup.cfg @@ -13,8 +13,8 @@ # limitations under the License. # [metadata] -# opentelemetry-ext plus the name of the library being instrument e.g -# name = opentelemetry-ext-sqlalchemy +# opentelemetry-instrumentation plus the name of the library being instrument e.g +# name = opentelemetry-instrumentation-sqlalchemy name = "" # a description of the instrumentation e.g # description = SQLAlchemy tracing for OpenTelemetry From 0349806a9bed31a8b25ad26cc94a986877619ded Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Thu, 9 Apr 2020 10:43:49 -0700 Subject: [PATCH 8/9] missed one file --- _template/setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_template/setup.py b/_template/setup.py index 5f63e144f4..423aa90a3e 100644 --- a/_template/setup.py +++ b/_template/setup.py @@ -18,11 +18,11 @@ BASE_DIR = os.path.dirname(__file__) VERSION_FILENAME = os.path.join( # REPLACE ME: the path to the version file e.g - # BASE_DIR, "src", "opentelemetry", "ext", "sqlalchemy", "version.py" + # BASE_DIR, "src", "opentelemetry", "instrumentation", "sqlalchemy", "version.py" BASE_DIR, "src", "opentelemetry", - "ext", + "instrumentation", "", "version.py", ) @@ -35,8 +35,8 @@ entry_points={ "opentelemetry_instrumentor": [ # REPLACE ME: the entrypoint for the instrumentor e.g - # "sqlalchemy = opentelemetry.ext.sqlalchemy:SQLAlchemyInstrumentor" - " = opentelemetry.ext." + # "sqlalchemy = opentelemetry.instrumentation.sqlalchemy:SQLAlchemyInstrumentor" + " = opentelemetry.instrumentation." ] }, ) From f84d57b4f3dec37bff65524a14e3b06eb0857014 Mon Sep 17 00:00:00 2001 From: alrex Date: Thu, 9 Apr 2020 10:56:40 -0700 Subject: [PATCH 9/9] Update _template/README.rst Co-Authored-By: Hector Hernandez <39923391+hectorhdzg@users.noreply.github.com> --- _template/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_template/README.rst b/_template/README.rst index 5ba2007f7f..32fcbfe3e6 100644 --- a/_template/README.rst +++ b/_template/README.rst @@ -1,4 +1,4 @@ -OpenTelemetry Tracing +OpenTelemetry Instrumentation =========================== |pypi|