diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..cbdffe129b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +repos: + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 24.3.0 + hooks: + - id: black + language_version: python3.11 + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + - repo: https://github.com/pycqa/flake8 + rev: '6.1.0' + hooks: + - id: flake8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2375eaf1ee..38608d80a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#2418](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2418)) - Use sqlalchemy version in sqlalchemy commenter instead of opentelemetry library version ([#2404](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2404)) +- Remove SDK dependency from opentelemetry-instrumentation-grpc + ([#2474](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2474)) ## Version 1.24.0/0.45b0 (2024-03-28) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3c4bae0f47..3de25a4e67 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,6 +70,17 @@ An easier way to do so is: 1. Run `.tox/lint-some-package/bin/black .` 2. Run `.tox/lint-some-package/bin/isort .` +Or you can call formatting and linting in one command by [pre-commit](https://pre-commit.com/): + +```console +$ pre-commit +``` + +You can also configure it to run lint tools automatically before committing with: + +```console +$ pre-commit install + See [`tox.ini`](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/tox.ini) for more detail on available tox commands. diff --git a/dev-requirements.txt b/dev-requirements.txt index 1c49c57b7e..be65b731c7 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -17,3 +17,5 @@ codespell==2.1.0 requests==2.31.0 ruamel.yaml==0.17.21 flaky==3.7.0 +pre-commit==3.7.0; python_version >= '3.9' +pre-commit==3.5.0; python_version < '3.9' diff --git a/instrumentation/opentelemetry-instrumentation-grpc/pyproject.toml b/instrumentation/opentelemetry-instrumentation-grpc/pyproject.toml index 750f76270a..7deffb71e7 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-grpc/pyproject.toml @@ -26,7 +26,6 @@ classifiers = [ dependencies = [ "opentelemetry-api ~= 1.12", "opentelemetry-instrumentation == 0.46b0.dev", - "opentelemetry-sdk ~= 1.12", "opentelemetry-semantic-conventions == 0.46b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] diff --git a/opentelemetry-contrib-instrumentations/README.rst b/opentelemetry-contrib-instrumentations/README.rst index 4e581c0a63..e0a76806e1 100644 --- a/opentelemetry-contrib-instrumentations/README.rst +++ b/opentelemetry-contrib-instrumentations/README.rst @@ -15,7 +15,7 @@ Installation This package installs all instrumentation packages hosted by the OpenTelemetry Python Contrib repository. -The list of packages can be found (here)[https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation] +The list of packages can be found `here `_. References diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py index 9eebd5bb38..55d2f498a1 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py @@ -24,10 +24,6 @@ "library": "aiohttp ~= 3.0", "instrumentation": "opentelemetry-instrumentation-aiohttp-client==0.46b0.dev", }, - { - "library": "aiohttp ~= 3.0", - "instrumentation": "opentelemetry-instrumentation-aiohttp-server==0.46b0.dev", - }, { "library": "aiopg >= 0.13.0, < 2.0.0", "instrumentation": "opentelemetry-instrumentation-aiopg==0.46b0.dev", @@ -191,7 +187,6 @@ "opentelemetry-instrumentation-dbapi==0.46b0.dev", "opentelemetry-instrumentation-logging==0.46b0.dev", "opentelemetry-instrumentation-sqlite3==0.46b0.dev", - "opentelemetry-instrumentation-threading==0.46b0.dev", "opentelemetry-instrumentation-urllib==0.46b0.dev", "opentelemetry-instrumentation-wsgi==0.46b0.dev", ] diff --git a/scripts/otel_packaging.py b/scripts/otel_packaging.py index 2f42e44189..c6c11c45fa 100644 --- a/scripts/otel_packaging.py +++ b/scripts/otel_packaging.py @@ -12,43 +12,55 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os -import subprocess -from subprocess import CalledProcessError +from tomli import load +from os import path, listdir +from subprocess import check_output, CalledProcessError +from requests import get -import tomli - -scripts_path = os.path.dirname(os.path.abspath(__file__)) -root_path = os.path.dirname(scripts_path) -instrumentations_path = os.path.join(root_path, "instrumentation") +scripts_path = path.dirname(path.abspath(__file__)) +root_path = path.dirname(scripts_path) +instrumentations_path = path.join(root_path, "instrumentation") def get_instrumentation_packages(): - for pkg in sorted(os.listdir(instrumentations_path)): - pkg_path = os.path.join(instrumentations_path, pkg) - if not os.path.isdir(pkg_path): + for pkg in sorted(listdir(instrumentations_path)): + pkg_path = path.join(instrumentations_path, pkg) + if not path.isdir(pkg_path): continue + error = f"Could not get version for package {pkg}" + try: - version = subprocess.check_output( + hatch_version = check_output( "hatch version", shell=True, cwd=pkg_path, - universal_newlines=True, + universal_newlines=True ) + except CalledProcessError as exc: print(f"Could not get hatch version from path {pkg_path}") print(exc.output) - raise exc - pyproject_toml_path = os.path.join(pkg_path, "pyproject.toml") + try: + response = get(f"https://pypi.org/pypi/{pkg}/json", timeout=10) + + except Exception: + print(error) + continue + + if response.status_code != 200: + print(error) + continue + + pyproject_toml_path = path.join(pkg_path, "pyproject.toml") with open(pyproject_toml_path, "rb") as file: - pyproject_toml = tomli.load(file) + pyproject_toml = load(file) instrumentation = { "name": pyproject_toml["project"]["name"], - "version": version.strip(), + "version": hatch_version.strip(), "instruments": pyproject_toml["project"]["optional-dependencies"][ "instruments" ],