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

adding instructions to port instrumentation #26

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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/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/contrib/jinja2 instrumentors/
```

2. Move the tests

```
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mkdir -p instrumentors/jinja2/src/opentelemetry/ext/jinja2
mkdir -p instrumentors/jinja2/src/opentelemetry/instrumentors/jinja2

git mv instrumentors/jinja2/*.py instrumentors/jinja2/src/opentelemetry/ext/jinja2
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not use ext but instrumentors.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
git mv instrumentors/jinja2/*.py instrumentors/jinja2/src/opentelemetry/ext/jinja2
git mv instrumentors/jinja2/*.py instrumentors/jinja2/src/opentelemetry/instrumentors/jinja2

```

4. 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

```bash
mv instrumentors/jinja2/version.py instrumentors/jinja2/src/opentelemetry/ext/jinja2/version.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mv instrumentors/jinja2/version.py instrumentors/jinja2/src/opentelemetry/ext/jinja2/version.py
mv instrumentors/jinja2/version.py instrumentors/jinja2/src/opentelemetry/instrumentors/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
23 changes: 23 additions & 0 deletions _template/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
OpenTelemetry <REPLACE ME> Tracing
===========================

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opentelemetry-ext-<REPLACE ME>.svg
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.. |pypi| image:: https://badge.fury.io/py/opentelemetry-ext-<REPLACE ME>.svg
.. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentors-<REPLACE ME>.svg

:target: https://pypi.org/project/opentelemetry-ext-<REPLACE ME>/
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
:target: https://pypi.org/project/opentelemetry-ext-<REPLACE ME>/
:target: https://pypi.org/project/opentelemetry-instrumentors-<REPLACE ME>/


This library allows tracing requests made by the <REPLACE ME> library.

Installation
------------

::

pip install opentelemetry-ext-<REPLACE ME>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pip install opentelemetry-ext-<REPLACE ME>
pip install opentelemetry-instrumentors-<REPLACE ME>



References
----------

* `OpenTelemetry SQLAlchemy Tracing <https://opentelemetry-python.readthedocs.io/en/latest/ext/<REPLACE ME>/<REPLACE ME>.html>`_
* `OpenTelemetry Project <https://opentelemetry.io/>`_
60 changes: 60 additions & 0 deletions _template/setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# opentelemetry-ext plus the name of the library being instrument e.g
# opentelemetry-instrumentors plus the name of the library being instrument e.g

# name = opentelemetry-ext-sqlalchemy
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# name = opentelemetry-ext-sqlalchemy
# name = opentelemetry-instrumentors-sqlalchemy

name = "<REPLACE ME>"
# a description of the instrumentation e.g
# description = SQLAlchemy tracing for OpenTelemetry
description = "<REPLACE ME>"
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 = "<REPLACE ME>"
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
"<REPLACE ME>"

[options.extras_require]
test =
# add any test dependencies here
"<REPLACE ME>"

[options.packages.find]
where = src

42 changes: 42 additions & 0 deletions _template/setup.py
Original file line number Diff line number Diff line change
@@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# BASE_DIR, "src", "opentelemetry", "ext", "sqlalchemy", "version.py"
# BASE_DIR, "src", "opentelemetry", "instrumentors", "sqlalchemy", "version.py"

BASE_DIR,
"src",
"opentelemetry",
"ext",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"ext",
"instrumentors",

"<REPLACE ME>",
"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"
"<REPLACE ME> = opentelemetry.ext.<REPLACE>"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"<REPLACE ME> = opentelemetry.ext.<REPLACE>"
"<REPLACE ME> = opentelemetry.instrumentors.<REPLACE>"

]
},
)
15 changes: 15 additions & 0 deletions _template/version.py
Original file line number Diff line number Diff line change
@@ -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__ = "<REPLACE ME>"