From 49e25cb6beec3dc35153d574e48adefa171258ec Mon Sep 17 00:00:00 2001 From: Owais Lone Date: Mon, 26 Apr 2021 11:35:13 -0700 Subject: [PATCH] Instrumentation: Use runtime dependency checks --- .github/workflows/test.yml | 4 +- CHANGELOG.md | 3 + .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../aiohttp_client/__init__.py | 8 ++- .../aiohttp_client/{version.py => package.py} | 2 + .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/aiopg/__init__.py | 9 ++- .../instrumentation/aiopg/package.py | 17 ++++++ .../instrumentation/aiopg/wrappers.py | 2 +- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/asgi/__init__.py | 2 +- .../instrumentation/asgi/package.py | 17 ++++++ .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/asyncpg/__init__.py | 9 ++- .../instrumentation/asyncpg/package.py | 17 ++++++ .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/boto/__init__.py | 8 ++- .../instrumentation/boto/package.py | 17 ++++++ .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/botocore/__init__.py | 8 ++- .../instrumentation/botocore/package.py | 17 ++++++ .../instrumentation/botocore/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/celery/__init__.py | 9 ++- .../instrumentation/celery/package.py | 17 ++++++ .../instrumentation/celery/version.py | 15 ----- .../setup.py | 28 ++++++++-- .../instrumentation/dbapi/__init__.py | 2 +- .../instrumentation/dbapi/package.py} | 2 + .../instrumentation/dbapi/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/django/__init__.py | 8 ++- .../instrumentation/django/middleware.py | 2 +- .../instrumentation/django/package.py | 17 ++++++ .../instrumentation/django/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/elasticsearch/__init__.py | 8 ++- .../instrumentation/elasticsearch/package.py | 17 ++++++ .../instrumentation/elasticsearch/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/falcon/__init__.py | 8 ++- .../instrumentation/falcon/package.py | 17 ++++++ .../instrumentation/falcon/version.py | 15 ----- .../setup.py | 28 ++++++++-- .../instrumentation/fastapi/__init__.py | 7 +++ .../instrumentation/fastapi/package.py | 17 ++++++ .../instrumentation/fastapi/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/flask/__init__.py | 8 ++- .../instrumentation/flask/package.py | 17 ++++++ .../instrumentation/flask/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/grpc/__init__.py | 12 +++- .../instrumentation/grpc/package.py | 17 ++++++ .../instrumentation/grpc/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/jinja2/__init__.py | 8 ++- .../instrumentation/jinja2/package.py | 17 ++++++ .../instrumentation/jinja2/version.py | 15 ----- .../setup.py | 28 ++++++++-- .../instrumentation/logging/__init__.py | 7 ++- .../instrumentation/logging/package.py} | 2 + .../instrumentation/logging/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/mysql/__init__.py | 9 ++- .../instrumentation/mysql/package.py | 17 ++++++ .../instrumentation/mysql/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/psycopg2/__init__.py | 8 ++- .../instrumentation/psycopg2/package.py | 17 ++++++ .../instrumentation/psycopg2/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/pymemcache/__init__.py | 8 ++- .../instrumentation/pymemcache/package.py | 17 ++++++ .../instrumentation/pymemcache/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/pymongo/__init__.py | 9 ++- .../instrumentation/pymongo/package.py | 17 ++++++ .../instrumentation/pymongo/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/pymysql/__init__.py | 9 ++- .../instrumentation/pymysql/package.py | 17 ++++++ .../instrumentation/pymysql/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/pyramid/__init__.py | 8 ++- .../instrumentation/pyramid/callbacks.py | 2 +- .../instrumentation/pyramid/package.py | 17 ++++++ .../instrumentation/pyramid/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/redis/__init__.py | 9 ++- .../instrumentation/redis/package.py | 17 ++++++ .../instrumentation/redis/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/requests/__init__.py | 8 ++- .../instrumentation/requests/package.py | 17 ++++++ .../instrumentation/requests/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/sklearn/__init__.py | 18 +++++- .../sklearn/{version.py => package.py} | 2 + .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/sqlalchemy/__init__.py | 7 +++ .../instrumentation/sqlalchemy/engine.py | 2 +- .../instrumentation/sqlalchemy/package.py | 17 ++++++ .../instrumentation/sqlalchemy/version.py | 15 ----- .../setup.py | 28 ++++++++-- .../instrumentation/sqlite3/__init__.py | 8 ++- .../instrumentation/sqlite3/package.py} | 2 + .../instrumentation/sqlite3/version.py | 15 ----- .../setup.py | 28 ++++++++-- .../instrumentation/starlette/__init__.py | 7 +++ .../instrumentation/starlette/package.py | 17 ++++++ .../instrumentation/starlette/version.py | 15 ----- .../setup.cfg | 2 - .../setup.py | 28 ++++++++-- .../instrumentation/tornado/__init__.py | 7 ++- .../instrumentation/tornado/package.py | 17 ++++++ .../instrumentation/tornado/version.py | 15 ----- .../setup.py | 28 ++++++++-- .../instrumentation/urllib/__init__.py | 8 ++- .../instrumentation/urllib/package.py} | 2 + .../instrumentation/urllib/version.py | 15 ----- .../setup.cfg | 1 - .../setup.py | 28 ++++++++-- .../instrumentation/urllib3/__init__.py | 8 ++- .../instrumentation/urllib3/package.py | 17 ++++++ .../instrumentation/urllib3/version.py | 15 ----- .../setup.py | 28 ++++++++-- .../instrumentation/wsgi/__init__.py | 2 +- .../instrumentation/wsgi/package.py | 17 ++++++ .../instrumentation/wsgi/version.py | 15 ----- .../auto_instrumentation/sitecustomize.py | 10 +++- .../instrumentation/instrumentor.py | 35 +++++++++--- .../instrumentation/resources.py | 40 +++++++++++++ .../tests/test_instrumentor.py | 3 + .../tests/test_resources.py | 56 +++++++++++++++++++ templates/instrumentation_setup.py.txt | 32 ++++++++--- tox.ini | 34 +++++------ 160 files changed, 1597 insertions(+), 648 deletions(-) rename instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/{version.py => package.py} (94%) create mode 100644 instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/package.py create mode 100644 instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/package.py create mode 100644 instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/package.py create mode 100644 instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/package.py create mode 100644 instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/version.py rename instrumentation/{opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/version.py => opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/package.py} (96%) delete mode 100644 instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/version.py rename instrumentation/{opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/version.py => opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/package.py} (96%) delete mode 100644 instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py rename instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/{version.py => package.py} (93%) create mode 100644 instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/version.py rename instrumentation/{opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/version.py => opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/package.py} (96%) delete mode 100644 instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/version.py rename instrumentation/{opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/version.py => opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/package.py} (96%) delete mode 100644 instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py create mode 100644 instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/package.py delete mode 100644 instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py create mode 100644 opentelemetry-instrumentation/src/opentelemetry/instrumentation/resources.py create mode 100644 opentelemetry-instrumentation/tests/test_resources.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1845614ede..370e30f1bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,7 +45,7 @@ jobs: uses: actions/cache@v2 with: path: .tox - key: tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }} + key: v2-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }} - name: run tox run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json - name: Find and merge benchmarks @@ -99,6 +99,6 @@ jobs: uses: actions/cache@v2 with: path: .tox - key: v2-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt', 'docs-requirements.txt') }} + key: v2-misc-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt', 'docs-requirements.txt') }} - name: run tox run: tox -e ${{ matrix.tox-environment }} diff --git a/CHANGELOG.md b/CHANGELOG.md index c3f4a47b30..0e48550f7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/open-telemetry/opentelemetry-python-contrib/compare/v0.200...HEAD) ### Changed +- Instrumentation packages don't specify the libraries they instrument as dependencies + anymore. Instead, they verify the correct version of libraries are installed at runtime. + ([#475](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/475)) - `opentelemetry-propagator-ot-trace` Use `TraceFlags` object in `extract` ([#472](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/472)) diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.cfg b/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.cfg index 809750e068..8d854ff5b7 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.cfg @@ -41,7 +41,6 @@ install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - aiohttp ~= 3.0 wrapt >= 1.0.0, < 2.0.0 [options.packages.find] diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.py index 77253baee6..7665d04edc 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/aiohttp_client. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/aiohttp_client. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "aiohttp_client", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py index 18519d9cef..3fa763d5f9 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py @@ -64,13 +64,14 @@ def strip_query_params(url: yarl.URL) -> str: import types import typing +from typing import Collection import aiohttp import wrapt from opentelemetry import context as context_api from opentelemetry import trace -from opentelemetry.instrumentation.aiohttp_client.version import __version__ +from opentelemetry.instrumentation.aiohttp_client.package import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.utils import ( http_status_to_status_code, @@ -81,6 +82,8 @@ def strip_query_params(url: yarl.URL) -> str: from opentelemetry.trace import SpanKind, TracerProvider, get_tracer from opentelemetry.trace.status import Status, StatusCode +from . import package as pkg + _UrlFilterT = typing.Optional[typing.Callable[[str], str]] _SpanNameT = typing.Optional[ typing.Union[typing.Callable[[aiohttp.TraceRequestStartParams], str], str] @@ -288,6 +291,9 @@ class AioHttpClientInstrumentor(BaseInstrumentor): See `BaseInstrumentor` """ + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Instruments aiohttp ClientSession diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/version.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/package.py similarity index 94% rename from instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/version.py rename to instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/package.py index 0b40082f67..dc62a7d0b9 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/version.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/package.py @@ -13,3 +13,5 @@ # limitations under the License. __version__ = "0.21.dev0" + +_instruments = ("aiohttp ~= 3.0",) diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/setup.cfg b/instrumentation/opentelemetry-instrumentation-aiopg/setup.cfg index 806b0b3882..1500edd89c 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-aiopg/setup.cfg @@ -42,7 +42,6 @@ install_requires = opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation-dbapi == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - aiopg >= 0.13.0 wrapt >= 1.0.0, < 2.0.0 [options.extras_require] diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/setup.py b/instrumentation/opentelemetry-instrumentation-aiopg/setup.py index 7197fc9ab0..b3ca1301ee 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/setup.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/aiopg. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/aiopg. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "aiopg", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "aiopg", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py index ffae8df5cc..0c94c8cd71 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py @@ -45,10 +45,14 @@ --- """ +from typing import Collection + from opentelemetry.instrumentation.aiopg import wrappers -from opentelemetry.instrumentation.aiopg.version import __version__ +from opentelemetry.instrumentation.aiopg.package import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor +from . import package as pkg + class AiopgInstrumentor(BaseInstrumentor): _CONNECTION_ATTRIBUTES = { @@ -60,6 +64,9 @@ class AiopgInstrumentor(BaseInstrumentor): _DATABASE_SYSTEM = "postgresql" + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Integrate with PostgreSQL aiopg library. aiopg: https://github.com/aio-libs/aiopg diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/package.py b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/package.py new file mode 100644 index 0000000000..4fd4c11853 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("aiopg >= 0.13.0",) diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/wrappers.py b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/wrappers.py index 706648d643..a279891efb 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/wrappers.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/wrappers.py @@ -40,7 +40,7 @@ AiopgIntegration, get_traced_connection_proxy, ) -from opentelemetry.instrumentation.aiopg.version import __version__ +from opentelemetry.instrumentation.aiopg.package import __version__ from opentelemetry.instrumentation.utils import unwrap from opentelemetry.trace import TracerProvider diff --git a/instrumentation/opentelemetry-instrumentation-asgi/setup.cfg b/instrumentation/opentelemetry-instrumentation-asgi/setup.cfg index a112d2e228..572e34ed34 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-asgi/setup.cfg @@ -41,7 +41,6 @@ install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - asgiref ~= 3.0 [options.extras_require] test = diff --git a/instrumentation/opentelemetry-instrumentation-asgi/setup.py b/instrumentation/opentelemetry-instrumentation-asgi/setup.py index 703aceb28b..d8ec6e008b 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/setup.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/asgi. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/asgi. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "asgi", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "asgi", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py index 8de64290d0..ae012c1a74 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -26,7 +26,7 @@ from asgiref.compatibility import guarantee_single_callable from opentelemetry import context, trace -from opentelemetry.instrumentation.asgi.version import __version__ # noqa +from opentelemetry.instrumentation.asgi.package import __version__ # noqa from opentelemetry.instrumentation.utils import http_status_to_status_code from opentelemetry.propagate import extract from opentelemetry.propagators.textmap import Getter diff --git a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/package.py b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/package.py new file mode 100644 index 0000000000..23a4ff475b --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("asgiref ~= 3.0",) diff --git a/instrumentation/opentelemetry-instrumentation-asyncpg/setup.cfg b/instrumentation/opentelemetry-instrumentation-asyncpg/setup.cfg index e0326f90f7..f237fdded4 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncpg/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-asyncpg/setup.cfg @@ -41,7 +41,6 @@ install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - asyncpg >= 0.12.0 [options.extras_require] test = diff --git a/instrumentation/opentelemetry-instrumentation-asyncpg/setup.py b/instrumentation/opentelemetry-instrumentation-asyncpg/setup.py index a37e526577..d54b8157e8 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncpg/setup.py +++ b/instrumentation/opentelemetry-instrumentation-asyncpg/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/asyncpg. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/asyncpg. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "asyncpg", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py b/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py index 3db2be0efe..cc8d6feebf 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py @@ -34,12 +34,14 @@ --- """ +from typing import Collection + import asyncpg import wrapt from asyncpg import exceptions from opentelemetry import trace -from opentelemetry.instrumentation.asyncpg.version import __version__ +from opentelemetry.instrumentation.asyncpg.package import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.utils import unwrap from opentelemetry.semconv.trace import ( @@ -50,6 +52,8 @@ from opentelemetry.trace import SpanKind from opentelemetry.trace.status import Status, StatusCode +from . import package as pkg + _APPLIED = "_opentelemetry_tracer" @@ -99,6 +103,9 @@ def __init__(self, capture_parameters=False): super().__init__() self.capture_parameters = capture_parameters + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): tracer_provider = kwargs.get( "tracer_provider", trace.get_tracer_provider() diff --git a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/package.py b/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/package.py new file mode 100644 index 0000000000..8ac671666e --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("asyncpg >= 0.12.0",) diff --git a/instrumentation/opentelemetry-instrumentation-boto/setup.cfg b/instrumentation/opentelemetry-instrumentation-boto/setup.cfg index 5a3a7f0b7b..814bd2ee13 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-boto/setup.cfg @@ -38,7 +38,6 @@ package_dir= =src packages=find_namespace: install_requires = - boto ~= 2.0 opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 diff --git a/instrumentation/opentelemetry-instrumentation-boto/setup.py b/instrumentation/opentelemetry-instrumentation-boto/setup.py index d6fa149d4f..b0db81b323 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/setup.py +++ b/instrumentation/opentelemetry-instrumentation-boto/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/boto. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/boto. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "boto", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "boto", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py index 6a0df422d9..783978da55 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py @@ -43,17 +43,20 @@ import logging from inspect import currentframe +from typing import Collection from boto.connection import AWSAuthConnection, AWSQueryConnection from wrapt import wrap_function_wrapper -from opentelemetry.instrumentation.boto.version import __version__ +from opentelemetry.instrumentation.boto.package import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.utils import unwrap from opentelemetry.sdk.trace import Resource from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace import SpanKind, get_tracer +from . import package as pkg + logger = logging.getLogger(__name__) SERVICE_PARAMS_BLOCK_LIST = {"s3": ["params.Body"]} @@ -79,6 +82,9 @@ def __init__(self): super().__init__() self._original_boto = None + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): # AWSQueryConnection and AWSAuthConnection are two different classes # called by different services for connection. diff --git a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/package.py b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/package.py new file mode 100644 index 0000000000..6e1a94e71f --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("boto~=2.0",) diff --git a/instrumentation/opentelemetry-instrumentation-botocore/setup.cfg b/instrumentation/opentelemetry-instrumentation-botocore/setup.cfg index 45cb5fa4d5..be7b58fa4d 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-botocore/setup.cfg @@ -38,7 +38,6 @@ package_dir= =src packages=find_namespace: install_requires = - botocore ~= 1.0 opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 diff --git a/instrumentation/opentelemetry-instrumentation-botocore/setup.py b/instrumentation/opentelemetry-instrumentation-botocore/setup.py index 677b02aea8..c97f870ed9 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/setup.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/botocore. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/botocore. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "botocore", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py index 6f717660c7..9d5e1da5ea 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py @@ -47,19 +47,22 @@ """ import logging +from typing import Collection from botocore.client import BaseClient from botocore.exceptions import ClientError from wrapt import wrap_function_wrapper from opentelemetry import context as context_api -from opentelemetry.instrumentation.botocore.version import __version__ +from opentelemetry.instrumentation.botocore.package import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.utils import unwrap from opentelemetry.propagate import inject from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace import SpanKind, get_tracer +from . import package as pkg + logger = logging.getLogger(__name__) @@ -77,6 +80,9 @@ class BotocoreInstrumentor(BaseInstrumentor): See `BaseInstrumentor` """ + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): # pylint: disable=attribute-defined-outside-init diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/package.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/package.py new file mode 100644 index 0000000000..8eea3465f6 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("botocore ~= 1.0",) diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/version.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-celery/setup.cfg b/instrumentation/opentelemetry-instrumentation-celery/setup.cfg index f22f07adaa..7b2e40a1db 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-celery/setup.cfg @@ -38,7 +38,6 @@ package_dir= =src packages=find_namespace: install_requires = - celery >= 4.0, < 6.0 opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 diff --git a/instrumentation/opentelemetry-instrumentation-celery/setup.py b/instrumentation/opentelemetry-instrumentation-celery/setup.py index bad69429bb..c110ff9801 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/setup.py +++ b/instrumentation/opentelemetry-instrumentation-celery/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/celery. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/celery. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "celery", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "celery", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/__init__.py b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/__init__.py index 6518b6c2a1..b39f688d2d 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/__init__.py @@ -52,19 +52,21 @@ def add(x, y): """ import logging -from collections.abc import Iterable +from typing import Collection, Iterable from celery import signals # pylint: disable=no-name-in-module from opentelemetry import trace from opentelemetry.instrumentation.celery import utils -from opentelemetry.instrumentation.celery.version import __version__ +from opentelemetry.instrumentation.celery.package import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.propagate import extract, inject from opentelemetry.propagators.textmap import Getter from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace.status import Status, StatusCode +from . import package as pkg + logger = logging.getLogger(__name__) # Task operations @@ -95,6 +97,9 @@ def keys(self, carrier): class CeleryInstrumentor(BaseInstrumentor): + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): tracer_provider = kwargs.get("tracer_provider") diff --git a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/package.py b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/package.py new file mode 100644 index 0000000000..d1fc1110e7 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("celery >= 4.0, < 6.0",) diff --git a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/version.py b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/setup.py b/instrumentation/opentelemetry-instrumentation-dbapi/setup.py index fcdca36d37..e78b084716 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/setup.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/dbapi. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/dbapi. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "dbapi", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "dbapi", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py index 6ceb66cae7..7ca99e89de 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py @@ -44,7 +44,7 @@ import wrapt from opentelemetry import trace as trace_api -from opentelemetry.instrumentation.dbapi.version import __version__ +from opentelemetry.instrumentation.dbapi.package import __version__ from opentelemetry.instrumentation.utils import unwrap from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace import SpanKind, TracerProvider, get_tracer diff --git a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/version.py b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/package.py similarity index 96% rename from instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/version.py rename to instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/package.py index 2b08175266..bafbb89a74 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/version.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/package.py @@ -13,3 +13,5 @@ # limitations under the License. __version__ = "0.21.dev0" + +_instruments = tuple() diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/version.py b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-django/setup.cfg b/instrumentation/opentelemetry-instrumentation-django/setup.cfg index ac7eca0896..9dfe686d28 100644 --- a/instrumentation/opentelemetry-instrumentation-django/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-django/setup.cfg @@ -38,7 +38,6 @@ package_dir= =src packages=find_namespace: install_requires = - django >= 1.10 opentelemetry-util-http == 0.21.dev0 opentelemetry-instrumentation-wsgi == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 diff --git a/instrumentation/opentelemetry-instrumentation-django/setup.py b/instrumentation/opentelemetry-instrumentation-django/setup.py index 011173f19d..857d267764 100644 --- a/instrumentation/opentelemetry-instrumentation-django/setup.py +++ b/instrumentation/opentelemetry-instrumentation-django/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/django. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/django. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "django", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "django", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py index 04e473f182..defc576684 100644 --- a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py @@ -75,6 +75,7 @@ def response_hook(span, request, response): from logging import getLogger from os import environ +from typing import Collection from django.conf import settings @@ -82,9 +83,11 @@ def response_hook(span, request, response): OTEL_PYTHON_DJANGO_INSTRUMENT, ) from opentelemetry.instrumentation.django.middleware import _DjangoMiddleware -from opentelemetry.instrumentation.django.version import __version__ +from opentelemetry.instrumentation.django.package import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor +from . import package as pkg + _logger = getLogger(__name__) @@ -98,6 +101,9 @@ class DjangoInstrumentor(BaseInstrumentor): [_DjangoMiddleware.__module__, _DjangoMiddleware.__qualname__] ) + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): # FIXME this is probably a pattern that will show up in the rest of the diff --git a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py index 9d01da2997..55a7c2d5e8 100644 --- a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py +++ b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py @@ -19,7 +19,7 @@ from django.http import HttpRequest, HttpResponse from opentelemetry.context import attach, detach -from opentelemetry.instrumentation.django.version import __version__ +from opentelemetry.instrumentation.django.package import __version__ from opentelemetry.instrumentation.propagators import ( get_global_response_propagator, ) diff --git a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/package.py b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/package.py new file mode 100644 index 0000000000..9c2067640b --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("django >= 1.10",) diff --git a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/version.py b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.cfg b/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.cfg index e8564d69e7..1637936e8e 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.cfg @@ -42,7 +42,6 @@ install_requires = opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 wrapt >= 1.0.0, < 2.0.0 - elasticsearch >= 2.0 [options.extras_require] test = diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.py index ac7e8773e5..e7c757f39d 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/elasticsearch. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/elasticsearch. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "elasticsearch", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py index 34c894a17c..a3fceb2b2d 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py @@ -48,18 +48,21 @@ from logging import getLogger from os import environ +from typing import Collection import elasticsearch import elasticsearch.exceptions from wrapt import wrap_function_wrapper as _wrap -from opentelemetry.instrumentation.elasticsearch.version import __version__ +from opentelemetry.instrumentation.elasticsearch.package import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.utils import unwrap from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace import SpanKind, get_tracer from opentelemetry.trace.status import Status, StatusCode +from . import package as pkg + logger = getLogger(__name__) @@ -87,6 +90,9 @@ def __init__(self, span_name_prefix=None): self._span_name_prefix = span_name_prefix.strip() super().__init__() + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """ Instruments elasticsarch module diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/package.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/package.py new file mode 100644 index 0000000000..61792cf5ba --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("elasticsearch >= 2.0",) diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/version.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-falcon/setup.cfg b/instrumentation/opentelemetry-instrumentation-falcon/setup.cfg index af88e821dc..8e82e7f0c4 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-falcon/setup.cfg @@ -39,7 +39,6 @@ package_dir= =src packages=find_namespace: install_requires = - falcon ~= 2.0 opentelemetry-instrumentation-wsgi == 0.21.dev0 opentelemetry-util-http == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 diff --git a/instrumentation/opentelemetry-instrumentation-falcon/setup.py b/instrumentation/opentelemetry-instrumentation-falcon/setup.py index d072a50fe1..bfb923565c 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/setup.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/falcon. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/falcon. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "falcon", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "falcon", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py index 6eea16e04f..4cb330278b 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py @@ -92,12 +92,13 @@ def response_hook(span, req, resp): from functools import partial from logging import getLogger from sys import exc_info +from typing import Collection import falcon import opentelemetry.instrumentation.wsgi as otel_wsgi from opentelemetry import context, trace -from opentelemetry.instrumentation.falcon.version import __version__ +from opentelemetry.instrumentation.falcon.package import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.propagators import ( FuncSetter, @@ -113,6 +114,8 @@ def response_hook(span, req, resp): from opentelemetry.util._time import _time_ns from opentelemetry.util.http import get_excluded_urls, get_traced_request_attrs +from . import package as pkg + _logger = getLogger(__name__) _ENVIRON_STARTTIME_KEY = "opentelemetry-falcon.starttime_key" @@ -134,6 +137,9 @@ class FalconInstrumentor(BaseInstrumentor): See `BaseInstrumentor` """ + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): self._original_falcon_api = falcon.API falcon.API = partial(_InstrumentedFalconAPI, **kwargs) diff --git a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/package.py b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/package.py new file mode 100644 index 0000000000..797c4b53b1 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("falcon ~= 2.0",) diff --git a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/version.py b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/setup.py b/instrumentation/opentelemetry-instrumentation-fastapi/setup.py index 06d50601ca..7762aa11a2 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/setup.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/fastapi. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/fastapi. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "fastapi", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py index 99fa6cdc08..34e0833b62 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import Collection + import fastapi from starlette.routing import Match @@ -20,6 +22,8 @@ from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.util.http import get_excluded_urls +from . import package as pkg + _excluded_urls = get_excluded_urls("FASTAPI") @@ -43,6 +47,9 @@ def instrument_app(app: fastapi.FastAPI): ) app.is_instrumented_by_opentelemetry = True + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): self._original_fastapi = fastapi.FastAPI fastapi.FastAPI = _InstrumentedFastAPI diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/package.py b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/package.py new file mode 100644 index 0000000000..733a897434 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("fastapi ~= 0.58.1",) diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/version.py b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-flask/setup.cfg b/instrumentation/opentelemetry-instrumentation-flask/setup.cfg index 6b6fe2bd69..35e125247f 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-flask/setup.cfg @@ -38,7 +38,6 @@ package_dir= =src packages=find_namespace: install_requires = - flask ~= 1.0 opentelemetry-util-http == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 opentelemetry-instrumentation-wsgi == 0.21.dev0 diff --git a/instrumentation/opentelemetry-instrumentation-flask/setup.py b/instrumentation/opentelemetry-instrumentation-flask/setup.py index b48d6692e3..5c214f38ad 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/setup.py +++ b/instrumentation/opentelemetry-instrumentation-flask/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/flask. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/flask. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "flask", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "flask", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py index 030fd4cbad..04a12ea6d5 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py @@ -48,12 +48,13 @@ def hello(): """ from logging import getLogger +from typing import Collection import flask import opentelemetry.instrumentation.wsgi as otel_wsgi from opentelemetry import context, trace -from opentelemetry.instrumentation.flask.version import __version__ +from opentelemetry.instrumentation.flask.package import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.propagators import ( get_global_response_propagator, @@ -63,6 +64,8 @@ def hello(): from opentelemetry.util._time import _time_ns from opentelemetry.util.http import get_excluded_urls +from . import package as pkg + _logger = getLogger(__name__) _ENVIRON_STARTTIME_KEY = "opentelemetry-flask.starttime_key" @@ -206,6 +209,9 @@ class FlaskInstrumentor(BaseInstrumentor): See `BaseInstrumentor` """ + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): self._original_flask = flask.Flask name_callback = kwargs.get("name_callback") diff --git a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/package.py b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/package.py new file mode 100644 index 0000000000..46ba17749f --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("flask ~= 1.0",) diff --git a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-grpc/setup.cfg b/instrumentation/opentelemetry-instrumentation-grpc/setup.cfg index 3bfdf614d2..e82650c30b 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-grpc/setup.cfg @@ -42,7 +42,6 @@ install_requires = opentelemetry-sdk == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - grpcio ~= 1.27 wrapt >= 1.0.0, < 2.0.0 [options.extras_require] diff --git a/instrumentation/opentelemetry-instrumentation-grpc/setup.py b/instrumentation/opentelemetry-instrumentation-grpc/setup.py index 6ccc31833e..b8858ef45f 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/setup.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/grpc. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/grpc. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "grpc", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "grpc", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py index 43c6b8ba74..c3fe113d60 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py @@ -118,15 +118,19 @@ def serve(): interceptors = [server_interceptor()]) """ +from typing import Collection + import grpc # pylint:disable=import-self from wrapt import wrap_function_wrapper as _wrap from opentelemetry import trace from opentelemetry.instrumentation.grpc.grpcext import intercept_channel -from opentelemetry.instrumentation.grpc.version import __version__ +from opentelemetry.instrumentation.grpc.package import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.utils import unwrap +from . import package as pkg + # pylint:disable=import-outside-toplevel # pylint:disable=import-self # pylint:disable=unused-argument @@ -145,6 +149,9 @@ class GrpcInstrumentorServer(BaseInstrumentor): # pylint:disable=attribute-defined-outside-init, redefined-outer-name + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): self._original_func = grpc.server @@ -189,6 +196,9 @@ def _which_channel(self, kwargs): return tuple(types) + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): for ctype in self._which_channel(kwargs): _wrap( diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/package.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/package.py new file mode 100644 index 0000000000..d88830ade3 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("grpcio ~= 1.27",) diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/version.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-jinja2/setup.cfg b/instrumentation/opentelemetry-instrumentation-jinja2/setup.cfg index 4147b5d07a..fe37e948be 100644 --- a/instrumentation/opentelemetry-instrumentation-jinja2/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-jinja2/setup.cfg @@ -39,7 +39,6 @@ packages=find_namespace: install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-instrumentation == 0.21.dev0 - jinja2~=2.7 wrapt >= 1.0.0, < 2.0.0 [options.extras_require] diff --git a/instrumentation/opentelemetry-instrumentation-jinja2/setup.py b/instrumentation/opentelemetry-instrumentation-jinja2/setup.py index 9171311b54..5596b1bbdd 100644 --- a/instrumentation/opentelemetry-instrumentation-jinja2/setup.py +++ b/instrumentation/opentelemetry-instrumentation-jinja2/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/jinja2. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/jinja2. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "jinja2", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "jinja2", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/__init__.py b/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/__init__.py index 14a5860707..d57aae5dc8 100644 --- a/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/__init__.py @@ -40,16 +40,19 @@ # pylint: disable=no-value-for-parameter import logging +from typing import Collection import jinja2 from wrapt import ObjectProxy from wrapt import wrap_function_wrapper as _wrap from opentelemetry.instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.instrumentation.jinja2.version import __version__ +from opentelemetry.instrumentation.jinja2.package import __version__ from opentelemetry.instrumentation.utils import unwrap from opentelemetry.trace import SpanKind, get_tracer +from . import package as pkg + logger = logging.getLogger(__name__) ATTRIBUTE_JINJA2_TEMPLATE_NAME = "jinja2.template_name" @@ -123,6 +126,9 @@ class Jinja2Instrumentor(BaseInstrumentor): See `BaseInstrumentor` """ + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): tracer_provider = kwargs.get("tracer_provider") tracer = get_tracer(__name__, __version__, tracer_provider) diff --git a/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/package.py b/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/package.py new file mode 100644 index 0000000000..62fa612418 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("jinja2~=2.7",) diff --git a/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/version.py b/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-logging/setup.py b/instrumentation/opentelemetry-instrumentation-logging/setup.py index 050f96f2a9..a7a8a095e9 100644 --- a/instrumentation/opentelemetry-instrumentation-logging/setup.py +++ b/instrumentation/opentelemetry-instrumentation-logging/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/logging. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/logging. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "logging", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/__init__.py b/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/__init__.py index d8f5ec97b0..b377852a00 100644 --- a/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/__init__.py @@ -16,7 +16,7 @@ import logging # pylint: disable=import-self from os import environ -from typing import Callable +from typing import Callable, Collection from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.logging.constants import ( @@ -35,6 +35,8 @@ get_tracer_provider, ) +from . import package as pkg + __doc__ = _MODULE_DOC LEVELS = { @@ -73,6 +75,9 @@ class LoggingInstrumentor(BaseInstrumentor): # pylint: disable=empty-docstring _old_factory = None + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): service_name = "" provider = kwargs.get("tracer_provider", None) or get_tracer_provider() diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/version.py b/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/package.py similarity index 96% rename from instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/version.py rename to instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/package.py index 2b08175266..bafbb89a74 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/version.py +++ b/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/package.py @@ -13,3 +13,5 @@ # limitations under the License. __version__ = "0.21.dev0" + +_instruments = tuple() diff --git a/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py b/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-mysql/setup.cfg b/instrumentation/opentelemetry-instrumentation-mysql/setup.cfg index 18759c8651..9f84351ed0 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-mysql/setup.cfg @@ -41,7 +41,6 @@ install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-instrumentation-dbapi == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - mysql-connector-python ~= 8.0 wrapt >= 1.0.0, < 2.0.0 [options.extras_require] diff --git a/instrumentation/opentelemetry-instrumentation-mysql/setup.py b/instrumentation/opentelemetry-instrumentation-mysql/setup.py index e7b9b3c2e4..2a24bf54fc 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/setup.py +++ b/instrumentation/opentelemetry-instrumentation-mysql/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/mysql. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/mysql. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "mysql", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "mysql", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py index 9fdf594c56..68ee3b02d6 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py @@ -38,13 +38,17 @@ --- """ +from typing import Collection + import mysql.connector from opentelemetry.instrumentation import dbapi from opentelemetry.instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.instrumentation.mysql.version import __version__ +from opentelemetry.instrumentation.mysql.package import __version__ from opentelemetry.trace import get_tracer +from . import package as pkg + class MySQLInstrumentor(BaseInstrumentor): _CONNECTION_ATTRIBUTES = { @@ -56,6 +60,9 @@ class MySQLInstrumentor(BaseInstrumentor): _DATABASE_SYSTEM = "mysql" + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Integrate with MySQL Connector/Python library. https://dev.mysql.com/doc/connector-python/en/ diff --git a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/package.py b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/package.py new file mode 100644 index 0000000000..8a77c5de0a --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("mysql-connector-python ~= 8.0",) diff --git a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/version.py b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/setup.cfg b/instrumentation/opentelemetry-instrumentation-psycopg2/setup.cfg index 79f2f795cb..1368232a8d 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/setup.cfg @@ -41,7 +41,6 @@ install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-instrumentation-dbapi == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - psycopg2-binary >= 2.7.3.1 wrapt >= 1.0.0, < 2.0.0 [options.extras_require] diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/setup.py b/instrumentation/opentelemetry-instrumentation-psycopg2/setup.py index df471100d0..1fbd1a3e73 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/setup.py +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/psycopg2. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/psycopg2. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "psycopg2", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py index 1190d1c083..d325473701 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py @@ -40,6 +40,7 @@ """ import typing +from typing import Collection import psycopg2 from psycopg2.extensions import ( @@ -49,7 +50,9 @@ from opentelemetry.instrumentation import dbapi from opentelemetry.instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.instrumentation.psycopg2.version import __version__ +from opentelemetry.instrumentation.psycopg2.package import __version__ + +from . import package as pkg _OTEL_CURSOR_FACTORY_KEY = "_otel_orig_cursor_factory" @@ -64,6 +67,9 @@ class Psycopg2Instrumentor(BaseInstrumentor): _DATABASE_SYSTEM = "postgresql" + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Integrate with PostgreSQL Psycopg library. Psycopg: http://initd.org/psycopg/ diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/package.py b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/package.py new file mode 100644 index 0000000000..3967bc5f19 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("psycopg2-binary >= 2.7.3.1",) diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/version.py b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/setup.cfg b/instrumentation/opentelemetry-instrumentation-pymemcache/setup.cfg index a5937d9097..d00524bf6d 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/setup.cfg @@ -41,7 +41,6 @@ install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - pymemcache ~= 1.3 wrapt >= 1.0.0, < 2.0.0 [options.extras_require] diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/setup.py b/instrumentation/opentelemetry-instrumentation-pymemcache/setup.py index 21406726d4..f05023201e 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/setup.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/pymemcache. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/pymemcache. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "pymemcache", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/__init__.py b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/__init__.py index a5ef627f1a..851c49b781 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/__init__.py @@ -38,13 +38,14 @@ # pylint: disable=no-value-for-parameter import logging +from typing import Collection import pymemcache from wrapt import ObjectProxy from wrapt import wrap_function_wrapper as _wrap from opentelemetry.instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.instrumentation.pymemcache.version import __version__ +from opentelemetry.instrumentation.pymemcache.package import __version__ from opentelemetry.instrumentation.utils import unwrap from opentelemetry.semconv.trace import ( DbSystemValues, @@ -53,6 +54,8 @@ ) from opentelemetry.trace import SpanKind, get_tracer +from . import package as pkg + logger = logging.getLogger(__name__) @@ -181,6 +184,9 @@ def _get_address_attributes(instance): class PymemcacheInstrumentor(BaseInstrumentor): """An instrumentor for pymemcache See `BaseInstrumentor`""" + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): tracer_provider = kwargs.get("tracer_provider") tracer = get_tracer(__name__, __version__, tracer_provider) diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/package.py b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/package.py new file mode 100644 index 0000000000..edb6f4c327 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("pymemcache ~= 1.3",) diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/version.py b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/setup.cfg b/instrumentation/opentelemetry-instrumentation-pymongo/setup.cfg index c0cab48390..a05690dc5d 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-pymongo/setup.cfg @@ -41,7 +41,6 @@ install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - pymongo ~= 3.1 [options.extras_require] test = diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/setup.py b/instrumentation/opentelemetry-instrumentation-pymongo/setup.py index d477dcc654..67c9807cf7 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/setup.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/pymongo. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/pymongo. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "pymongo", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py index cd3743e395..d135ac3cc6 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py @@ -37,15 +37,19 @@ --- """ +from typing import Collection + from pymongo import monitoring from opentelemetry import trace from opentelemetry.instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.instrumentation.pymongo.version import __version__ +from opentelemetry.instrumentation.pymongo.package import __version__ from opentelemetry.semconv.trace import DbSystemValues, SpanAttributes from opentelemetry.trace import SpanKind, get_tracer from opentelemetry.trace.status import Status, StatusCode +from . import package as pkg + class CommandTracer(monitoring.CommandListener): def __init__(self, tracer): @@ -127,6 +131,9 @@ class PymongoInstrumentor(BaseInstrumentor): # instrumentation an enabled flag is implemented in CommandTracer, # it's checked in the different listeners. + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Integrate with pymongo to trace it using event listener. https://api.mongodb.com/python/current/api/pymongo/monitoring.html diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/package.py b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/package.py new file mode 100644 index 0000000000..abcef7cd6e --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("pymongo ~= 3.1",) diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/version.py b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-pymysql/setup.cfg b/instrumentation/opentelemetry-instrumentation-pymysql/setup.cfg index 726e606c5a..8fbac88d67 100644 --- a/instrumentation/opentelemetry-instrumentation-pymysql/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-pymysql/setup.cfg @@ -41,7 +41,6 @@ install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-instrumentation-dbapi == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - PyMySQL ~= 0.10.1 [options.extras_require] test = diff --git a/instrumentation/opentelemetry-instrumentation-pymysql/setup.py b/instrumentation/opentelemetry-instrumentation-pymysql/setup.py index 2e3fa5a70e..d6335a7486 100644 --- a/instrumentation/opentelemetry-instrumentation-pymysql/setup.py +++ b/instrumentation/opentelemetry-instrumentation-pymysql/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/pymysql. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/pymysql. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "pymysql", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py b/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py index 5e9952bc47..0a3dc72343 100644 --- a/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py @@ -40,11 +40,15 @@ --- """ +from typing import Collection + import pymysql from opentelemetry.instrumentation import dbapi from opentelemetry.instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.instrumentation.pymysql.version import __version__ +from opentelemetry.instrumentation.pymysql.package import __version__ + +from . import package as pkg class PyMySQLInstrumentor(BaseInstrumentor): @@ -57,6 +61,9 @@ class PyMySQLInstrumentor(BaseInstrumentor): _DATABASE_SYSTEM = "mysql" + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Integrate with the PyMySQL library. https://github.com/PyMySQL/PyMySQL/ diff --git a/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/package.py b/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/package.py new file mode 100644 index 0000000000..7854729132 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("PyMySQL ~= 0.10.1",) diff --git a/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/version.py b/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/setup.cfg b/instrumentation/opentelemetry-instrumentation-pyramid/setup.cfg index e9870d64e7..8ea25cab83 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-pyramid/setup.cfg @@ -38,7 +38,6 @@ package_dir= =src packages=find_namespace: install_requires = - pyramid >= 1.7 opentelemetry-instrumentation == 0.21.dev0 opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/setup.py b/instrumentation/opentelemetry-instrumentation-pyramid/setup.py index 338f1eabea..067aca0868 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/setup.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/pyramid. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/pyramid. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "pyramid", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/__init__.py b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/__init__.py index 4125453153..bdfd54fd33 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/__init__.py @@ -79,6 +79,7 @@ """ import typing +from typing import Collection from pyramid.config import Configurator from pyramid.path import caller_package @@ -92,10 +93,12 @@ TWEEN_NAME, trace_tween_factory, ) -from opentelemetry.instrumentation.pyramid.version import __version__ +from opentelemetry.instrumentation.pyramid.package import __version__ from opentelemetry.instrumentation.utils import unwrap from opentelemetry.trace import TracerProvider, get_tracer +from . import package as pkg + def _traced_init(wrapped, instance, args, kwargs): settings = kwargs.get("settings", {}) @@ -125,6 +128,9 @@ def _traced_init(wrapped, instance, args, kwargs): class PyramidInstrumentor(BaseInstrumentor): + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Integrate with Pyramid Python library. https://docs.pylonsproject.org/projects/pyramid/en/latest/ diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py index 292c38e029..9ae2472600 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py @@ -24,7 +24,7 @@ from opentelemetry.instrumentation.propagators import ( get_global_response_propagator, ) -from opentelemetry.instrumentation.pyramid.version import __version__ +from opentelemetry.instrumentation.pyramid.package import __version__ from opentelemetry.propagate import extract from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.util._time import _time_ns diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/package.py b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/package.py new file mode 100644 index 0000000000..cfd8512181 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("pyramid >= 1.7",) diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/version.py b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-redis/setup.cfg b/instrumentation/opentelemetry-instrumentation-redis/setup.cfg index 31e90b37dc..f1bf9b52d4 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-redis/setup.cfg @@ -41,7 +41,6 @@ install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - redis >= 2.6 wrapt >= 1.12.1 [options.extras_require] diff --git a/instrumentation/opentelemetry-instrumentation-redis/setup.py b/instrumentation/opentelemetry-instrumentation-redis/setup.py index 2426a141dc..2b55fed7e6 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/setup.py +++ b/instrumentation/opentelemetry-instrumentation-redis/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/redis. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/redis. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "redis", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "redis", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py index 3d02d982d0..eb5963646e 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py @@ -42,19 +42,23 @@ --- """ +from typing import Collection + import redis from wrapt import ObjectProxy, wrap_function_wrapper from opentelemetry import trace from opentelemetry.instrumentation.instrumentor import BaseInstrumentor +from opentelemetry.instrumentation.redis.package import __version__ from opentelemetry.instrumentation.redis.util import ( _extract_conn_attributes, _format_command_args, ) -from opentelemetry.instrumentation.redis.version import __version__ from opentelemetry.instrumentation.utils import unwrap from opentelemetry.semconv.trace import SpanAttributes +from . import package as pkg + _DEFAULT_SERVICE = "redis" @@ -110,6 +114,9 @@ class RedisInstrumentor(BaseInstrumentor): See `BaseInstrumentor` """ + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): tracer_provider = kwargs.get( "tracer_provider", trace.get_tracer_provider() diff --git a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/package.py b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/package.py new file mode 100644 index 0000000000..804b7c1ed3 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("redis >= 2.6",) diff --git a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/version.py b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-requests/setup.cfg b/instrumentation/opentelemetry-instrumentation-requests/setup.cfg index c49aa3342c..30fa9afff8 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-requests/setup.cfg @@ -41,7 +41,6 @@ install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - requests ~= 2.0 [options.extras_require] test = diff --git a/instrumentation/opentelemetry-instrumentation-requests/setup.py b/instrumentation/opentelemetry-instrumentation-requests/setup.py index 5beef7e98a..fd23bd0b80 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/setup.py +++ b/instrumentation/opentelemetry-instrumentation-requests/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/requests. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/requests. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "requests", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py index 29cf67d0c6..73e66f43b2 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py @@ -35,6 +35,7 @@ import functools import types +from typing import Collection from requests.models import Response from requests.sessions import Session @@ -42,13 +43,15 @@ from opentelemetry import context from opentelemetry.instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.instrumentation.requests.version import __version__ +from opentelemetry.instrumentation.requests.package import __version__ from opentelemetry.instrumentation.utils import http_status_to_status_code from opentelemetry.propagate import inject from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace import SpanKind, get_tracer from opentelemetry.trace.status import Status +from . import package as pkg + # A key to a context variable to avoid creating duplicate spans when instrumenting # both, Session.request and Session.send, since Session.request calls into Session.send _SUPPRESS_HTTP_INSTRUMENTATION_KEY = "suppress_http_instrumentation" @@ -213,6 +216,9 @@ class RequestsInstrumentor(BaseInstrumentor): See `BaseInstrumentor` """ + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Instruments requests module diff --git a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/package.py b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/package.py new file mode 100644 index 0000000000..6c8d2abf2e --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("requests ~= 2.0",) diff --git a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-sklearn/setup.cfg b/instrumentation/opentelemetry-instrumentation-sklearn/setup.cfg index f95094ef9e..5f22fdc663 100644 --- a/instrumentation/opentelemetry-instrumentation-sklearn/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-sklearn/setup.cfg @@ -40,7 +40,6 @@ packages=find_namespace: install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-instrumentation == 0.21.dev0 - scikit-learn ~= 0.22.0 [options.extras_require] test = diff --git a/instrumentation/opentelemetry-instrumentation-sklearn/setup.py b/instrumentation/opentelemetry-instrumentation-sklearn/setup.py index 5e61f67d39..378df960da 100644 --- a/instrumentation/opentelemetry-instrumentation-sklearn/setup.py +++ b/instrumentation/opentelemetry-instrumentation-sklearn/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/sklearn. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/sklearn. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "sklearn", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/__init__.py b/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/__init__.py index 90d57f05a6..22e726fe82 100644 --- a/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/__init__.py @@ -65,7 +65,16 @@ from importlib import import_module from inspect import isclass from pkgutil import iter_modules -from typing import Callable, Dict, List, MutableMapping, Sequence, Type, Union +from typing import ( + Callable, + Collection, + Dict, + List, + MutableMapping, + Sequence, + Type, + Union, +) from sklearn.base import BaseEstimator from sklearn.pipeline import FeatureUnion, Pipeline @@ -73,10 +82,12 @@ from sklearn.utils.metaestimators import _IffHasAttrDescriptor from opentelemetry.instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.instrumentation.sklearn.version import __version__ +from opentelemetry.instrumentation.sklearn.package import __version__ from opentelemetry.trace import get_tracer from opentelemetry.util.types import Attributes +from . import package as pkg + logger = logging.getLogger(__name__) @@ -361,6 +372,9 @@ def __init__( else: self.exclude_classes = tuple(exclude_classes) + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Instrument the library, and any additional specified on init.""" klasses = get_base_estimators(packages=self.packages) diff --git a/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/version.py b/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/package.py similarity index 93% rename from instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/version.py rename to instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/package.py index 0b40082f67..23be3db5fb 100644 --- a/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/version.py +++ b/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/package.py @@ -13,3 +13,5 @@ # limitations under the License. __version__ = "0.21.dev0" + +_instruments = ("scikit-learn ~= 0.22.0",) diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.cfg b/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.cfg index 3b4998dc67..fbd0a038fb 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.cfg @@ -42,7 +42,6 @@ install_requires = opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 wrapt >= 1.11.2 - sqlalchemy [options.extras_require] test = diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.py index 4980a1f870..463ec48f38 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/sqlalchemy. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/sqlalchemy. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "sqlalchemy", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/__init__.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/__init__.py index d10cb385a4..679a35340f 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/__init__.py @@ -39,6 +39,8 @@ API --- """ +from typing import Collection + import sqlalchemy import wrapt from wrapt import wrap_function_wrapper as _w @@ -51,12 +53,17 @@ ) from opentelemetry.instrumentation.utils import unwrap +from . import package as pkg + class SQLAlchemyInstrumentor(BaseInstrumentor): """An instrumentor for SQLAlchemy See `BaseInstrumentor` """ + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Instruments SQLAlchemy engine creation methods and the engine if passed as an argument. diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py index f2beb024d8..064e18683c 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py @@ -18,7 +18,7 @@ from sqlalchemy.event import listen # pylint: disable=no-name-in-module from opentelemetry import trace -from opentelemetry.instrumentation.sqlalchemy.version import __version__ +from opentelemetry.instrumentation.sqlalchemy.package import __version__ from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace.status import Status, StatusCode diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/package.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/package.py new file mode 100644 index 0000000000..536610bf73 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("sqlalchemy",) diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/version.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-sqlite3/setup.py b/instrumentation/opentelemetry-instrumentation-sqlite3/setup.py index 20cbc737dc..779e27f83d 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlite3/setup.py +++ b/instrumentation/opentelemetry-instrumentation-sqlite3/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/sqlite3. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/sqlite3. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "sqlite3", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py b/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py index 7ba76968af..db6b07111f 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py @@ -40,12 +40,15 @@ """ import sqlite3 +from typing import Collection from opentelemetry.instrumentation import dbapi from opentelemetry.instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.instrumentation.sqlite3.version import __version__ +from opentelemetry.instrumentation.sqlite3.package import __version__ from opentelemetry.trace import get_tracer +from . import package as pkg + class SQLite3Instrumentor(BaseInstrumentor): # No useful attributes of sqlite3 connection object @@ -53,6 +56,9 @@ class SQLite3Instrumentor(BaseInstrumentor): _DATABASE_SYSTEM = "sqlite" + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Integrate with SQLite3 Python library. https://docs.python.org/3/library/sqlite3.html diff --git a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/version.py b/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/package.py similarity index 96% rename from instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/version.py rename to instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/package.py index 2b08175266..bafbb89a74 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/version.py +++ b/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/package.py @@ -13,3 +13,5 @@ # limitations under the License. __version__ = "0.21.dev0" + +_instruments = tuple() diff --git a/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/version.py b/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-starlette/setup.py b/instrumentation/opentelemetry-instrumentation-starlette/setup.py index 3245e1f668..55dc7c2b67 100644 --- a/instrumentation/opentelemetry-instrumentation-starlette/setup.py +++ b/instrumentation/opentelemetry-instrumentation-starlette/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/starlette. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/starlette. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "starlette", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/__init__.py b/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/__init__.py index 2e3fe9e45c..2e8326c0c1 100644 --- a/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/__init__.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import Collection + from starlette import applications from starlette.routing import Match @@ -20,6 +22,8 @@ from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.util.http import get_excluded_urls +from . import package as pkg + _excluded_urls = get_excluded_urls("STARLETTE") @@ -43,6 +47,9 @@ def instrument_app(app: applications.Starlette): ) app.is_instrumented_by_opentelemetry = True + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): self._original_starlette = applications.Starlette applications.Starlette = _InstrumentedStarlette diff --git a/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/package.py b/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/package.py new file mode 100644 index 0000000000..732d3b9ddd --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("starlette ~= 0.13.0",) diff --git a/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/version.py b/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-tornado/setup.cfg b/instrumentation/opentelemetry-instrumentation-tornado/setup.cfg index 217aa6cf7c..ea5adbc89f 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-tornado/setup.cfg @@ -37,7 +37,6 @@ package_dir= =src packages=find_namespace: install_requires = - tornado >= 6.0 opentelemetry-instrumentation == 0.21.dev0 opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 @@ -45,7 +44,6 @@ install_requires = [options.extras_require] test = - tornado >= 6.0 opentelemetry-test == 0.21.dev0 [options.entry_points] diff --git a/instrumentation/opentelemetry-instrumentation-tornado/setup.py b/instrumentation/opentelemetry-instrumentation-tornado/setup.py index e0535bd5e0..eda1df5609 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/setup.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/tornado. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/tornado. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "tornado", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py index e13d24c971..d6cbfb712b 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py @@ -76,6 +76,7 @@ def client_resposne_hook(span, future): from collections import namedtuple from functools import partial from logging import getLogger +from typing import Collection import tornado.web import wrapt @@ -87,7 +88,7 @@ def client_resposne_hook(span, future): FuncSetter, get_global_response_propagator, ) -from opentelemetry.instrumentation.tornado.version import __version__ +from opentelemetry.instrumentation.tornado.package import __version__ from opentelemetry.instrumentation.utils import ( extract_attributes_from_object, http_status_to_status_code, @@ -99,6 +100,7 @@ def client_resposne_hook(span, future): from opentelemetry.util._time import _time_ns from opentelemetry.util.http import get_excluded_urls, get_traced_request_attrs +from . import package as pkg from .client import fetch_async # pylint: disable=E0401 _logger = getLogger(__name__) @@ -117,6 +119,9 @@ class TornadoInstrumentor(BaseInstrumentor): patched_handlers = [] original_handler_new = None + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """ _instrument patches tornado.web.RequestHandler and tornado.httpclient.AsyncHTTPClient classes diff --git a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/package.py b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/package.py new file mode 100644 index 0000000000..2deaac4c91 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("tornado >= 6.0",) diff --git a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/version.py b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-urllib/setup.py b/instrumentation/opentelemetry-instrumentation-urllib/setup.py index 6989ef4969..8e1a9b78a7 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/setup.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/urllib. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/urllib. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "urllib", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "urllib", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py index 5a586317e6..2cbe57db3d 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py @@ -38,6 +38,7 @@ import functools import types +from typing import Collection from urllib.request import ( # pylint: disable=no-name-in-module,import-error OpenerDirector, Request, @@ -45,7 +46,7 @@ from opentelemetry import context from opentelemetry.instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.instrumentation.urllib.version import ( # pylint: disable=no-name-in-module,import-error +from opentelemetry.instrumentation.urllib.package import ( # pylint: disable=no-name-in-module,import-error __version__, ) from opentelemetry.instrumentation.utils import http_status_to_status_code @@ -54,6 +55,8 @@ from opentelemetry.trace import SpanKind, get_tracer from opentelemetry.trace.status import Status +from . import package as pkg + # A key to a context variable to avoid creating duplicate spans when instrumenting _SUPPRESS_HTTP_INSTRUMENTATION_KEY = "suppress_http_instrumentation" @@ -63,6 +66,9 @@ class URLLibInstrumentor(BaseInstrumentor): See `BaseInstrumentor` """ + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Instruments urllib module diff --git a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/version.py b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/package.py similarity index 96% rename from instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/version.py rename to instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/package.py index 2b08175266..bafbb89a74 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/version.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/package.py @@ -13,3 +13,5 @@ # limitations under the License. __version__ = "0.21.dev0" + +_instruments = tuple() diff --git a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/version.py b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/setup.cfg b/instrumentation/opentelemetry-instrumentation-urllib3/setup.cfg index f2051cfcd9..76e623a854 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-urllib3/setup.cfg @@ -41,7 +41,6 @@ install_requires = opentelemetry-api == 1.2.0.dev0 opentelemetry-semantic-conventions == 0.21.dev0 opentelemetry-instrumentation == 0.21.dev0 - urllib3 >= 1.0.0, < 2.0.0 wrapt >= 1.0.0, < 2.0.0 [options.extras_require] diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/setup.py b/instrumentation/opentelemetry-instrumentation-urllib3/setup.py index 1054a2352c..2bf6e7a1f5 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/setup.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/setup.py @@ -13,25 +13,43 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/urllib3. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/urllib3. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( +PACKAGE_FILENAME = os.path.join( BASE_DIR, "src", "opentelemetry", "instrumentation", "urllib3", - "version.py", + "package.py", ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py index 0885656cd6..7205fefaa5 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py @@ -46,13 +46,14 @@ def span_name_callback(method: str, url: str, headers): import contextlib import typing +from typing import Collection import urllib3.connectionpool import wrapt from opentelemetry import context from opentelemetry.instrumentation.instrumentor import BaseInstrumentor -from opentelemetry.instrumentation.urllib3.version import __version__ +from opentelemetry.instrumentation.urllib3.package import __version__ from opentelemetry.instrumentation.utils import ( http_status_to_status_code, unwrap, @@ -62,6 +63,8 @@ def span_name_callback(method: str, url: str, headers): from opentelemetry.trace import Span, SpanKind, TracerProvider, get_tracer from opentelemetry.trace.status import Status +from . import package as pkg + _SUPPRESS_HTTP_INSTRUMENTATION_KEY = "suppress_http_instrumentation" _UrlFilterT = typing.Optional[typing.Callable[[str], str]] @@ -76,6 +79,9 @@ def span_name_callback(method: str, url: str, headers): class URLLib3Instrumentor(BaseInstrumentor): + def instrumentation_dependencies(self) -> Collection[str]: + return pkg._instruments + def _instrument(self, **kwargs): """Instruments the urllib3 module diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/package.py b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/package.py new file mode 100644 index 0000000000..ad358c451c --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = ("urllib3 >= 1.0.0, < 2.0.0",) diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/setup.py b/instrumentation/opentelemetry-instrumentation-wsgi/setup.py index 04ec707083..c3f7a03d55 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/setup.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/setup.py @@ -13,20 +13,38 @@ # limitations under the License. -# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templaes/wsgi. +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/wsgi. # Run `python scripts/generate_setuppy.py` to regenerate. import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read("setup.cfg") + +extras_require = {} +if "options.extras_require" in config: + for key, value in config["options.extras_require"].items(): + extras_require[key] = [v for v in value.split("\n") if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, "src", "opentelemetry", "instrumentation", "wsgi", "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "wsgi", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], extras_require=extras_require +) diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py index 1d04ab7a8b..2421f5e044 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py @@ -60,7 +60,7 @@ def hello(): from opentelemetry import context, trace from opentelemetry.instrumentation.utils import http_status_to_status_code -from opentelemetry.instrumentation.wsgi.version import __version__ +from opentelemetry.instrumentation.wsgi.package import __version__ from opentelemetry.propagate import extract from opentelemetry.propagators.textmap import Getter from opentelemetry.semconv.trace import SpanAttributes diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/package.py b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/package.py new file mode 100644 index 0000000000..bafbb89a74 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/package.py @@ -0,0 +1,17 @@ +# 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.21.dev0" + +_instruments = tuple() diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py deleted file mode 100644 index 2b08175266..0000000000 --- a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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.21.dev0" diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py index 10c8faf899..e0d862024e 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py @@ -23,6 +23,7 @@ from opentelemetry.environment_variables import ( OTEL_PYTHON_DISABLED_INSTRUMENTATIONS, ) +from opentelemetry.instrumentation.resources import get_dist_dependency_conflicts logger = getLogger(__file__) @@ -53,7 +54,14 @@ def _load_instrumentors(): "Instrumentation skipped for library %s", entry_point.name ) continue - entry_point.load()().instrument() # type: ignore + + conflict = get_dist_dependency_conflicts(entry_point.dist) + if conflict: + logger.debug("Skipping instrumentation %s: %s", entry_point.name, conflict) + continue + + # tell instrumentation to not run dep checks again as we already did it above + entry_point.load()().instrument(skip_dep_check=True) # type: ignore logger.debug("Instrumented %s", entry_point.name) except Exception as exc: # pylint: disable=broad-except logger.exception("Instrumenting of %s failed", entry_point.name) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py index 8cd77a8a5b..6ddc308133 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py @@ -19,6 +19,9 @@ from abc import ABC, abstractmethod from logging import getLogger +from typing import Collection + +from opentelemetry.instrumentation.resources import get_dependency_conflicts _LOG = getLogger(__name__) @@ -47,6 +50,9 @@ def __new__(cls, *args, **kwargs): return cls._instance @abstractmethod + def instrumentation_dependencies(self) -> Collection[str]: + """"Return the Python package name""" + def _instrument(self, **kwargs): """Instrument the library""" @@ -54,6 +60,10 @@ def _instrument(self, **kwargs): def _uninstrument(self, **kwargs): """Uninstrument the library""" + def _check_dependency_conflicts(self) -> bool: + dependencies = self.instrumentation_dependencies() + return get_dependency_conflicts(dependencies) + def instrument(self, **kwargs): """Instrument the library @@ -65,14 +75,23 @@ def instrument(self, **kwargs): ``opentelemetry-instrument`` command does. """ - if not self._is_instrumented: - result = self._instrument(**kwargs) - self._is_instrumented = True - return result - - _LOG.warning("Attempting to instrument while already instrumented") - - return None + if self._is_instrumented: + _LOG.warning("Attempting to instrument while already instrumented") + return None + + # check if instrumentor has any missing or conflicting dependencies + skip_dep_check = kwargs.pop('skip_dep_check', False) + if not skip_dep_check: + conflict = self._check_dependency_conflicts() + if conflict: + _LOG.debug(conflict) + return None + + result = self._instrument( # pylint: disable=assignment-from-no-return + **kwargs + ) + self._is_instrumented = True + return result def uninstrument(self, **kwargs): """Uninstrument the library diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/resources.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/resources.py new file mode 100644 index 0000000000..15df5b6db8 --- /dev/null +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/resources.py @@ -0,0 +1,40 @@ +from typing import Collection, Optional + +from pkg_resources import ( + Distribution, + DistributionNotFound, + VersionConflict, + get_distribution, +) + + +class DependencyConflict: + required: str = None + found: Optional[str] = None + + def __init__(self, required, found=None): + self.required = required + self.found = found + + def __str__(self): + return 'DependencyConflict: requested: "{0}" but found: "{1}"'.format( + self.required, self.found + ) + + +def get_dist_dependency_conflicts(dist: Distribution) -> Optional[DependencyConflict]: + deps = [dep for dep in dist.requires(('instruments',)) if dep not in dist.requires()] + return get_dependency_conflicts(deps) + + +def get_dependency_conflicts( + deps: Collection[str], +) -> Optional[DependencyConflict]: + for dep in deps: + try: + get_distribution(str(dep)) + except VersionConflict as exc: + return DependencyConflict(dep, exc.dist) + except DistributionNotFound: + return DependencyConflict(dep) + return None diff --git a/opentelemetry-instrumentation/tests/test_instrumentor.py b/opentelemetry-instrumentation/tests/test_instrumentor.py index 19104a3246..dee32c34e4 100644 --- a/opentelemetry-instrumentation/tests/test_instrumentor.py +++ b/opentelemetry-instrumentation/tests/test_instrumentor.py @@ -27,6 +27,9 @@ def _instrument(self, **kwargs): def _uninstrument(self, **kwargs): return "uninstrumented" + def instrumentation_dependencies(self): + return [] + def test_protect(self): instrumentor = self.Instrumentor() diff --git a/opentelemetry-instrumentation/tests/test_resources.py b/opentelemetry-instrumentation/tests/test_resources.py new file mode 100644 index 0000000000..48c22a3121 --- /dev/null +++ b/opentelemetry-instrumentation/tests/test_resources.py @@ -0,0 +1,56 @@ +# 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. + +# pylint: disable=protected-access + +import pytest + +from opentelemetry.instrumentation.resources import ( + DependencyConflict, + get_dependency_conflicts, +) +from opentelemetry.test.test_base import TestBase + + +class TestDependencyConflicts(TestBase): + def setUp(self): + pass + + def test_get_dependency_conflicts_empty(self): + self.assertIsNone(get_dependency_conflicts([])) + + def test_get_dependency_conflicts_no_conflict(self): + self.assertIsNone(get_dependency_conflicts(["pytest"])) + + def test_get_dependency_conflicts_not_installed(self): + conflict = get_dependency_conflicts(["this-package-does-not-exist"]) + self.assertTrue(conflict is not None) + self.assertTrue(isinstance(conflict, DependencyConflict)) + print(conflict) + self.assertEqual( + str(conflict), + 'DependencyConflict: requested: "this-package-does-not-exist" but found: "None"', + ) + + def test_get_dependency_conflicts_mismatched_version(self): + conflict = get_dependency_conflicts(["pytest == 5000"]) + self.assertTrue(conflict is not None) + self.assertTrue(isinstance(conflict, DependencyConflict)) + print(conflict) + self.assertEqual( + str(conflict), + 'DependencyConflict: requested: "pytest == 5000" but found: "pytest {0}"'.format( + pytest.__version__ + ), + ) diff --git a/templates/instrumentation_setup.py.txt b/templates/instrumentation_setup.py.txt index b619c49b56..38d06f4ed5 100644 --- a/templates/instrumentation_setup.py.txt +++ b/templates/instrumentation_setup.py.txt @@ -17,20 +17,34 @@ {{ auto_generation_msg }} import os +from configparser import ConfigParser import setuptools +config = ConfigParser() +config.read('setup.cfg') + +extras_require = {} +if 'options.extras_require' in config: + for key, value in config['options.extras_require'].items(): + extras_require[key] = [v for v in value.split('\n') if v.strip()] + BASE_DIR = os.path.dirname(__file__) -VERSION_FILENAME = os.path.join( - BASE_DIR, - "src", - "opentelemetry", - "instrumentation", - "{{ name }}", - "version.py" +PACKAGE_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "{{ name }}", "package.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(PACKAGE_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"]) \ No newline at end of file +extras_require["instruments"] = PACKAGE_INFO["_instruments"] +test_deps = extras_require.get("test", []) +for dep in extras_require["instruments"]: + test_deps.append(dep) + +extras_require["test"] = test_deps + +setuptools.setup( + version=PACKAGE_INFO["__version__"], + extras_require=extras_require +) \ No newline at end of file diff --git a/tox.ini b/tox.ini index d28b82988e..f3bd555015 100644 --- a/tox.ini +++ b/tox.ini @@ -220,22 +220,22 @@ commands_pre = py3{6,7,8,9}: python -m pip install -U pip setuptools wheel ; Install common packages for all the tests. These are not needed in all the ; cases but it saves a lot of boilerplate in this file. - test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-api - test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-semantic-conventions - test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-sdk - test: pip install {toxinidir}/opentelemetry-python-core/tests/util + test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-api[test] + test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-semantic-conventions[test] + test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-sdk[test] + test: pip install {toxinidir}/opentelemetry-python-core/tests/util[test] - test: pip install {toxinidir}/opentelemetry-instrumentation + test: pip install {toxinidir}/opentelemetry-instrumentation[test] celery: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-celery[test] grpc: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-grpc[test] - falcon,flask,django,pyramid,tornado,starlette,fastapi: pip install {toxinidir}/util/opentelemetry-util-http - wsgi,falcon,flask,django,pyramid: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-wsgi - asgi,starlette,fastapi: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-asgi + falcon,flask,django,pyramid,tornado,starlette,fastapi: pip install {toxinidir}/util/opentelemetry-util-http[test] + wsgi,falcon,flask,django,pyramid: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-wsgi[test] + asgi,starlette,fastapi: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-asgi[test] - asyncpg: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-asyncpg + asyncpg: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-asyncpg[test] boto: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-botocore[test] boto: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-boto[test] @@ -276,27 +276,27 @@ commands_pre = starlette: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-starlette[test] - tornado: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-tornado + tornado: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-tornado[test] jinja2: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-jinja2[test] - logging: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-logging + logging: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-logging[test] - aiohttp-client: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-aiohttp-client + aiohttp-client: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-aiohttp-client[test] aiopg: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-dbapi pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-aiopg[test] - datadog: pip install flaky {toxinidir}/exporter/opentelemetry-exporter-datadog + datadog: pip install flaky {toxinidir}/exporter/opentelemetry-exporter-datadog[test] sklearn: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-sklearn[test] - sqlalchemy: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-sqlalchemy + sqlalchemy: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-sqlalchemy[test] elasticsearch{2,5,6,7}: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-elasticsearch[test] - aws: pip install requests {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws + aws: pip install requests {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws[test] - http: pip install {toxinidir}/util/opentelemetry-util-http + http: pip install {toxinidir}/util/opentelemetry-util-http[test] ; In order to get a health coverage report, propagator-ot-trace: pip install {toxinidir}/propagator/opentelemetry-propagator-ot-trace[test] @@ -395,7 +395,7 @@ deps = docker-compose >= 1.25.2 mysql-connector-python ~= 8.0 pymongo ~= 3.1 - pymysql ~= 0.9.3 + PyMySQL ~= 0.10.1 psycopg2-binary ~= 2.8.4 aiopg >= 0.13.0 sqlalchemy ~= 1.3.16