-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out auto instrumentation into new package
- Loading branch information
1 parent
3da42e9
commit 5499d30
Showing
11 changed files
with
230 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Changelog | ||
|
||
## Unreleased | ||
|
||
- Initial Release | ||
- Add IDs Generator as Configurable Property of Auto Instrumentation | ||
([#1404](https://github.com/open-telemetry/opentelemetry-python/pull/1404)) | ||
- Added support for `OTEL_EXPORTER` to the `opentelemetry-instrument` command | ||
([#1036](https://github.com/open-telemetry/opentelemetry-python/pull/1036)) | ||
- Split auto instrumentation into a new package | ||
([#1415](https://github.com/open-telemetry/opentelemetry-python/pull/1415)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
prune tests | ||
graft src | ||
global-exclude *.pyc | ||
global-exclude *.pyo | ||
global-exclude __pycache__/* | ||
include MANIFEST.in | ||
include README.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
OpenTelemetry Auto Instrumentation | ||
================================== | ||
|
||
|pypi| | ||
|
||
.. |pypi| image:: https://badge.fury.io/py/opentelemetry-auto-instrumentation.svg | ||
:target: https://pypi.org/project/opentelemetry-auto-instrumentation/ | ||
|
||
Installation | ||
------------ | ||
|
||
:: | ||
|
||
pip install opentelemetry-auto-instrumentation | ||
|
||
This package provides a wrapper to automatically instrument applications. The | ||
wrapper will automatically instrument the application's usage of dependencies if | ||
the relevant instrumentation packages for those dependencies are installed. | ||
These packages can be installed automatically using the `opentelmetry-bootstrap <https://github.com/open-telemetry/opentelemetry-python/tree/master/opentelemetry-instrumentation>`_ command. | ||
|
||
opentelemetry-auto-instrument | ||
----------------------------- | ||
|
||
:: | ||
|
||
opentelemetry-instrument python program.py | ||
|
||
The instrument command will try to automatically detect dependencies used by your python program | ||
and when possible, apply automatic tracing instrumentation on them. This means your program | ||
will get automatic distributed tracing for free without having to make any code changes | ||
at all. This command will also configure the OTel SDK's TracerProvider as the global tracer provider | ||
and the tracing exporter according to the specified configuration flags without you having to | ||
make any code changes. By default, the instrument command will use the OTLP exporter but | ||
this can be overridden when needed. | ||
|
||
The command supports the following configuration options as CLI arguments and environment vars: | ||
|
||
* ``--exporter`` or ``OTEL_EXPORTER`` | ||
|
||
Used to specify which trace exporter to use. Can be set to one or more | ||
of the well-known exporter names (see below). | ||
|
||
- Defaults to `otlp`. | ||
- Can be set to `none` to disable automatic tracer initialization. | ||
|
||
You can pass multiple values to configure multiple exporters e.g, ``zipkin,prometheus`` | ||
|
||
Well known trace exporter names: | ||
|
||
- jaeger | ||
- opencensus | ||
- otlp | ||
- otlp_span | ||
- otlp_metric | ||
- zipkin | ||
|
||
``otlp`` is an alias for ``otlp_span,otlp_metric``. | ||
|
||
* ``--service-name`` or ``OTEL_SERVICE_NAME`` | ||
|
||
When present the value is passed on to the relevant exporter initializer as ``service_name`` argument. | ||
|
||
* ``--ids-generator`` or ``OTEL_IDS_GENERATOR`` | ||
|
||
Used to specify which IDs Generator to use for the global Tracer Provider. By default, it | ||
will use the random IDs generator. | ||
|
||
The code in ``program.py`` needs to use one of the packages for which there is | ||
an OpenTelemetry integration. For a list of the available integrations please | ||
check `here <https://opentelemetry-python.readthedocs.io/en/stable/index.html#integrations>`_ | ||
|
||
Examples | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
:: | ||
|
||
opentelemetry-instrument -e otlp flask run --port=3000 | ||
|
||
The above command will pass ``-e otlp`` to the instrument command and ``--port=3000`` to ``flask run``. | ||
|
||
:: | ||
|
||
opentelemetry-instrument -e zipkin,otlp celery -A tasks worker --loglevel=info | ||
|
||
The above command will configure global trace provider, attach zipkin and otlp exporters to it and then | ||
start celery with the rest of the arguments. | ||
|
||
:: | ||
|
||
opentelemetry-instrument --ids-generator random flask run --port=3000 | ||
|
||
The above command will configure the global trace provider to use the Random IDs Generator, and then | ||
pass ``--port=3000`` to ``flask run``. | ||
|
||
References | ||
---------- | ||
|
||
* `OpenTelemetry Project <https://opentelemetry.io/>`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# 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] | ||
name = opentelemetry-auto-instrumentation | ||
description = Auto Instrumentation for OpenTelemetry Python | ||
long_description = file: README.rst | ||
long_description_content_type = text/x-rst | ||
author = OpenTelemetry Authors | ||
author_email = [email protected] | ||
url = https://github.com/open-telemetry/opentelemetry-python/tree/master/opentelemetry-auto-instrumentation | ||
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.5 | ||
Programming Language :: Python :: 3.6 | ||
Programming Language :: Python :: 3.7 | ||
Programming Language :: Python :: 3.8 | ||
|
||
[options] | ||
python_requires = >=3.5 | ||
package_dir= | ||
=src | ||
packages=find_namespace: | ||
zip_safe = False | ||
include_package_data = True | ||
install_requires = | ||
opentelemetry-api == 0.16.dev0 | ||
opentelemetry-sdk == 0.16.dev0 | ||
|
||
[options.packages.find] | ||
where = src | ||
|
||
[options.entry_points] | ||
console_scripts = | ||
opentelemetry-instrument = opentelemetry.instrumentation.auto_instrumentation:run | ||
|
||
[options.extras_require] | ||
test = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# 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( | ||
BASE_DIR, | ||
"src", | ||
"opentelemetry", | ||
"instrumentation", | ||
"auto_instrumentation", | ||
"version.py", | ||
) | ||
PACKAGE_INFO = {} | ||
with open(VERSION_FILENAME) as f: | ||
exec(f.read(), PACKAGE_INFO) | ||
|
||
setuptools.setup(version=PACKAGE_INFO["__version__"],) |
15 changes: 15 additions & 0 deletions
15
...ry-auto-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__ = "0.16.dev0" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters