diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8decdb1a42..64c39745f2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ on: - 'release/*' pull_request: env: - CORE_REPO_SHA: 0ef76a5cc39626f783416ca75e43556e2bb2739d + CORE_REPO_SHA: 9831afaff5b4d371fd9a14266ab47884546bd971 jobs: build: @@ -44,7 +44,7 @@ jobs: ~/.cache/pip key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }} - name: run tox - run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json + run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json # - name: Find and merge ${{ matrix.package }} benchmarks # # TODO: Add at least one benchmark to every package type to remove this (#249) # if: matrix.package == 'sdkextension' || matrix.package == 'propagator' diff --git a/.pylintrc b/.pylintrc index 30d60bc2d3..5ea4385ea0 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,7 +3,7 @@ # A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python interpreter and may # run arbitrary code. -extension-pkg-whitelist= +extension-pkg-whitelist=cassandra # Add list of files or directories to be excluded. They should be base names, not # paths. @@ -29,7 +29,7 @@ limit-inference-results=100 # List of plugins (as comma separated values of python modules names) to load, # usually to register additional checkers. -load-plugins= +load-plugins=pylint.extensions.no_self_use # Pickle collected data for later comparisons. persistent=yes @@ -69,7 +69,6 @@ disable=missing-docstring, duplicate-code, ungrouped-imports, # Leave this up to isort wrong-import-order, # Leave this up to isort - bad-continuation, # Leave this up to black line-too-long, # Leave this up to black exec-used, super-with-arguments, # temp-pylint-upgrade @@ -81,6 +80,7 @@ disable=missing-docstring, invalid-overridden-method, # temp-pylint-upgrade missing-module-docstring, # temp-pylint-upgrade import-error, # needed as a workaround as reported here: https://github.com/open-telemetry/opentelemetry-python-contrib/issues/290 + cyclic-import, # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -268,13 +268,6 @@ max-line-length=79 # Maximum number of lines in a module. max-module-lines=1000 -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma, - dict-separator - # Allow the body of a class to be on the same line as the declaration if body # contains single statement. single-line-class-stmt=no diff --git a/CHANGELOG.md b/CHANGELOG.md index 2923ebc791..fa52f4cde4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- `opentelemetry-instrumentation` Added Otel semantic convention opt-in mechanism + ([#1987](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1987)) +- `opentelemetry-instrumentation-httpx` Fix mixing async and non async hooks + ([#1920](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1920)) + +### Fixed + +- `opentelemetry-instrumentation-urllib`/`opentelemetry-instrumentation-urllib3` Fix metric descriptions to match semantic conventions + ([#1959]((https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1959)) + +## Version 1.21.0/0.42b0 (2023-11-01) ### Added + +- `opentelemetry-instrumentation-aiohttp-server` Add instrumentor and auto instrumentation support for aiohttp-server + ([#1800](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1800)) +- `opentelemetry-instrumentation-botocore` Include SNS topic ARN as a span attribute with name `messaging.destination.name` to uniquely identify the SNS topic + ([#1995](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1995)) - `opentelemetry-instrumentation-system-metrics` Add support for collecting process metrics ([#1948](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1948)) +- Added schema_url (`"https://opentelemetry.io/schemas/1.11.0"`) to all metrics and traces + ([#1977](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1977)) ### Fixed @@ -18,7 +38,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1980](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1980)) - `opentelemetry-resource-detector-azure` Using new Cloud Resource ID attribute. ([#1976](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1976)) - +- Do not collect `system.network.connections` by default on macOS which was causing exceptions in metrics collection. + ([#2008](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2008)) ## Version 1.20.0/0.41b0 (2023-09-01) @@ -49,6 +70,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1824](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1824)) - Fix sqlalchemy instrumentation wrap methods to accept sqlcommenter options ([#1873](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1873)) +- Exclude background task execution from root server span in ASGI middleware + ([#1952](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1952)) ### Added @@ -58,7 +81,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1744](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1744)) - Fix async redis clients not being traced correctly ([#1830](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1830)) -- Make Flask request span attributes available for `start_span`. +- Make Flask request span attributes available for `start_span`. ([#1784](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1784)) - Fix falcon instrumentation's usage of Span Status to only set the description if the status code is ERROR. ([#1840](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1840)) @@ -1380,6 +1403,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `opentelemetry-ext-wsgi` Updates for core library changes - `opentelemetry-ext-http-requests` Updates for core library changes +- `Added support for PyPy3` Initial release +## [#1033](https://github.com/open-telemetryopentelemetry-python-contrib/issues/1033) + ## Version 0.1a0 (2019-09-30) ### Added diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41f2aa08cb..b79d25492a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,9 +52,13 @@ An easier way to do so is: 2. Run `.tox/lint/bin/isort .` See -[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python/blob/main/tox.ini) +[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/tox.ini) for more detail on available tox commands. +### Troubleshooting + +- Some packages may require additional system wide dependencies to be installed. For example, you may need to install `libpq-dev` to run the postgresql client libraries instrumentation tests. or `libsnappy-dev` to run the prometheus exporter tests. If you encounter a build error, please check the installation instructions for the package you are trying to run tests for. + ### Benchmarks Performance progression of benchmarks for packages distributed by OpenTelemetry Python can be viewed as a [graph of throughput vs commit history](https://opentelemetry-python-contrib.readthedocs.io/en/latest/performance/benchmarks.html). From the linked page, you can download a JSON file with the performance results. diff --git a/_template/version.py b/_template/version.py index c2996671d6..2e4aa8c751 100644 --- a/_template/version.py +++ b/_template/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/dev-requirements.txt b/dev-requirements.txt index feab6b4b02..fffb4c445d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,20 +1,19 @@ -pylint==2.12.2 -flake8~=3.7 -isort~=5.6 -black>=22.1.0 -httpretty~=1.0 -mypy==0.790 -sphinx -sphinx-rtd-theme~=0.4 -sphinx-autodoc-typehints -pytest!=5.2.3 -pytest-cov>=2.8 -readme-renderer~=24.0 +pylint==3.0.2 +flake8==6.1.0 +isort==5.12.0 +black==22.3.0 +httpretty==1.1.4 +mypy==0.931 +sphinx==7.1.2 +sphinx-rtd-theme==2.0.0rc4 +sphinx-autodoc-typehints==1.25.2 +pytest==7.1.3 +pytest-cov==4.1.0 +readme-renderer==42.0 bleach==4.1.0 # transient dependency for readme-renderer -grpcio-tools==1.29.0 -mypy-protobuf>=1.23 protobuf~=3.13 markupsafe>=2.0.1 codespell==2.1.0 requests==2.31.0 ruamel.yaml==0.17.21 +flaky==3.7.0 diff --git a/docs-requirements.txt b/docs-requirements.txt index 32f4a406aa..965ea850c2 100644 --- a/docs-requirements.txt +++ b/docs-requirements.txt @@ -1,6 +1,6 @@ -sphinx==4.5.0 -sphinx-rtd-theme~=0.4 -sphinx-autodoc-typehints +sphinx==7.1.2 +sphinx-rtd-theme==2.0.0rc4 +sphinx-autodoc-typehints==1.25.2 # Need to install the api/sdk in the venv for autodoc. Modifying sys.path # doesn't work for pkg_resources. @@ -45,11 +45,8 @@ remoulade>=0.50 sqlalchemy>=1.0 tornado>=5.1.1 tortoise-orm>=0.17.0 -ddtrace>=0.34.0 httpx>=0.18.0 # indirect dependency pins markupsafe==2.0.1 itsdangerous==2.0.1 - -docutils==0.16 \ No newline at end of file diff --git a/eachdist.ini b/eachdist.ini index dacd4fc42f..2884f8608d 100644 --- a/eachdist.ini +++ b/eachdist.ini @@ -16,7 +16,7 @@ sortfirst= ext/* [stable] -version=1.21.0.dev +version=1.22.0.dev packages= opentelemetry-sdk @@ -34,7 +34,7 @@ packages= opentelemetry-api [prerelease] -version=0.42b0.dev +version=0.43b0.dev packages= all @@ -54,6 +54,7 @@ packages= [lintroots] extraroots=examples/*,scripts/ subglob=*.py,tests/,test/,src/*,examples/* +ignore=sklearn [testroots] extraroots=examples/*,tests/ diff --git a/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/version.py b/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/version.py index c2996671d6..2e4aa8c751 100644 --- a/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/version.py +++ b/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/exporter/opentelemetry-exporter-prometheus-remote-write/tests/conftest.py b/exporter/opentelemetry-exporter-prometheus-remote-write/tests/conftest.py index 259de7b7a2..78e9c49bee 100644 --- a/exporter/opentelemetry-exporter-prometheus-remote-write/tests/conftest.py +++ b/exporter/opentelemetry-exporter-prometheus-remote-write/tests/conftest.py @@ -3,6 +3,8 @@ import pytest import opentelemetry.test.metrictestutil as metric_util + +# pylint: disable=no-name-in-module from opentelemetry.exporter.prometheus_remote_write import ( PrometheusRemoteWriteMetricsExporter, ) diff --git a/exporter/opentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py b/exporter/opentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py index d64a8f04a8..785c6bdc29 100644 --- a/exporter/opentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py +++ b/exporter/opentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py @@ -17,6 +17,7 @@ import pytest +# pylint: disable=no-name-in-module from opentelemetry.exporter.prometheus_remote_write import ( PrometheusRemoteWriteMetricsExporter, ) diff --git a/exporter/opentelemetry-exporter-richconsole/pyproject.toml b/exporter/opentelemetry-exporter-richconsole/pyproject.toml index 202dda7a51..b2e7c7fc28 100644 --- a/exporter/opentelemetry-exporter-richconsole/pyproject.toml +++ b/exporter/opentelemetry-exporter-richconsole/pyproject.toml @@ -27,7 +27,7 @@ classifiers = [ dependencies = [ "opentelemetry-api ~= 1.12", "opentelemetry-sdk ~= 1.12", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", "rich>=10.0.0", ] diff --git a/exporter/opentelemetry-exporter-richconsole/src/opentelemetry/exporter/richconsole/version.py b/exporter/opentelemetry-exporter-richconsole/src/opentelemetry/exporter/richconsole/version.py index c2996671d6..2e4aa8c751 100644 --- a/exporter/opentelemetry-exporter-richconsole/src/opentelemetry/exporter/richconsole/version.py +++ b/exporter/opentelemetry-exporter-richconsole/src/opentelemetry/exporter/richconsole/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/README.md b/instrumentation/README.md index 12b8ada105..cc5ea02def 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -3,6 +3,7 @@ | --------------- | ------------------ | --------------- | | [opentelemetry-instrumentation-aio-pika](./opentelemetry-instrumentation-aio-pika) | aio_pika >= 7.2.0, < 10.0.0 | No | [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 | No +| [opentelemetry-instrumentation-aiohttp-server](./opentelemetry-instrumentation-aiohttp-server) | aiohttp ~= 3.0 | No | [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 2.0.0 | No | [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 | No | [opentelemetry-instrumentation-asyncpg](./opentelemetry-instrumentation-asyncpg) | asyncpg >= 0.12.0 | No diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/pyproject.toml b/instrumentation/opentelemetry-instrumentation-aio-pika/pyproject.toml index af57ebe6e7..ee87d4303b 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/pyproject.toml @@ -35,7 +35,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-aio-pika[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", "pytest", "wrapt >= 1.0.0, < 2.0.0", ] diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/aio_pika_instrumentor.py b/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/aio_pika_instrumentor.py index 99420d0892..caf0e5b1a9 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/aio_pika_instrumentor.py +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/aio_pika_instrumentor.py @@ -64,7 +64,10 @@ async def wrapper(wrapped, instance, args, kwargs): def _instrument(self, **kwargs): tracer_provider = kwargs.get("tracer_provider", None) tracer = trace.get_tracer( - _INSTRUMENTATION_MODULE_NAME, __version__, tracer_provider + _INSTRUMENTATION_MODULE_NAME, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) self._instrument_queue(tracer) self._instrument_exchange(tracer) diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/version.py b/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/version.py +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/pyproject.toml b/instrumentation/opentelemetry-instrumentation-aiohttp-client/pyproject.toml index c466977377..d35b3326fa 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/pyproject.toml @@ -26,9 +26,9 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] 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 65e1601f34..ef3b667c98 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 @@ -163,7 +163,12 @@ def create_trace_config( # Explicitly specify the type for the `request_hook` and `response_hook` param and rtype to work # around this issue. - tracer = get_tracer(__name__, __version__, tracer_provider) + tracer = get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) def _end_trace(trace_config_ctx: types.SimpleNamespace): context_api.detach(trace_config_ctx.token) 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/version.py index e9ca2a1777..0d568a8987 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/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py index 6af9d41900..50330b05be 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py @@ -14,6 +14,7 @@ import asyncio import contextlib +import sys import typing import unittest import urllib.parse @@ -116,6 +117,11 @@ def test_status_codes(self): status_code=status_code, ) + url = f"http://{host}:{port}/test-path?query=param#foobar" + # if python version is < 3.8, then the url will be + if sys.version_info[1] < 8: + url = f"http://{host}:{port}/test-path#foobar" + self.assert_spans( [ ( @@ -123,7 +129,7 @@ def test_status_codes(self): (span_status, None), { SpanAttributes.HTTP_METHOD: "GET", - SpanAttributes.HTTP_URL: f"http://{host}:{port}/test-path#foobar", + SpanAttributes.HTTP_URL: url, SpanAttributes.HTTP_STATUS_CODE: int( status_code ), @@ -134,6 +140,21 @@ def test_status_codes(self): self.memory_exporter.clear() + def test_schema_url(self): + with self.subTest(status_code=200): + self._http_request( + trace_config=aiohttp_client.create_trace_config(), + url="/test-path?query=param#foobar", + status_code=200, + ) + + span = self.memory_exporter.get_finished_spans()[0] + self.assertEqual( + span.instrumentation_info.schema_url, + "https://opentelemetry.io/schemas/1.11.0", + ) + self.memory_exporter.clear() + def test_not_recording(self): mock_tracer = mock.Mock() mock_span = mock.Mock() @@ -141,7 +162,7 @@ def test_not_recording(self): mock_tracer.start_span.return_value = mock_span with mock.patch("opentelemetry.trace.get_tracer"): # pylint: disable=W0612 - host, port = self._http_request( + self._http_request( trace_config=aiohttp_client.create_trace_config(), url="/test-path?query=param#foobar", ) diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-server/README.rst b/instrumentation/opentelemetry-instrumentation-aiohttp-server/README.rst new file mode 100644 index 0000000000..b8606ad687 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-server/README.rst @@ -0,0 +1,24 @@ +OpenTelemetry aiohttp server Integration +======================================== + +|pypi| + +.. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentation-aiohttp-client.svg + :target: https://pypi.org/project/opentelemetry-instrumentation-aiohttp-client/ + +This library allows tracing HTTP requests made by the +`aiohttp server `_ library. + +Installation +------------ + +:: + + pip install opentelemetry-instrumentation-aiohttp-server + +References +---------- + +* `OpenTelemetry Project `_ +* `aiohttp client Tracing `_ +* `OpenTelemetry Python Examples `_ diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-server/pyproject.toml b/instrumentation/opentelemetry-instrumentation-aiohttp-server/pyproject.toml new file mode 100644 index 0000000000..bc3372bfc6 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-server/pyproject.toml @@ -0,0 +1,61 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "opentelemetry-instrumentation-aiohttp-server" +dynamic = ["version"] +description = "Aiohttp server instrumentation for OpenTelemetry" +readme = "README.rst" +license = "Apache-2.0" +requires-python = ">=3.7" +authors = [ + { name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io"} +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11" +] +dependencies = [ + "opentelemetry-api ~= 1.12", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", + "wrapt >= 1.0.0, < 2.0.0", +] + +[project.optional-dependencies] +instruments = [ + "aiohttp ~= 3.0", +] +test = [ + "opentelemetry-instrumentation-aiohttp-server[instruments]", + "pytest-asyncio", + "pytest-aiohttp", +] + +[project.entry-points.opentelemetry_instrumentor] +aiohttp-server = "opentelemetry.instrumentation.aiohttp_server:AioHttpServerInstrumentor" + +[project.urls] +Homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-aiohttp-server" + +[tool.hatch.version] +path = "src/opentelemetry/instrumentation/aiohttp_server/version.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/src", + "/tests", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/opentelemetry"] diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py b/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py new file mode 100644 index 0000000000..914f005b2a --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py @@ -0,0 +1,267 @@ +# Copyright 2020, OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import urllib +from timeit import default_timer +from typing import Dict, List, Tuple, Union + +from aiohttp import web +from multidict import CIMultiDictProxy + +from opentelemetry import context, metrics, trace +from opentelemetry.context import _SUPPRESS_HTTP_INSTRUMENTATION_KEY +from opentelemetry.instrumentation.aiohttp_server.package import _instruments +from opentelemetry.instrumentation.aiohttp_server.version import __version__ +from opentelemetry.instrumentation.instrumentor import BaseInstrumentor +from opentelemetry.instrumentation.utils import http_status_to_status_code +from opentelemetry.propagate import extract +from opentelemetry.propagators.textmap import Getter +from opentelemetry.semconv.metrics import MetricInstruments +from opentelemetry.semconv.trace import SpanAttributes +from opentelemetry.trace.status import Status, StatusCode +from opentelemetry.util.http import get_excluded_urls, remove_url_credentials + +_duration_attrs = [ + SpanAttributes.HTTP_METHOD, + SpanAttributes.HTTP_HOST, + SpanAttributes.HTTP_SCHEME, + SpanAttributes.HTTP_STATUS_CODE, + SpanAttributes.HTTP_FLAVOR, + SpanAttributes.HTTP_SERVER_NAME, + SpanAttributes.NET_HOST_NAME, + SpanAttributes.NET_HOST_PORT, + SpanAttributes.HTTP_ROUTE, +] + +_active_requests_count_attrs = [ + SpanAttributes.HTTP_METHOD, + SpanAttributes.HTTP_HOST, + SpanAttributes.HTTP_SCHEME, + SpanAttributes.HTTP_FLAVOR, + SpanAttributes.HTTP_SERVER_NAME, +] + +tracer = trace.get_tracer(__name__) +meter = metrics.get_meter(__name__, __version__) +_excluded_urls = get_excluded_urls("AIOHTTP_SERVER") + + +def _parse_duration_attrs(req_attrs): + duration_attrs = {} + for attr_key in _duration_attrs: + if req_attrs.get(attr_key) is not None: + duration_attrs[attr_key] = req_attrs[attr_key] + return duration_attrs + + +def _parse_active_request_count_attrs(req_attrs): + active_requests_count_attrs = {} + for attr_key in _active_requests_count_attrs: + if req_attrs.get(attr_key) is not None: + active_requests_count_attrs[attr_key] = req_attrs[attr_key] + return active_requests_count_attrs + + +def get_default_span_details(request: web.Request) -> Tuple[str, dict]: + """Default implementation for get_default_span_details + Args: + request: the request object itself. + Returns: + a tuple of the span name, and any attributes to attach to the span. + """ + span_name = request.path.strip() or f"HTTP {request.method}" + return span_name, {} + + +def _get_view_func(request: web.Request) -> str: + """Returns the name of the request handler. + Args: + request: the request object itself. + Returns: + a string containing the name of the handler function + """ + try: + return request.match_info.handler.__name__ + except AttributeError: + return "unknown" + + +def collect_request_attributes(request: web.Request) -> Dict: + """Collects HTTP request attributes from the ASGI scope and returns a + dictionary to be used as span creation attributes.""" + + server_host, port, http_url = ( + request.url.host, + request.url.port, + str(request.url), + ) + query_string = request.query_string + if query_string and http_url: + if isinstance(query_string, bytes): + query_string = query_string.decode("utf8") + http_url += "?" + urllib.parse.unquote(query_string) + + result = { + SpanAttributes.HTTP_SCHEME: request.scheme, + SpanAttributes.HTTP_HOST: server_host, + SpanAttributes.NET_HOST_PORT: port, + SpanAttributes.HTTP_ROUTE: _get_view_func(request), + SpanAttributes.HTTP_FLAVOR: f"{request.version.major}.{request.version.minor}", + SpanAttributes.HTTP_TARGET: request.path, + SpanAttributes.HTTP_URL: remove_url_credentials(http_url), + } + + http_method = request.method + if http_method: + result[SpanAttributes.HTTP_METHOD] = http_method + + http_host_value_list = ( + [request.host] if not isinstance(request.host, list) else request.host + ) + if http_host_value_list: + result[SpanAttributes.HTTP_SERVER_NAME] = ",".join( + http_host_value_list + ) + http_user_agent = request.headers.get("user-agent") + if http_user_agent: + result[SpanAttributes.HTTP_USER_AGENT] = http_user_agent + + # remove None values + result = {k: v for k, v in result.items() if v is not None} + + return result + + +def set_status_code(span, status_code: int) -> None: + """Adds HTTP response attributes to span using the status_code argument.""" + + try: + status_code = int(status_code) + except ValueError: + span.set_status( + Status( + StatusCode.ERROR, + "Non-integer HTTP status: " + repr(status_code), + ) + ) + else: + span.set_attribute(SpanAttributes.HTTP_STATUS_CODE, status_code) + span.set_status( + Status(http_status_to_status_code(status_code, server_span=True)) + ) + + +class AiohttpGetter(Getter): + """Extract current trace from headers""" + + def get(self, carrier, key: str) -> Union[List, None]: + """Getter implementation to retrieve an HTTP header value from the ASGI + scope. + + Args: + carrier: ASGI scope object + key: header name in scope + Returns: + A list of all header values matching the key, or None if the key + does not match any header. + """ + headers: CIMultiDictProxy = carrier.headers + if not headers: + return None + return headers.getall(key, None) + + def keys(self, carrier: Dict) -> List: + return list(carrier.keys()) + + +getter = AiohttpGetter() + + +@web.middleware +async def middleware(request, handler): + """Middleware for aiohttp implementing tracing logic""" + if ( + context.get_value("suppress_instrumentation") + or context.get_value(_SUPPRESS_HTTP_INSTRUMENTATION_KEY) + or _excluded_urls.url_disabled(request.url.path) + ): + return await handler(request) + + span_name, additional_attributes = get_default_span_details(request) + + req_attrs = collect_request_attributes(request) + duration_attrs = _parse_duration_attrs(req_attrs) + active_requests_count_attrs = _parse_active_request_count_attrs(req_attrs) + + duration_histogram = meter.create_histogram( + name=MetricInstruments.HTTP_SERVER_DURATION, + unit="ms", + description="measures the duration of the inbound HTTP request", + ) + + active_requests_counter = meter.create_up_down_counter( + name=MetricInstruments.HTTP_SERVER_ACTIVE_REQUESTS, + unit="requests", + description="measures the number of concurrent HTTP requests those are currently in flight", + ) + + with tracer.start_as_current_span( + span_name, + context=extract(request, getter=getter), + kind=trace.SpanKind.SERVER, + ) as span: + attributes = collect_request_attributes(request) + attributes.update(additional_attributes) + span.set_attributes(attributes) + start = default_timer() + active_requests_counter.add(1, active_requests_count_attrs) + try: + resp = await handler(request) + set_status_code(span, resp.status) + except web.HTTPException as ex: + set_status_code(span, ex.status_code) + raise + finally: + duration = max((default_timer() - start) * 1000, 0) + duration_histogram.record(duration, duration_attrs) + active_requests_counter.add(-1, active_requests_count_attrs) + return resp + + +class _InstrumentedApplication(web.Application): + """Insert tracing middleware""" + + def __init__(self, *args, **kwargs): + middlewares = kwargs.pop("middlewares", []) + middlewares.insert(0, middleware) + kwargs["middlewares"] = middlewares + super().__init__(*args, **kwargs) + + +class AioHttpServerInstrumentor(BaseInstrumentor): + # pylint: disable=protected-access,attribute-defined-outside-init + """An instrumentor for aiohttp.web.Application + + See `BaseInstrumentor` + """ + + def _instrument(self, **kwargs): + self._original_app = web.Application + setattr(web, "Application", _InstrumentedApplication) + + def _uninstrument(self, **kwargs): + setattr(web, "Application", self._original_app) + + def instrumentation_dependencies(self): + return _instruments diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/package.py b/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/package.py new file mode 100644 index 0000000000..557f1a54a9 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/package.py @@ -0,0 +1,16 @@ +# 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. + + +_instruments = ("aiohttp ~= 3.0",) diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/version.py b/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/version.py new file mode 100644 index 0000000000..2e4aa8c751 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/version.py @@ -0,0 +1,15 @@ +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-server/tests/__init__.py b/instrumentation/opentelemetry-instrumentation-aiohttp-server/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-server/tests/test_aiohttp_server_integration.py b/instrumentation/opentelemetry-instrumentation-aiohttp-server/tests/test_aiohttp_server_integration.py new file mode 100644 index 0000000000..b5e8ec468f --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-server/tests/test_aiohttp_server_integration.py @@ -0,0 +1,130 @@ +# Copyright 2020, 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. + +from enum import Enum +from http import HTTPStatus + +import aiohttp +import pytest +import pytest_asyncio + +from opentelemetry import trace as trace_api +from opentelemetry.instrumentation.aiohttp_server import ( + AioHttpServerInstrumentor, +) +from opentelemetry.semconv.trace import SpanAttributes +from opentelemetry.test.globals_test import reset_trace_globals +from opentelemetry.test.test_base import TestBase +from opentelemetry.util._importlib_metadata import entry_points + + +class HTTPMethod(Enum): + """HTTP methods and descriptions""" + + def __repr__(self): + return f"{self.value}" + + CONNECT = "CONNECT" + DELETE = "DELETE" + GET = "GET" + HEAD = "HEAD" + OPTIONS = "OPTIONS" + PATCH = "PATCH" + POST = "POST" + PUT = "PUT" + TRACE = "TRACE" + + +@pytest.fixture(name="tracer", scope="session") +def fixture_tracer(): + test_base = TestBase() + + tracer_provider, memory_exporter = test_base.create_tracer_provider() + + reset_trace_globals() + trace_api.set_tracer_provider(tracer_provider) + + yield tracer_provider, memory_exporter + + reset_trace_globals() + + +async def default_handler(request, status=200): + return aiohttp.web.Response(status=status) + + +@pytest_asyncio.fixture(name="server_fixture") +async def fixture_server_fixture(tracer, aiohttp_server): + _, memory_exporter = tracer + + AioHttpServerInstrumentor().instrument() + + app = aiohttp.web.Application() + app.add_routes([aiohttp.web.get("/test-path", default_handler)]) + + server = await aiohttp_server(app) + yield server, app + + memory_exporter.clear() + + AioHttpServerInstrumentor().uninstrument() + + +def test_checking_instrumentor_pkg_installed(): + + (instrumentor_entrypoint,) = entry_points( + group="opentelemetry_instrumentor", name="aiohttp-server" + ) + instrumentor = instrumentor_entrypoint.load()() + assert isinstance(instrumentor, AioHttpServerInstrumentor) + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + "url, expected_method, expected_status_code", + [ + ("/test-path", HTTPMethod.GET, HTTPStatus.OK), + ("/not-found", HTTPMethod.GET, HTTPStatus.NOT_FOUND), + ], +) +async def test_status_code_instrumentation( + tracer, + server_fixture, + aiohttp_client, + url, + expected_method, + expected_status_code, +): + _, memory_exporter = tracer + server, _ = server_fixture + + assert len(memory_exporter.get_finished_spans()) == 0 + + client = await aiohttp_client(server) + await client.get(url) + + assert len(memory_exporter.get_finished_spans()) == 1 + + [span] = memory_exporter.get_finished_spans() + + assert expected_method.value == span.attributes[SpanAttributes.HTTP_METHOD] + assert ( + expected_status_code + == span.attributes[SpanAttributes.HTTP_STATUS_CODE] + ) + + assert ( + f"http://{server.host}:{server.port}{url}" + == span.attributes[SpanAttributes.HTTP_URL] + ) diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/pyproject.toml b/instrumentation/opentelemetry-instrumentation-aiopg/pyproject.toml index 024f707d89..cddbf583ca 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-aiopg/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-dbapi == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-dbapi == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] @@ -37,8 +37,8 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-aiopg[instruments]", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py index 6cc87f4900..a4bde482db 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py @@ -215,6 +215,7 @@ async def __aexit__(self, exc_type, exc, tb): class _PoolAcquireContextManager(_ContextManager): + # pylint: disable=redefined-slots-in-subclass __slots__ = ("_coro", "_obj", "_pool") def __init__(self, coro, pool): diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/version.py b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/version.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-asgi/pyproject.toml b/instrumentation/opentelemetry-instrumentation-asgi/pyproject.toml index 60f15e9ba7..2813274ace 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-asgi/pyproject.toml @@ -27,9 +27,9 @@ classifiers = [ dependencies = [ "asgiref ~= 3.0", "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", ] [project.optional-dependencies] @@ -38,7 +38,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-asgi[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.urls] 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 c0dcd39fd2..6ae6ce1790 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -495,9 +495,19 @@ def __init__( meter=None, ): self.app = guarantee_single_callable(app) - self.tracer = trace.get_tracer(__name__, __version__, tracer_provider) + self.tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) self.meter = ( - get_meter(__name__, __version__, meter_provider) + get_meter( + __name__, + __version__, + meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) if meter is None else meter ) @@ -566,7 +576,7 @@ async def __call__(self, scope, receive, send): if scope["type"] == "http": self.active_requests_counter.add(1, active_requests_count_attrs) try: - with trace.use_span(span, end_on_exit=True) as current_span: + with trace.use_span(span, end_on_exit=False) as current_span: if current_span.is_recording(): for key, value in attributes.items(): current_span.set_attribute(key, value) @@ -620,6 +630,8 @@ async def __call__(self, scope, receive, send): ) if token: context.detach(token) + if span.is_recording(): + span.end() # pylint: enable=too-many-branches @@ -643,8 +655,11 @@ async def otel_receive(): def _get_otel_send( self, server_span, server_span_name, scope, send, duration_attrs ): + expecting_trailers = False + @wraps(send) async def otel_send(message): + nonlocal expecting_trailers with self.tracer.start_as_current_span( " ".join((server_span_name, scope["type"], "send")) ) as send_span: @@ -658,6 +673,8 @@ async def otel_send(message): ] = status_code set_status_code(server_span, status_code) set_status_code(send_span, status_code) + + expecting_trailers = message.get("trailers", False) elif message["type"] == "websocket.send": set_status_code(server_span, 200) set_status_code(send_span, 200) @@ -693,5 +710,16 @@ async def otel_send(message): pass await send(message) + # pylint: disable=too-many-boolean-expressions + if ( + not expecting_trailers + and message["type"] == "http.response.body" + and not message.get("more_body", False) + ) or ( + expecting_trailers + and message["type"] == "http.response.trailers" + and not message.get("more_trailers", False) + ): + server_span.end() return otel_send diff --git a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/version.py b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/version.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py index cb22174482..4819f80630 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py @@ -16,6 +16,7 @@ import asyncio import sys +import time import unittest from timeit import default_timer from unittest import mock @@ -57,6 +58,8 @@ "http.server.request.size": _duration_attrs, } +_SIMULATED_BACKGROUND_TASK_EXECUTION_TIME_S = 0.01 + async def http_app(scope, receive, send): message = await receive() @@ -99,6 +102,108 @@ async def simple_asgi(scope, receive, send): await websocket_app(scope, receive, send) +async def long_response_asgi(scope, receive, send): + assert isinstance(scope, dict) + assert scope["type"] == "http" + message = await receive() + scope["headers"] = [(b"content-length", b"128")] + assert scope["type"] == "http" + if message.get("type") == "http.request": + await send( + { + "type": "http.response.start", + "status": 200, + "headers": [ + [b"Content-Type", b"text/plain"], + [b"content-length", b"1024"], + ], + } + ) + await send( + {"type": "http.response.body", "body": b"*", "more_body": True} + ) + await send( + {"type": "http.response.body", "body": b"*", "more_body": True} + ) + await send( + {"type": "http.response.body", "body": b"*", "more_body": True} + ) + await send( + {"type": "http.response.body", "body": b"*", "more_body": False} + ) + + +async def background_execution_asgi(scope, receive, send): + assert isinstance(scope, dict) + assert scope["type"] == "http" + message = await receive() + scope["headers"] = [(b"content-length", b"128")] + assert scope["type"] == "http" + if message.get("type") == "http.request": + await send( + { + "type": "http.response.start", + "status": 200, + "headers": [ + [b"Content-Type", b"text/plain"], + [b"content-length", b"1024"], + ], + } + ) + await send( + { + "type": "http.response.body", + "body": b"*", + } + ) + time.sleep(_SIMULATED_BACKGROUND_TASK_EXECUTION_TIME_S) + + +async def background_execution_trailers_asgi(scope, receive, send): + assert isinstance(scope, dict) + assert scope["type"] == "http" + message = await receive() + scope["headers"] = [(b"content-length", b"128")] + assert scope["type"] == "http" + if message.get("type") == "http.request": + await send( + { + "type": "http.response.start", + "status": 200, + "headers": [ + [b"Content-Type", b"text/plain"], + [b"content-length", b"1024"], + ], + "trailers": True, + } + ) + await send( + {"type": "http.response.body", "body": b"*", "more_body": True} + ) + await send( + {"type": "http.response.body", "body": b"*", "more_body": False} + ) + await send( + { + "type": "http.response.trailers", + "headers": [ + [b"trailer", b"test-trailer"], + ], + "more_trailers": True, + } + ) + await send( + { + "type": "http.response.trailers", + "headers": [ + [b"trailer", b"second-test-trailer"], + ], + "more_trailers": False, + } + ) + time.sleep(_SIMULATED_BACKGROUND_TASK_EXECUTION_TIME_S) + + async def error_asgi(scope, receive, send): assert isinstance(scope, dict) assert scope["type"] == "http" @@ -122,19 +227,25 @@ async def error_asgi(scope, receive, send): await send({"type": "http.response.body", "body": b"*"}) +# pylint: disable=too-many-public-methods class TestAsgiApplication(AsgiTestBase): def validate_outputs(self, outputs, error=None, modifiers=None): # Ensure modifiers is a list modifiers = modifiers or [] # Check for expected outputs - self.assertEqual(len(outputs), 2) response_start = outputs[0] - response_body = outputs[1] + response_final_body = [ + output + for output in outputs + if output["type"] == "http.response.body" + ][-1] + self.assertEqual(response_start["type"], "http.response.start") - self.assertEqual(response_body["type"], "http.response.body") + self.assertEqual(response_final_body["type"], "http.response.body") + self.assertEqual(response_final_body.get("more_body", False), False) # Check http response body - self.assertEqual(response_body["body"], b"*") + self.assertEqual(response_final_body["body"], b"*") # Check http response start self.assertEqual(response_start["status"], 200) @@ -153,7 +264,6 @@ def validate_outputs(self, outputs, error=None, modifiers=None): # Check spans span_list = self.memory_exporter.get_finished_spans() - self.assertEqual(len(span_list), 4) expected = [ { "name": "GET / http receive", @@ -194,6 +304,7 @@ def validate_outputs(self, outputs, error=None, modifiers=None): for modifier in modifiers: expected = modifier(expected) # Check that output matches + self.assertEqual(len(span_list), len(expected)) for span, expected in zip(span_list, expected): self.assertEqual(span.name, expected["name"]) self.assertEqual(span.kind, expected["kind"]) @@ -232,6 +343,80 @@ def test_asgi_exc_info(self): outputs = self.get_all_output() self.validate_outputs(outputs, error=ValueError) + def test_long_response(self): + """Test that the server span is ended on the final response body message. + + If the server span is ended early then this test will fail due + to discrepancies in the expected list of spans and the emitted list of spans. + """ + app = otel_asgi.OpenTelemetryMiddleware(long_response_asgi) + self.seed_app(app) + self.send_default_request() + outputs = self.get_all_output() + + def add_more_body_spans(expected: list): + more_body_span = { + "name": "GET / http send", + "kind": trace_api.SpanKind.INTERNAL, + "attributes": {"type": "http.response.body"}, + } + extra_spans = [more_body_span] * 3 + expected[2:2] = extra_spans + return expected + + self.validate_outputs(outputs, modifiers=[add_more_body_spans]) + + def test_background_execution(self): + """Test that the server span is ended BEFORE the background task is finished.""" + app = otel_asgi.OpenTelemetryMiddleware(background_execution_asgi) + self.seed_app(app) + self.send_default_request() + outputs = self.get_all_output() + self.validate_outputs(outputs) + span_list = self.memory_exporter.get_finished_spans() + server_span = span_list[-1] + assert server_span.kind == SpanKind.SERVER + span_duration_nanos = server_span.end_time - server_span.start_time + self.assertLessEqual( + span_duration_nanos, + _SIMULATED_BACKGROUND_TASK_EXECUTION_TIME_S * 10**9, + ) + + def test_trailers(self): + """Test that trailers are emitted as expected and that the server span is ended + BEFORE the background task is finished.""" + app = otel_asgi.OpenTelemetryMiddleware( + background_execution_trailers_asgi + ) + self.seed_app(app) + self.send_default_request() + outputs = self.get_all_output() + + def add_body_and_trailer_span(expected: list): + body_span = { + "name": "GET / http send", + "kind": trace_api.SpanKind.INTERNAL, + "attributes": {"type": "http.response.body"}, + } + trailer_span = { + "name": "GET / http send", + "kind": trace_api.SpanKind.INTERNAL, + "attributes": {"type": "http.response.trailers"}, + } + expected[2:2] = [body_span] + expected[4:4] = [trailer_span] * 2 + return expected + + self.validate_outputs(outputs, modifiers=[add_body_and_trailer_span]) + span_list = self.memory_exporter.get_finished_spans() + server_span = span_list[-1] + assert server_span.kind == SpanKind.SERVER + span_duration_nanos = server_span.end_time - server_span.start_time + self.assertLessEqual( + span_duration_nanos, + _SIMULATED_BACKGROUND_TASK_EXECUTION_TIME_S * 10**9, + ) + def test_override_span_name(self): """Test that default span_names can be overwritten by our callback function.""" span_name = "Dymaxion" @@ -656,10 +841,7 @@ def test_no_metric_for_websockets(self): self.send_input({"type": "websocket.receive", "text": "ping"}) self.send_input({"type": "websocket.disconnect"}) self.get_all_output() - metrics_list = self.memory_metrics_reader.get_metrics_data() - self.assertEqual( - len(metrics_list.resource_metrics[0].scope_metrics), 0 - ) + self.assertIsNone(self.memory_metrics_reader.get_metrics_data()) class TestAsgiAttributes(unittest.TestCase): diff --git a/instrumentation/opentelemetry-instrumentation-asyncpg/pyproject.toml b/instrumentation/opentelemetry-instrumentation-asyncpg/pyproject.toml index 41a7e3ef3c..17be9fd807 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncpg/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-asyncpg/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", ] [project.optional-dependencies] @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-asyncpg[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 4c9bc8c727..a8c0eab2ac 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py @@ -84,7 +84,7 @@ def _hydrate_span_from_args(connection, query, parameters) -> dict: span_attributes[SpanAttributes.NET_PEER_NAME] = addr span_attributes[ SpanAttributes.NET_TRANSPORT - ] = NetTransportValues.UNIX.value + ] = NetTransportValues.OTHER.value if query is not None: span_attributes[SpanAttributes.DB_STATEMENT] = query @@ -107,7 +107,12 @@ def instrumentation_dependencies(self) -> Collection[str]: def _instrument(self, **kwargs): tracer_provider = kwargs.get("tracer_provider") - self._tracer = trace.get_tracer(__name__, __version__, tracer_provider) + self._tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) for method in [ "Connection.execute", diff --git a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/version.py b/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/version.py +++ b/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/pyproject.toml b/instrumentation/opentelemetry-instrumentation-aws-lambda/pyproject.toml index b632297922..f1c17410f8 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/pyproject.toml @@ -22,15 +22,15 @@ classifiers = [ "Programming Language :: Python :: 3.8", ] dependencies = [ - "opentelemetry-instrumentation == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", "opentelemetry-propagator-aws-xray == 1.0.1", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", ] [project.optional-dependencies] instruments = [] test = [ - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.urls] diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py index 799becbdcc..391bc32f60 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py @@ -321,7 +321,12 @@ def _instrumented_lambda_handler_call( # noqa pylint: disable=too-many-branches except (IndexError, KeyError, TypeError): span_kind = SpanKind.SERVER - tracer = get_tracer(__name__, __version__, tracer_provider) + tracer = get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) with tracer.start_as_current_span( name=orig_handler_name, diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/version.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/version.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/__init__.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/mocks/__init__.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/mocks/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py index 1df7499d31..5e4aaf0312 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py @@ -17,10 +17,12 @@ from typing import Any, Callable, Dict from unittest import mock -from mocks.api_gateway_http_api_event import ( +from tests.mocks.api_gateway_http_api_event import ( MOCK_LAMBDA_API_GATEWAY_HTTP_API_EVENT, ) -from mocks.api_gateway_proxy_event import MOCK_LAMBDA_API_GATEWAY_PROXY_EVENT +from tests.mocks.api_gateway_proxy_event import ( + MOCK_LAMBDA_API_GATEWAY_PROXY_EVENT, +) from opentelemetry.environment_variables import OTEL_PROPAGATORS from opentelemetry.instrumentation.aws_lambda import ( @@ -103,7 +105,7 @@ def setUp(self): super().setUp() self.common_env_patch = mock.patch.dict( "os.environ", - {_HANDLER: "mocks.lambda_function.handler"}, + {_HANDLER: "tests.mocks.lambda_function.handler"}, ) self.common_env_patch.start() @@ -356,7 +358,7 @@ def test_lambda_handles_multiple_consumers(self): def test_api_gateway_proxy_event_sets_attributes(self): handler_patch = mock.patch.dict( "os.environ", - {_HANDLER: "mocks.lambda_function.rest_api_handler"}, + {_HANDLER: "tests.mocks.lambda_function.rest_api_handler"}, ) handler_patch.start() diff --git a/instrumentation/opentelemetry-instrumentation-boto/pyproject.toml b/instrumentation/opentelemetry-instrumentation-boto/pyproject.toml index 125f311045..559fdc5cac 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-boto/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", ] [project.optional-dependencies] @@ -38,7 +38,7 @@ test = [ "opentelemetry-instrumentation-boto[instruments]", "markupsafe==2.0.1", "moto~=2.0", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 84c4e54a86..c92ccc8106 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py @@ -91,7 +91,10 @@ def _instrument(self, **kwargs): # pylint: disable=attribute-defined-outside-init self._tracer = get_tracer( - __name__, __version__, kwargs.get("tracer_provider") + __name__, + __version__, + kwargs.get("tracer_provider"), + schema_url="https://opentelemetry.io/schemas/1.11.0", ) wrap_function_wrapper( diff --git a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/version.py b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/version.py +++ b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-boto3sqs/pyproject.toml b/instrumentation/opentelemetry-instrumentation-boto3sqs/pyproject.toml index 5a91c1d206..21628ef70c 100644 --- a/instrumentation/opentelemetry-instrumentation-boto3sqs/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-boto3sqs/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] @@ -37,7 +37,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-boto3sqs[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-boto3sqs/src/opentelemetry/instrumentation/boto3sqs/__init__.py b/instrumentation/opentelemetry-instrumentation-boto3sqs/src/opentelemetry/instrumentation/boto3sqs/__init__.py index c34be82189..137c570ac6 100644 --- a/instrumentation/opentelemetry-instrumentation-boto3sqs/src/opentelemetry/instrumentation/boto3sqs/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-boto3sqs/src/opentelemetry/instrumentation/boto3sqs/__init__.py @@ -422,7 +422,10 @@ def _instrument(self, **kwargs: Dict[str, Any]) -> None: "tracer_provider" ) self._tracer: Tracer = trace.get_tracer( - __name__, __version__, self._tracer_provider + __name__, + __version__, + self._tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) self._wrap_client_creation() diff --git a/instrumentation/opentelemetry-instrumentation-boto3sqs/src/opentelemetry/instrumentation/boto3sqs/version.py b/instrumentation/opentelemetry-instrumentation-boto3sqs/src/opentelemetry/instrumentation/boto3sqs/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-boto3sqs/src/opentelemetry/instrumentation/boto3sqs/version.py +++ b/instrumentation/opentelemetry-instrumentation-boto3sqs/src/opentelemetry/instrumentation/boto3sqs/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-botocore/pyproject.toml b/instrumentation/opentelemetry-instrumentation-botocore/pyproject.toml index d78756778d..702723015e 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-botocore/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", "opentelemetry-propagator-aws-xray == 1.0.1", ] @@ -38,8 +38,9 @@ instruments = [ test = [ "opentelemetry-instrumentation-botocore[instruments]", "markupsafe==2.0.1", + "botocore ~= 1.0, < 1.31.81", "moto[all] ~= 2.2.6", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 baf8a56e71..686b040b13 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py @@ -127,7 +127,10 @@ def instrumentation_dependencies(self) -> Collection[str]: def _instrument(self, **kwargs): # pylint: disable=attribute-defined-outside-init self._tracer = get_tracer( - __name__, __version__, kwargs.get("tracer_provider") + __name__, + __version__, + kwargs.get("tracer_provider"), + schema_url="https://opentelemetry.io/schemas/1.11.0", ) self.request_hook = kwargs.get("request_hook") diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/dynamodb.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/dynamodb.py index da389415c7..1a5f01b6ce 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/dynamodb.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/dynamodb.py @@ -28,6 +28,7 @@ from opentelemetry.trace.span import Span from opentelemetry.util.types import AttributeValue +# pylint: disable=invalid-name _AttributePathT = Union[str, Tuple[str]] diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/lmbd.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/lmbd.py index 05d45de689..299a37ab6c 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/lmbd.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/lmbd.py @@ -99,13 +99,13 @@ def _inject_current_span(cls, call_context: _AwsSdkCallContext): # Lambda extension ################################################################################ -_OPERATION_MAPPING = { +_OPERATION_MAPPING: Dict[str, _LambdaOperation] = { op.operation_name(): op for op in globals().values() if inspect.isclass(op) and issubclass(op, _LambdaOperation) and not inspect.isabstract(op) -} # type: Dict[str, _LambdaOperation] +} class _LambdaExtension(_AwsSdkExtension): diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py index 7849daa286..aa55ae697f 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py @@ -81,6 +81,10 @@ def extract_attributes( ] = MessagingDestinationKindValues.TOPIC.value attributes[SpanAttributes.MESSAGING_DESTINATION] = destination_name + # TODO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when opentelemetry-semantic-conventions 0.42b0 is released + attributes["messaging.destination.name"] = cls._extract_input_arn( + call_context + ) call_context.span_name = ( f"{'phone_number' if is_phone_number else destination_name} send" ) @@ -139,13 +143,13 @@ def before_service_call(cls, call_context: _AwsSdkCallContext, span: Span): # SNS extension ################################################################################ -_OPERATION_MAPPING = { +_OPERATION_MAPPING: Dict[str, _SnsOperation] = { op.operation_name(): op for op in globals().values() if inspect.isclass(op) and issubclass(op, _SnsOperation) and not inspect.isabstract(op) -} # type: Dict[str, _SnsOperation] +} class _SnsExtension(_AwsSdkExtension): diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/types.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/types.py index b6a1c3aa57..a3c73af65c 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/types.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/types.py @@ -57,23 +57,21 @@ def __init__(self, client: _BotoClientT, args: Tuple[str, Dict[str, Any]]): boto_meta = client.meta service_model = boto_meta.service_model - self.service = service_model.service_name.lower() # type: str - self.operation = operation # type: str - self.params = params # type: Dict[str, Any] + self.service = service_model.service_name.lower() + self.operation = operation + self.params = params # 'operation' and 'service' are essential for instrumentation. # for all other attributes we extract them defensively. All of them should # usually exist unless some future botocore version moved things. - self.region = self._get_attr( - boto_meta, "region_name" - ) # type: Optional[str] - self.endpoint_url = self._get_attr( + self.region: Optional[str] = self._get_attr(boto_meta, "region_name") + self.endpoint_url: Optional[str] = self._get_attr( boto_meta, "endpoint_url" - ) # type: Optional[str] + ) - self.api_version = self._get_attr( + self.api_version: Optional[str] = self._get_attr( service_model, "api_version" - ) # type: Optional[str] + ) # name of the service in proper casing self.service_id = str( self._get_attr(service_model, "service_id", self.service) diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/version.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/version.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_sns.py b/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_sns.py index 33f2531027..e2b4c55732 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_sns.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_sns.py @@ -118,6 +118,12 @@ def _test_publish_to_arn(self, arg_name: str): self.topic_name, span.attributes[SpanAttributes.MESSAGING_DESTINATION], ) + self.assertEqual( + target_arn, + # TODO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when + # opentelemetry-semantic-conventions 0.42b0 is released + span.attributes["messaging.destination.name"], + ) @mock_sns def test_publish_to_phone_number(self): @@ -184,6 +190,12 @@ def test_publish_batch_to_topic(self): self.topic_name, span.attributes[SpanAttributes.MESSAGING_DESTINATION], ) + self.assertEqual( + topic_arn, + # TODO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when + # opentelemetry-semantic-conventions 0.42b0 is released + span.attributes["messaging.destination.name"], + ) self.assert_injected_span(message1_attrs, span) self.assert_injected_span(message2_attrs, span) diff --git a/instrumentation/opentelemetry-instrumentation-cassandra/README.rst b/instrumentation/opentelemetry-instrumentation-cassandra/README.rst index 36e7d6202e..dfd5fa07e6 100644 --- a/instrumentation/opentelemetry-instrumentation-cassandra/README.rst +++ b/instrumentation/opentelemetry-instrumentation-cassandra/README.rst @@ -1,5 +1,5 @@ OpenTelemetry Cassandra Instrumentation -=================================== +======================================= |pypi| diff --git a/instrumentation/opentelemetry-instrumentation-cassandra/pyproject.toml b/instrumentation/opentelemetry-instrumentation-cassandra/pyproject.toml index 9abb17598f..a9f6b76310 100644 --- a/instrumentation/opentelemetry-instrumentation-cassandra/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-cassandra/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] @@ -38,7 +38,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-cassandra[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-cassandra/src/opentelemetry/instrumentation/cassandra/__init__.py b/instrumentation/opentelemetry-instrumentation-cassandra/src/opentelemetry/instrumentation/cassandra/__init__.py index 6a4ee7edc5..2a9239f152 100644 --- a/instrumentation/opentelemetry-instrumentation-cassandra/src/opentelemetry/instrumentation/cassandra/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-cassandra/src/opentelemetry/instrumentation/cassandra/__init__.py @@ -43,9 +43,9 @@ from wrapt import wrap_function_wrapper from opentelemetry import trace -from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.cassandra.package import _instruments from opentelemetry.instrumentation.cassandra.version import __version__ +from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.utils import unwrap from opentelemetry.semconv.trace import SpanAttributes @@ -55,7 +55,12 @@ def _instrument(tracer_provider, include_db_statement=False): Wraps cassandra.cluster.Session.execute_async(). """ - tracer = trace.get_tracer(__name__, __version__, tracer_provider) + tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) name = "Cassandra" def _traced_execute_async(func, instance, args, kwargs): @@ -65,7 +70,10 @@ def _traced_execute_async(func, instance, args, kwargs): if span.is_recording(): span.set_attribute(SpanAttributes.DB_NAME, instance.keyspace) span.set_attribute(SpanAttributes.DB_SYSTEM, "cassandra") - span.set_attribute(SpanAttributes.NET_PEER_NAME, instance.cluster.contact_points) + span.set_attribute( + SpanAttributes.NET_PEER_NAME, + instance.cluster.contact_points, + ) if include_db_statement: query = args[0] @@ -74,7 +82,9 @@ def _traced_execute_async(func, instance, args, kwargs): response = func(*args, **kwargs) return response - wrap_function_wrapper("cassandra.cluster", "Session.execute_async", _traced_execute_async) + wrap_function_wrapper( + "cassandra.cluster", "Session.execute_async", _traced_execute_async + ) class CassandraInstrumentor(BaseInstrumentor): diff --git a/instrumentation/opentelemetry-instrumentation-cassandra/src/opentelemetry/instrumentation/cassandra/version.py b/instrumentation/opentelemetry-instrumentation-cassandra/src/opentelemetry/instrumentation/cassandra/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-cassandra/src/opentelemetry/instrumentation/cassandra/version.py +++ b/instrumentation/opentelemetry-instrumentation-cassandra/src/opentelemetry/instrumentation/cassandra/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-cassandra/tests/test_cassandra_integration.py b/instrumentation/opentelemetry-instrumentation-cassandra/tests/test_cassandra_integration.py index 6977e1b2a2..ed488ab07f 100644 --- a/instrumentation/opentelemetry-instrumentation-cassandra/tests/test_cassandra_integration.py +++ b/instrumentation/opentelemetry-instrumentation-cassandra/tests/test_cassandra_integration.py @@ -46,15 +46,25 @@ def tearDown(self): def test_instrument_uninstrument(self): instrumentation = CassandraInstrumentor() instrumentation.instrument() - self.assertTrue(isinstance(cassandra.cluster.Session.execute_async, BoundFunctionWrapper)) + self.assertTrue( + isinstance( + cassandra.cluster.Session.execute_async, BoundFunctionWrapper + ) + ) instrumentation.uninstrument() - self.assertFalse(isinstance(cassandra.cluster.Session.execute_async, BoundFunctionWrapper)) + self.assertFalse( + isinstance( + cassandra.cluster.Session.execute_async, BoundFunctionWrapper + ) + ) @mock.patch("cassandra.cluster.Cluster.connect") @mock.patch("cassandra.cluster.Session.__init__") @mock.patch("cassandra.cluster.Session._create_response_future") - def test_instrumentor(self, mock_create_response_future, mock_session_init, mock_connect): + def test_instrumentor( + self, mock_create_response_future, mock_session_init, mock_connect + ): mock_create_response_future.return_value = mock.Mock() mock_session_init.return_value = None mock_connect.return_value = cassandra.cluster.Session() @@ -85,7 +95,9 @@ def test_instrumentor(self, mock_create_response_future, mock_session_init, mock @mock.patch("cassandra.cluster.Cluster.connect") @mock.patch("cassandra.cluster.Session.__init__") @mock.patch("cassandra.cluster.Session._create_response_future") - def test_custom_tracer_provider(self, mock_create_response_future, mock_session_init, mock_connect): + def test_custom_tracer_provider( + self, mock_create_response_future, mock_session_init, mock_connect + ): mock_create_response_future.return_value = mock.Mock() mock_session_init.return_value = None mock_connect.return_value = cassandra.cluster.Session() @@ -107,7 +119,9 @@ def test_custom_tracer_provider(self, mock_create_response_future, mock_session_ @mock.patch("cassandra.cluster.Cluster.connect") @mock.patch("cassandra.cluster.Session.__init__") @mock.patch("cassandra.cluster.Session._create_response_future") - def test_instrument_connection_no_op_tracer_provider(self, mock_create_response_future, mock_session_init, mock_connect): + def test_instrument_connection_no_op_tracer_provider( + self, mock_create_response_future, mock_session_init, mock_connect + ): mock_create_response_future.return_value = mock.Mock() mock_session_init.return_value = None mock_connect.return_value = cassandra.cluster.Session() diff --git a/instrumentation/opentelemetry-instrumentation-celery/pyproject.toml b/instrumentation/opentelemetry-instrumentation-celery/pyproject.toml index 2c0de681e1..ff39e54d8f 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-celery/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", ] [project.optional-dependencies] @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-celery[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", "pytest", ] 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 bb83a5c192..94cac68b70 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/__init__.py @@ -63,6 +63,7 @@ def add(x, y): from timeit import default_timer from typing import Collection, Iterable +from billiard import VERSION from billiard.einfo import ExceptionInfo from celery import signals # pylint: disable=no-name-in-module @@ -76,8 +77,6 @@ def add(x, y): from opentelemetry.propagators.textmap import Getter from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace.status import Status, StatusCode -from billiard import VERSION - if VERSION >= (4, 0, 1): from billiard.einfo import ExceptionWithTraceback @@ -126,10 +125,20 @@ def _instrument(self, **kwargs): tracer_provider = kwargs.get("tracer_provider") # pylint: disable=attribute-defined-outside-init - self._tracer = trace.get_tracer(__name__, __version__, tracer_provider) + self._tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) meter_provider = kwargs.get("meter_provider") - meter = get_meter(__name__, __version__, meter_provider) + meter = get_meter( + __name__, + __version__, + meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) self.create_celery_metrics(meter) diff --git a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/utils.py b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/utils.py index f92c5e03c8..6f4f9cbc3a 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/utils.py +++ b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/utils.py @@ -15,7 +15,6 @@ import logging from celery import registry # pylint: disable=no-name-in-module -from billiard import VERSION from opentelemetry.semconv.trace import SpanAttributes diff --git a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/version.py b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/version.py +++ b/instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-celery/tests/test_metrics.py b/instrumentation/opentelemetry-instrumentation-celery/tests/test_metrics.py index 46e39a6046..e290362e77 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/tests/test_metrics.py +++ b/instrumentation/opentelemetry-instrumentation-celery/tests/test_metrics.py @@ -68,9 +68,4 @@ def test_metric_uninstrument(self): self.assertEqual(len(metrics), 1) CeleryInstrumentor().uninstrument() - metrics = self.get_metrics() - self.assertEqual(len(metrics), 1) - - for metric in metrics: - for point in list(metric.data.data_points): - self.assertEqual(point.count, 1) + self.assertIsNone(self.memory_metrics_reader.get_metrics_data()) diff --git a/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/__init__.py b/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/__init__.py index c4e68b33b4..c869d03dd9 100644 --- a/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/__init__.py @@ -107,16 +107,15 @@ def instrument_consumer(consumer: Consumer, tracer_provider=None) from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.utils import unwrap from opentelemetry.semconv.trace import MessagingOperationValues -from opentelemetry.trace import Link, SpanKind, Tracer +from opentelemetry.trace import Tracer from .package import _instruments from .utils import ( KafkaPropertiesExtractor, - _end_current_consume_span, _create_new_consume_span, + _end_current_consume_span, _enrich_span, _get_span_name, - _kafka_getter, _kafka_setter, ) from .version import __version__ @@ -229,7 +228,10 @@ def instrument_producer( producer: Producer, tracer_provider=None ) -> ProxiedProducer: tracer = trace.get_tracer( - __name__, __version__, tracer_provider=tracer_provider + __name__, + __version__, + tracer_provider=tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) manual_producer = ProxiedProducer(producer, tracer) @@ -241,7 +243,10 @@ def instrument_consumer( consumer: Consumer, tracer_provider=None ) -> ProxiedConsumer: tracer = trace.get_tracer( - __name__, __version__, tracer_provider=tracer_provider + __name__, + __version__, + tracer_provider=tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) manual_consumer = ProxiedConsumer(consumer, tracer) @@ -272,7 +277,10 @@ def _instrument(self, **kwargs): tracer_provider = kwargs.get("tracer_provider") tracer = trace.get_tracer( - __name__, __version__, tracer_provider=tracer_provider + __name__, + __version__, + tracer_provider=tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) self._tracer = tracer diff --git a/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/utils.py b/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/utils.py index 2029960703..4769f2a88f 100644 --- a/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/utils.py +++ b/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/utils.py @@ -2,13 +2,13 @@ from typing import List, Optional from opentelemetry import context, propagate -from opentelemetry.trace import SpanKind, Link from opentelemetry.propagators import textmap from opentelemetry.semconv.trace import ( MessagingDestinationKindValues, MessagingOperationValues, SpanAttributes, ) +from opentelemetry.trace import Link, SpanKind _LOG = getLogger(__name__) diff --git a/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/version.py b/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/version.py +++ b/instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-confluent-kafka/tests/test_instrumentation.py b/instrumentation/opentelemetry-instrumentation-confluent-kafka/tests/test_instrumentation.py index d7ac343dbf..21d5bd6f83 100644 --- a/instrumentation/opentelemetry-instrumentation-confluent-kafka/tests/test_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-confluent-kafka/tests/test_instrumentation.py @@ -14,13 +14,6 @@ # pylint: disable=no-name-in-module -from opentelemetry.semconv.trace import ( - SpanAttributes, - MessagingDestinationKindValues, -) -from opentelemetry.test.test_base import TestBase -from .utils import MockConsumer, MockedMessage - from confluent_kafka import Consumer, Producer from opentelemetry.instrumentation.confluent_kafka import ( @@ -32,6 +25,13 @@ KafkaContextGetter, KafkaContextSetter, ) +from opentelemetry.semconv.trace import ( + MessagingDestinationKindValues, + SpanAttributes, +) +from opentelemetry.test.test_base import TestBase + +from .utils import MockConsumer, MockedMessage class TestConfluentKafka(TestBase): diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/pyproject.toml b/instrumentation/opentelemetry-instrumentation-dbapi/pyproject.toml index 5f9df3983e..2f866514c8 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-dbapi/pyproject.toml @@ -26,15 +26,15 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] [project.optional-dependencies] instruments = [] test = [ - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.urls] 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 6d7e37a45f..b0acbed185 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py @@ -264,6 +264,7 @@ def __init__( self._name, instrumenting_library_version=self._version, tracer_provider=tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) self.capture_parameters = capture_parameters self.enable_commenter = enable_commenter @@ -426,14 +427,14 @@ def traced_execution( if args and self._commenter_enabled: try: args_list = list(args) - commenter_data = dict( + commenter_data = { # Psycopg2/framework information - db_driver=f"psycopg2:{self._connect_module.__version__.split(' ')[0]}", - dbapi_threadsafety=self._connect_module.threadsafety, - dbapi_level=self._connect_module.apilevel, - libpq_version=self._connect_module.__libpq_version__, - driver_paramstyle=self._connect_module.paramstyle, - ) + "db_driver": f"psycopg2:{self._connect_module.__version__.split(' ')[0]}", + "dbapi_threadsafety": self._connect_module.threadsafety, + "dbapi_level": self._connect_module.apilevel, + "libpq_version": self._connect_module.__libpq_version__, + "driver_paramstyle": self._connect_module.paramstyle, + } if self._commenter_options.get( "opentelemetry_values", True ): diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/version.py b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/version.py index 084725a38e..633040fa58 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/version.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/version.py @@ -12,6 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" _instruments = tuple() diff --git a/instrumentation/opentelemetry-instrumentation-django/pyproject.toml b/instrumentation/opentelemetry-instrumentation-django/pyproject.toml index e235d6e6a9..d27e4a400c 100644 --- a/instrumentation/opentelemetry-instrumentation-django/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-django/pyproject.toml @@ -26,22 +26,22 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-wsgi == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-wsgi == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", ] [project.optional-dependencies] asgi = [ - "opentelemetry-instrumentation-asgi == 0.42b0.dev", + "opentelemetry-instrumentation-asgi == 0.43b0.dev", ] instruments = [ "django >= 1.10", ] test = [ "opentelemetry-instrumentation-django[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 d545a1950b..583f1adeb6 100644 --- a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py @@ -300,8 +300,14 @@ def _instrument(self, **kwargs): __name__, __version__, tracer_provider=tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) + meter = get_meter( + __name__, + __version__, + meter_provider=meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) - meter = get_meter(__name__, __version__, meter_provider=meter_provider) _DjangoMiddleware._tracer = tracer _DjangoMiddleware._meter = meter _DjangoMiddleware._excluded_urls = ( diff --git a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/version.py b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/version.py +++ b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/pyproject.toml b/instrumentation/opentelemetry-instrumentation-elasticsearch/pyproject.toml index bee1d44d2a..0d1bb6adcc 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] @@ -38,7 +38,7 @@ instruments = [ test = [ "opentelemetry-instrumentation-elasticsearch[instruments]", "elasticsearch-dsl >= 2.0", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 480ccb6402..dd72a5235e 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py @@ -140,7 +140,12 @@ def _instrument(self, **kwargs): Instruments Elasticsearch module """ tracer_provider = kwargs.get("tracer_provider") - tracer = get_tracer(__name__, __version__, tracer_provider) + tracer = get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) request_hook = kwargs.get("request_hook") response_hook = kwargs.get("response_hook") if es_transport_split: @@ -167,6 +172,7 @@ def _instrument(self, **kwargs): ) def _uninstrument(self, **kwargs): + # pylint: disable=no-member unwrap(elasticsearch.Transport, "perform_request") diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/version.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/version.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py index 37dd5f9cd7..0c84cf5cd6 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py @@ -11,6 +11,7 @@ # 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=unexpected-keyword-arg,missing-kwoa,no-value-for-parameter import json import os diff --git a/instrumentation/opentelemetry-instrumentation-falcon/pyproject.toml b/instrumentation/opentelemetry-instrumentation-falcon/pyproject.toml index b6c482ed1f..0d5114b4eb 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-falcon/pyproject.toml @@ -26,10 +26,10 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-wsgi == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-wsgi == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", "packaging >= 20.0", ] @@ -39,7 +39,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-falcon[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", "parameterized == 0.7.4", ] 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 669f41b0ab..d6cf8249a4 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py @@ -254,9 +254,17 @@ def __init__(self, *args, **kwargs): self._middlewares_list = [self._middlewares_list] self._otel_tracer = trace.get_tracer( - __name__, __version__, tracer_provider + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) + self._otel_meter = get_meter( + __name__, + __version__, + meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) - self._otel_meter = get_meter(__name__, __version__, meter_provider) self.duration_histogram = self._otel_meter.create_histogram( name=MetricInstruments.HTTP_SERVER_DURATION, unit="ms", diff --git a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/version.py b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/version.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml b/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml index 4938baaffb..7abead865e 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml @@ -26,10 +26,10 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-asgi == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-asgi == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", ] [project.optional-dependencies] @@ -38,7 +38,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-fastapi[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", "requests ~= 2.23", # needed for testclient "httpx ~= 0.22", # needed for testclient ] 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 e99c8be6ed..10b73c7a5b 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py @@ -222,7 +222,12 @@ def instrument_app( excluded_urls = _excluded_urls_from_env else: excluded_urls = parse_excluded_urls(excluded_urls) - meter = get_meter(__name__, __version__, meter_provider) + meter = get_meter( + __name__, + __version__, + meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) app.add_middleware( OpenTelemetryMiddleware, @@ -295,7 +300,10 @@ class _InstrumentedFastAPI(fastapi.FastAPI): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) meter = get_meter( - __name__, __version__, _InstrumentedFastAPI._meter_provider + __name__, + __version__, + _InstrumentedFastAPI._meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) self.add_middleware( OpenTelemetryMiddleware, diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/version.py b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/version.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml b/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml index e6c7851f7e..abb9f7289d 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml @@ -26,10 +26,10 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-wsgi == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-wsgi == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", "packaging >= 21.0", ] @@ -41,7 +41,7 @@ instruments = [ test = [ "opentelemetry-instrumentation-flask[instruments]", "markupsafe==2.1.2", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 432c6b1fbf..18b4713eaf 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py @@ -495,7 +495,10 @@ def __init__(self, *args, **kwargs): self._is_instrumented_by_opentelemetry = True meter = get_meter( - __name__, __version__, _InstrumentedFlask._meter_provider + __name__, + __version__, + _InstrumentedFlask._meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) duration_histogram = meter.create_histogram( name=MetricInstruments.HTTP_SERVER_DURATION, @@ -517,7 +520,10 @@ def __init__(self, *args, **kwargs): ) tracer = trace.get_tracer( - __name__, __version__, _InstrumentedFlask._tracer_provider + __name__, + __version__, + _InstrumentedFlask._tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) _before_request = _wrapped_before_request( @@ -594,7 +600,12 @@ def instrument_app( if excluded_urls is not None else _excluded_urls_from_env ) - meter = get_meter(__name__, __version__, meter_provider) + meter = get_meter( + __name__, + __version__, + meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) duration_histogram = meter.create_histogram( name=MetricInstruments.HTTP_SERVER_DURATION, unit="ms", @@ -615,7 +626,12 @@ def instrument_app( excluded_urls=excluded_urls, ) - tracer = trace.get_tracer(__name__, __version__, tracer_provider) + tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) _before_request = _wrapped_before_request( request_hook, diff --git a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py +++ b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py b/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py index bf641aaed4..3bd2f74ba8 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py +++ b/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py @@ -40,7 +40,6 @@ OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS, OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST, OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE, - OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE, OTEL_PYTHON_INSTRUMENTATION_HTTP_CAPTURE_ALL_METHODS, get_excluded_urls, ) @@ -328,7 +327,9 @@ def test_flask_metric_values(self): if isinstance(point, NumberDataPoint): self.assertEqual(point.value, 0) - def _assert_basic_metric(self, expected_duration_attributes, expected_requests_count_attributes): + def _assert_basic_metric( + self, expected_duration_attributes, expected_requests_count_attributes + ): metrics_list = self.memory_metrics_reader.get_metrics_data() for resource_metric in metrics_list.resource_metrics: for scope_metrics in resource_metric.scope_metrics: @@ -394,7 +395,7 @@ def test_basic_metric_nonstandard_http_method_success(self): ) @patch.dict( - "os.environ", + "os.environ", { OTEL_PYTHON_INSTRUMENTATION_HTTP_CAPTURE_ALL_METHODS: "1", }, diff --git a/instrumentation/opentelemetry-instrumentation-grpc/pyproject.toml b/instrumentation/opentelemetry-instrumentation-grpc/pyproject.toml index 37023eae4d..1fe1b6bea7 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-grpc/pyproject.toml @@ -26,9 +26,9 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", "opentelemetry-sdk ~= 1.12", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] @@ -39,7 +39,7 @@ instruments = [ test = [ "opentelemetry-instrumentation-grpc[instruments]", "opentelemetry-sdk ~= 1.12", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", "protobuf ~= 3.13", ] 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 440d1facc8..717977146e 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py @@ -576,7 +576,12 @@ def client_interceptor( """ from . import _client - tracer = trace.get_tracer(__name__, __version__, tracer_provider) + tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) return _client.OpenTelemetryClientInterceptor( tracer, @@ -601,7 +606,12 @@ def server_interceptor(tracer_provider=None, filter_=None): """ from . import _server - tracer = trace.get_tracer(__name__, __version__, tracer_provider) + tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) return _server.OpenTelemetryServerInterceptor(tracer, filter_=filter_) @@ -619,7 +629,12 @@ def aio_client_interceptors( """ from . import _aio_client - tracer = trace.get_tracer(__name__, __version__, tracer_provider) + tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) return [ _aio_client.UnaryUnaryAioClientInterceptor( @@ -660,7 +675,12 @@ def aio_server_interceptor(tracer_provider=None, filter_=None): """ from . import _aio_server - tracer = trace.get_tracer(__name__, __version__, tracer_provider) + tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) return _aio_server.OpenTelemetryAioServerInterceptor( tracer, filter_=filter_ diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_aio_server.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_aio_server.py index d64dcf000b..7c20de0cc0 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_aio_server.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_aio_server.py @@ -77,7 +77,7 @@ async def _unary_interceptor(request_or_iterator, context): # we handle in our context wrapper. # Here, we're interested in uncaught exceptions. # pylint:disable=unidiomatic-typecheck - if type(error) != Exception: + if type(error) != Exception: # noqa: E721 span.record_exception(error) raise error @@ -101,7 +101,7 @@ async def _stream_interceptor(request_or_iterator, context): except Exception as error: # pylint:disable=unidiomatic-typecheck - if type(error) != Exception: + if type(error) != Exception: # noqa: E721 span.record_exception(error) raise error diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py index dcee959b4d..9b66110574 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py @@ -315,7 +315,7 @@ def telemetry_interceptor(request_or_iterator, context): # we handle in our context wrapper. # Here, we're interested in uncaught exceptions. # pylint:disable=unidiomatic-typecheck - if type(error) != Exception: + if type(error) != Exception: # noqa: E721 span.record_exception(error) raise error @@ -342,6 +342,6 @@ def _intercept_server_stream( except Exception as error: # pylint:disable=unidiomatic-typecheck - if type(error) != Exception: + if type(error) != Exception: # noqa: E721 span.record_exception(error) raise error diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/filters/__init__.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/filters/__init__.py index 8100a2d17f..858d5d9e40 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/filters/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/filters/__init__.py @@ -17,13 +17,14 @@ import grpc -TCallDetails = TypeVar( - "TCallDetails", +CallDetailsT = TypeVar( + "CallDetailsT", grpc.HandlerCallDetails, grpc.ClientCallDetails, grpc.aio.ClientCallDetails, ) -Condition = Callable[[TCallDetails], bool] +# pylint: disable=invalid-name +Condition = Callable[[CallDetailsT], bool] def _full_method(metadata): @@ -61,7 +62,7 @@ def _split_full_method(metadata): return (service, method) -def all_of(*args: Condition[TCallDetails]) -> Condition[TCallDetails]: +def all_of(*args: Condition[CallDetailsT]) -> Condition[CallDetailsT]: """Returns a filter function that returns True if all filter functions assigned matches conditions. @@ -79,7 +80,7 @@ def filter_fn(metadata): return filter_fn -def any_of(*args: Condition[TCallDetails]) -> Condition[TCallDetails]: +def any_of(*args: Condition[CallDetailsT]) -> Condition[CallDetailsT]: """Returns a filter function that returns True if any of filter functions assigned matches conditions. @@ -97,7 +98,7 @@ def filter_fn(metadata): return filter_fn -def negate(func: Condition[TCallDetails]) -> Condition[TCallDetails]: +def negate(func: Condition[CallDetailsT]) -> Condition[CallDetailsT]: """Returns a filter function that negate the result of func Args: @@ -113,7 +114,7 @@ def filter_fn(metadata): return filter_fn -def method_name(name: str) -> Condition[TCallDetails]: +def method_name(name: str) -> Condition[CallDetailsT]: """Returns a filter function that return True if request's gRPC method name matches name. @@ -132,7 +133,7 @@ def filter_fn(metadata): return filter_fn -def method_prefix(prefix: str) -> Condition[TCallDetails]: +def method_prefix(prefix: str) -> Condition[CallDetailsT]: """Returns a filter function that return True if request's gRPC method name starts with prefix. @@ -151,7 +152,7 @@ def filter_fn(metadata): return filter_fn -def full_method_name(name: str) -> Condition[TCallDetails]: +def full_method_name(name: str) -> Condition[CallDetailsT]: """Returns a filter function that return True if request's gRPC full method name matches name. @@ -170,7 +171,7 @@ def filter_fn(metadata): return filter_fn -def service_name(name: str) -> Condition[TCallDetails]: +def service_name(name: str) -> Condition[CallDetailsT]: """Returns a filter function that return True if request's gRPC service name matches name. @@ -189,7 +190,7 @@ def filter_fn(metadata): return filter_fn -def service_prefix(prefix: str) -> Condition[TCallDetails]: +def service_prefix(prefix: str) -> Condition[CallDetailsT]: """Returns a filter function that return True if request's gRPC service name starts with prefix. @@ -208,7 +209,7 @@ def filter_fn(metadata): return filter_fn -def health_check() -> Condition[TCallDetails]: +def health_check() -> Condition[CallDetailsT]: """Returns a Filter that returns true if the request's service name is health check defined by gRPC Health Checking Protocol. https://github.com/grpc/grpc/blob/master/doc/health-checking.md diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/version.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/version.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor.py b/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor.py index 810ee930dd..21d016d624 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor.py @@ -11,6 +11,7 @@ # 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=cyclic-import import grpc from tests.protobuf import ( # pylint: disable=no-name-in-module diff --git a/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor_filter.py b/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor_filter.py index a15268464b..bfa20592ba 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor_filter.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor_filter.py @@ -11,6 +11,7 @@ # 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=cyclic-import import os from unittest import mock diff --git a/instrumentation/opentelemetry-instrumentation-httpx/README.rst b/instrumentation/opentelemetry-instrumentation-httpx/README.rst index 1e03eb128e..cc465dd615 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/README.rst +++ b/instrumentation/opentelemetry-instrumentation-httpx/README.rst @@ -136,7 +136,21 @@ The hooks can be configured as follows: # status_code, headers, stream, extensions = response pass - HTTPXClientInstrumentor().instrument(request_hook=request_hook, response_hook=response_hook) + async def async_request_hook(span, request): + # method, url, headers, stream, extensions = request + pass + + async def async_response_hook(span, request, response): + # method, url, headers, stream, extensions = request + # status_code, headers, stream, extensions = response + pass + + HTTPXClientInstrumentor().instrument( + request_hook=request_hook, + response_hook=response_hook, + async_request_hook=async_request_hook, + async_response_hook=async_response_hook + ) Or if you are using the transport classes directly: @@ -144,7 +158,7 @@ Or if you are using the transport classes directly: .. code-block:: python - from opentelemetry.instrumentation.httpx import SyncOpenTelemetryTransport + from opentelemetry.instrumentation.httpx import SyncOpenTelemetryTransport, AsyncOpenTelemetryTransport def request_hook(span, request): # method, url, headers, stream, extensions = request @@ -155,6 +169,15 @@ Or if you are using the transport classes directly: # status_code, headers, stream, extensions = response pass + async def async_request_hook(span, request): + # method, url, headers, stream, extensions = request + pass + + async def async_response_hook(span, request, response): + # method, url, headers, stream, extensions = request + # status_code, headers, stream, extensions = response + pass + transport = httpx.HTTPTransport() telemetry_transport = SyncOpenTelemetryTransport( transport, @@ -162,6 +185,13 @@ Or if you are using the transport classes directly: response_hook=response_hook ) + async_transport = httpx.AsyncHTTPTransport() + async_telemetry_transport = AsyncOpenTelemetryTransport( + async_transport, + request_hook=async_request_hook, + response_hook=async_response_hook + ) + References ---------- diff --git a/instrumentation/opentelemetry-instrumentation-httpx/pyproject.toml b/instrumentation/opentelemetry-instrumentation-httpx/pyproject.toml index a50b2f4754..3d8eebfa9b 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-httpx/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", ] [project.optional-dependencies] @@ -37,7 +37,7 @@ instruments = [ test = [ "opentelemetry-instrumentation-httpx[instruments]", "opentelemetry-sdk ~= 1.12", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py b/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py index bb40adbc26..13b01b6ca3 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py @@ -131,7 +131,21 @@ def response_hook(span, request, response): # status_code, headers, stream, extensions = response pass - HTTPXClientInstrumentor().instrument(request_hook=request_hook, response_hook=response_hook) + async def async_request_hook(span, request): + # method, url, headers, stream, extensions = request + pass + + async def async_response_hook(span, request, response): + # method, url, headers, stream, extensions = request + # status_code, headers, stream, extensions = response + pass + + HTTPXClientInstrumentor().instrument( + request_hook=request_hook, + response_hook=response_hook, + async_request_hook=async_request_hook, + async_response_hook=async_response_hook + ) Or if you are using the transport classes directly: @@ -139,7 +153,7 @@ def response_hook(span, request, response): .. code-block:: python - from opentelemetry.instrumentation.httpx import SyncOpenTelemetryTransport + from opentelemetry.instrumentation.httpx import SyncOpenTelemetryTransport, AsyncOpenTelemetryTransport def request_hook(span, request): # method, url, headers, stream, extensions = request @@ -150,6 +164,15 @@ def response_hook(span, request, response): # status_code, headers, stream, extensions = response pass + async def async_request_hook(span, request): + # method, url, headers, stream, extensions = request + pass + + async def async_response_hook(span, request, response): + # method, url, headers, stream, extensions = request + # status_code, headers, stream, extensions = response + pass + transport = httpx.HTTPTransport() telemetry_transport = SyncOpenTelemetryTransport( transport, @@ -157,6 +180,13 @@ def response_hook(span, request, response): response_hook=response_hook ) + async_transport = httpx.AsyncHTTPTransport() + async_telemetry_transport = AsyncOpenTelemetryTransport( + async_transport, + request_hook=async_request_hook, + response_hook=async_response_hook + ) + API --- """ @@ -290,6 +320,7 @@ def __init__( __name__, instrumenting_library_version=__version__, tracer_provider=tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) self._request_hook = request_hook self._response_hook = response_hook @@ -376,14 +407,15 @@ def __init__( self, transport: httpx.AsyncBaseTransport, tracer_provider: typing.Optional[TracerProvider] = None, - request_hook: typing.Optional[RequestHook] = None, - response_hook: typing.Optional[ResponseHook] = None, + request_hook: typing.Optional[AsyncRequestHook] = None, + response_hook: typing.Optional[AsyncResponseHook] = None, ): self._transport = transport self._tracer = get_tracer( __name__, instrumenting_library_version=__version__, tracer_provider=tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) self._request_hook = request_hook self._response_hook = response_hook @@ -509,21 +541,27 @@ def _instrument(self, **kwargs): Args: **kwargs: Optional arguments ``tracer_provider``: a TracerProvider, defaults to global - ``request_hook``: A hook that receives the span and request that is called - right after the span is created - ``response_hook``: A hook that receives the span, request, and response - that is called right before the span ends + ``request_hook``: A ``httpx.Client`` hook that receives the span and request + that is called right after the span is created + ``response_hook``: A ``httpx.Client`` hook that receives the span, request, + and response that is called right before the span ends + ``async_request_hook``: Async ``request_hook`` for ``httpx.AsyncClient`` + ``async_response_hook``: Async``response_hook`` for ``httpx.AsyncClient`` """ self._original_client = httpx.Client self._original_async_client = httpx.AsyncClient request_hook = kwargs.get("request_hook") response_hook = kwargs.get("response_hook") + async_request_hook = kwargs.get("async_request_hook", request_hook) + async_response_hook = kwargs.get("async_response_hook", response_hook) if callable(request_hook): _InstrumentedClient._request_hook = request_hook - _InstrumentedAsyncClient._request_hook = request_hook + if callable(async_request_hook): + _InstrumentedAsyncClient._request_hook = async_request_hook if callable(response_hook): _InstrumentedClient._response_hook = response_hook - _InstrumentedAsyncClient._response_hook = response_hook + if callable(async_response_hook): + _InstrumentedAsyncClient._response_hook = async_response_hook tracer_provider = kwargs.get("tracer_provider") _InstrumentedClient._tracer_provider = tracer_provider _InstrumentedAsyncClient._tracer_provider = tracer_provider @@ -544,8 +582,12 @@ def _uninstrument(self, **kwargs): def instrument_client( client: typing.Union[httpx.Client, httpx.AsyncClient], tracer_provider: TracerProvider = None, - request_hook: typing.Optional[RequestHook] = None, - response_hook: typing.Optional[ResponseHook] = None, + request_hook: typing.Union[ + typing.Optional[RequestHook], typing.Optional[AsyncRequestHook] + ] = None, + response_hook: typing.Union[ + typing.Optional[ResponseHook], typing.Optional[AsyncResponseHook] + ] = None, ) -> None: """Instrument httpx Client or AsyncClient diff --git a/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/version.py b/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/version.py +++ b/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py b/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py index daddaad306..db35ab2639 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py +++ b/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py @@ -421,6 +421,28 @@ def test_response_hook(self): ) HTTPXClientInstrumentor().uninstrument() + def test_response_hook_sync_async_kwargs(self): + HTTPXClientInstrumentor().instrument( + tracer_provider=self.tracer_provider, + response_hook=_response_hook, + async_response_hook=_async_response_hook, + ) + client = self.create_client() + result = self.perform_request(self.URL, client=client) + + self.assertEqual(result.text, "Hello!") + span = self.assert_span() + self.assertEqual( + span.attributes, + { + SpanAttributes.HTTP_METHOD: "GET", + SpanAttributes.HTTP_URL: self.URL, + SpanAttributes.HTTP_STATUS_CODE: 200, + HTTP_RESPONSE_BODY: "Hello!", + }, + ) + HTTPXClientInstrumentor().uninstrument() + def test_request_hook(self): HTTPXClientInstrumentor().instrument( tracer_provider=self.tracer_provider, @@ -434,6 +456,20 @@ def test_request_hook(self): self.assertEqual(span.name, "GET" + self.URL) HTTPXClientInstrumentor().uninstrument() + def test_request_hook_sync_async_kwargs(self): + HTTPXClientInstrumentor().instrument( + tracer_provider=self.tracer_provider, + request_hook=_request_hook, + async_request_hook=_async_request_hook, + ) + client = self.create_client() + result = self.perform_request(self.URL, client=client) + + self.assertEqual(result.text, "Hello!") + span = self.assert_span() + self.assertEqual(span.name, "GET" + self.URL) + HTTPXClientInstrumentor().uninstrument() + def test_request_hook_no_span_update(self): HTTPXClientInstrumentor().instrument( tracer_provider=self.tracer_provider, diff --git a/instrumentation/opentelemetry-instrumentation-jinja2/pyproject.toml b/instrumentation/opentelemetry-instrumentation-jinja2/pyproject.toml index c0f0c51d37..8283b16c98 100644 --- a/instrumentation/opentelemetry-instrumentation-jinja2/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-jinja2/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] @@ -36,7 +36,7 @@ instruments = [ test = [ "opentelemetry-instrumentation-jinja2[instruments]", "markupsafe==2.0.1", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 735f808e90..0b199cbe64 100644 --- a/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/__init__.py @@ -130,7 +130,12 @@ def instrumentation_dependencies(self) -> Collection[str]: def _instrument(self, **kwargs): tracer_provider = kwargs.get("tracer_provider") - tracer = get_tracer(__name__, __version__, tracer_provider) + tracer = get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) _wrap(jinja2, "environment.Template.render", _wrap_render(tracer)) _wrap(jinja2, "environment.Template.generate", _wrap_render(tracer)) diff --git a/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/version.py b/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/version.py +++ b/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-kafka-python/pyproject.toml b/instrumentation/opentelemetry-instrumentation-kafka-python/pyproject.toml index 9fbde3057d..23d9338b66 100644 --- a/instrumentation/opentelemetry-instrumentation-kafka-python/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-kafka-python/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.5", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", ] [project.optional-dependencies] @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-kafka-python[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] diff --git a/instrumentation/opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka/__init__.py b/instrumentation/opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka/__init__.py index ad94a4fb04..8d7378dfdf 100644 --- a/instrumentation/opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka/__init__.py @@ -102,7 +102,10 @@ def _instrument(self, **kwargs): consume_hook = kwargs.get("consume_hook") tracer = trace.get_tracer( - __name__, __version__, tracer_provider=tracer_provider + __name__, + __version__, + tracer_provider=tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) wrap_function_wrapper( diff --git a/instrumentation/opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka/version.py b/instrumentation/opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka/version.py +++ b/instrumentation/opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-kafka-python/tests/test_utils.py b/instrumentation/opentelemetry-instrumentation-kafka-python/tests/test_utils.py index 7da1ed0596..85397bcb73 100644 --- a/instrumentation/opentelemetry-instrumentation-kafka-python/tests/test_utils.py +++ b/instrumentation/opentelemetry-instrumentation-kafka-python/tests/test_utils.py @@ -1,3 +1,18 @@ +# 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=unnecessary-dunder-call + from unittest import TestCase, mock from opentelemetry.instrumentation.kafka.utils import ( diff --git a/instrumentation/opentelemetry-instrumentation-logging/pyproject.toml b/instrumentation/opentelemetry-instrumentation-logging/pyproject.toml index 76bde24c55..93fc900e1f 100644 --- a/instrumentation/opentelemetry-instrumentation-logging/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-logging/pyproject.toml @@ -25,13 +25,13 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", ] [project.optional-dependencies] instruments = [] test = [ - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py b/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py index 084725a38e..633040fa58 100644 --- a/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py +++ b/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/version.py @@ -12,6 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" _instruments = tuple() diff --git a/instrumentation/opentelemetry-instrumentation-mysql/pyproject.toml b/instrumentation/opentelemetry-instrumentation-mysql/pyproject.toml index e155147d5c..370dd9213f 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-mysql/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-dbapi == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-dbapi == 0.43b0.dev", ] [project.optional-dependencies] @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-mysql[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/version.py b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/version.py +++ b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-mysqlclient/pyproject.toml b/instrumentation/opentelemetry-instrumentation-mysqlclient/pyproject.toml index 72d4bc67cc..4bee91321a 100644 --- a/instrumentation/opentelemetry-instrumentation-mysqlclient/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-mysqlclient/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-dbapi == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-dbapi == 0.43b0.dev", ] [project.optional-dependencies] @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-mysqlclient[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-mysqlclient/src/opentelemetry/instrumentation/mysqlclient/version.py b/instrumentation/opentelemetry-instrumentation-mysqlclient/src/opentelemetry/instrumentation/mysqlclient/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-mysqlclient/src/opentelemetry/instrumentation/mysqlclient/version.py +++ b/instrumentation/opentelemetry-instrumentation-mysqlclient/src/opentelemetry/instrumentation/mysqlclient/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-pika/pyproject.toml b/instrumentation/opentelemetry-instrumentation-pika/pyproject.toml index 8ee033e58d..8d723bb0ea 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-pika/pyproject.toml @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-pika[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", "pytest", "wrapt >= 1.0.0, < 2.0.0", ] diff --git a/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/pika_instrumentor.py b/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/pika_instrumentor.py index b09c3a0f9c..56c78a85c3 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/pika_instrumentor.py +++ b/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/pika_instrumentor.py @@ -11,6 +11,8 @@ # 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=unnecessary-dunder-call + from logging import getLogger from typing import Any, Collection, Dict, Optional @@ -122,7 +124,12 @@ def instrument_channel( "Attempting to instrument Pika channel while already instrumented!" ) return - tracer = trace.get_tracer(__name__, __version__, tracer_provider) + tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) PikaInstrumentor._instrument_blocking_channel_consumers( channel, tracer, consume_hook ) diff --git a/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/version.py b/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/version.py +++ b/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/pyproject.toml b/instrumentation/opentelemetry-instrumentation-psycopg2/pyproject.toml index d709c2bad1..df917b8917 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-dbapi == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-dbapi == 0.43b0.dev", ] [project.optional-dependencies] @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-psycopg2[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/version.py b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/version.py +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/tests/test_psycopg2_integration.py b/instrumentation/opentelemetry-instrumentation-psycopg2/tests/test_psycopg2_integration.py index 8252929037..369d63d5cf 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/tests/test_psycopg2_integration.py +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/tests/test_psycopg2_integration.py @@ -61,7 +61,7 @@ def cursor(self): return MockCursor() def get_dsn_parameters(self): # pylint: disable=no-self-use - return dict(dbname="test") + return {"dbname": "test"} class TestPostgresqlIntegration(TestBase): diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/pyproject.toml b/instrumentation/opentelemetry-instrumentation-pymemcache/pyproject.toml index f6b61bd4d0..067ad618aa 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] @@ -37,7 +37,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-pymemcache[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 573414c1c7..512ce9ea56 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/__init__.py @@ -169,7 +169,7 @@ def _get_address_attributes(instance): address_attributes[SpanAttributes.NET_PEER_NAME] = instance.server address_attributes[ SpanAttributes.NET_TRANSPORT - ] = NetTransportValues.UNIX.value + ] = NetTransportValues.OTHER.value return address_attributes @@ -182,7 +182,12 @@ def instrumentation_dependencies(self) -> Collection[str]: def _instrument(self, **kwargs): tracer_provider = kwargs.get("tracer_provider") - tracer = get_tracer(__name__, __version__, tracer_provider) + tracer = get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) for cmd in COMMANDS: _wrap( diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/version.py b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/version.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py b/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py index 4e29091217..35b672bac0 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py @@ -24,14 +24,15 @@ MemcacheUnknownError, ) +# pylint: disable=import-error,no-name-in-module +from tests.utils import MockSocket, _str + from opentelemetry import trace as trace_api from opentelemetry.instrumentation.pymemcache import PymemcacheInstrumentor from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.test.test_base import TestBase from opentelemetry.trace import get_tracer -from .utils import MockSocket, _str - TEST_HOST = "localhost" TEST_PORT = 117711 diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/pyproject.toml b/instrumentation/opentelemetry-instrumentation-pymongo/pyproject.toml index 2c40ed26bb..5962545901 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-pymongo/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", ] [project.optional-dependencies] @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-pymongo[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 00e757edee..041ff6b928 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py @@ -248,7 +248,12 @@ def _instrument(self, **kwargs): capture_statement = kwargs.get("capture_statement") # Create and register a CommandTracer only the first time if self._commandtracer_instance is None: - tracer = get_tracer(__name__, __version__, tracer_provider) + tracer = get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) self._commandtracer_instance = CommandTracer( tracer, diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/version.py b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/version.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-pymysql/pyproject.toml b/instrumentation/opentelemetry-instrumentation-pymysql/pyproject.toml index 62404ed4f1..7e36fa65bd 100644 --- a/instrumentation/opentelemetry-instrumentation-pymysql/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-pymysql/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-dbapi == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-dbapi == 0.43b0.dev", ] [project.optional-dependencies] @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-pymysql[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/version.py b/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/version.py +++ b/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/pyproject.toml b/instrumentation/opentelemetry-instrumentation-pyramid/pyproject.toml index 59483c972b..348d73abd7 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-pyramid/pyproject.toml @@ -26,10 +26,10 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-wsgi == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-wsgi == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] @@ -39,7 +39,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-pyramid[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", "werkzeug == 0.16.1", ] 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 ce15f0cb24..e3675fcfab 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py @@ -84,7 +84,11 @@ def _before_traversal(event): return start_time = request_environ.get(_ENVIRON_STARTTIME_KEY) - tracer = trace.get_tracer(__name__, __version__) + tracer = trace.get_tracer( + __name__, + __version__, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) if request.matched_route: span_name = request.matched_route.pattern @@ -128,7 +132,11 @@ def trace_tween_factory(handler, registry): # pylint: disable=too-many-statements settings = registry.settings enabled = asbool(settings.get(SETTING_TRACE_ENABLED, True)) - meter = get_meter(__name__, __version__) + meter = get_meter( + __name__, + __version__, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) duration_histogram = meter.create_histogram( name=MetricInstruments.HTTP_SERVER_DURATION, unit="ms", diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/version.py b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/version.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-redis/pyproject.toml b/instrumentation/opentelemetry-instrumentation-redis/pyproject.toml index 3ae0609147..3f32ae2f6d 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-redis/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", "wrapt >= 1.12.1", ] @@ -38,7 +38,7 @@ instruments = [ test = [ "opentelemetry-instrumentation-redis[instruments]", "opentelemetry-sdk ~= 1.3", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 ba4b8d529e..1d61e8cfd3 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py @@ -333,7 +333,10 @@ def _instrument(self, **kwargs): """ tracer_provider = kwargs.get("tracer_provider") tracer = trace.get_tracer( - __name__, __version__, tracer_provider=tracer_provider + __name__, + __version__, + tracer_provider=tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) _instrument( tracer, diff --git a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py index b24f9b2655..3c274c8c43 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py +++ b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py @@ -43,7 +43,7 @@ def _extract_conn_attributes(conn_kwargs): attributes[SpanAttributes.NET_PEER_NAME] = conn_kwargs.get("path", "") attributes[ SpanAttributes.NET_TRANSPORT - ] = NetTransportValues.UNIX.value + ] = NetTransportValues.OTHER.value return attributes diff --git a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/version.py b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/version.py +++ b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-remoulade/pyproject.toml b/instrumentation/opentelemetry-instrumentation-remoulade/pyproject.toml index 2a3a596700..0c6995a752 100644 --- a/instrumentation/opentelemetry-instrumentation-remoulade/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-remoulade/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", ] [project.optional-dependencies] @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-remoulade[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", "opentelemetry-sdk ~= 1.10" ] diff --git a/instrumentation/opentelemetry-instrumentation-remoulade/src/opentelemetry/instrumentation/remoulade/__init__.py b/instrumentation/opentelemetry-instrumentation-remoulade/src/opentelemetry/instrumentation/remoulade/__init__.py index 87a26585fc..56e544edcd 100644 --- a/instrumentation/opentelemetry-instrumentation-remoulade/src/opentelemetry/instrumentation/remoulade/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-remoulade/src/opentelemetry/instrumentation/remoulade/__init__.py @@ -176,7 +176,12 @@ def _instrument(self, **kwargs): tracer_provider = kwargs.get("tracer_provider") # pylint: disable=attribute-defined-outside-init - self._tracer = trace.get_tracer(__name__, __version__, tracer_provider) + self._tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) instrumentation_middleware = _InstrumentationMiddleware(self._tracer) broker.add_extra_default_middleware(instrumentation_middleware) diff --git a/instrumentation/opentelemetry-instrumentation-remoulade/src/opentelemetry/instrumentation/remoulade/version.py b/instrumentation/opentelemetry-instrumentation-remoulade/src/opentelemetry/instrumentation/remoulade/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-remoulade/src/opentelemetry/instrumentation/remoulade/version.py +++ b/instrumentation/opentelemetry-instrumentation-remoulade/src/opentelemetry/instrumentation/remoulade/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml b/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml index 184bd1ca7e..075bb1f571 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml @@ -26,9 +26,9 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", ] [project.optional-dependencies] @@ -38,7 +38,7 @@ instruments = [ test = [ "opentelemetry-instrumentation-requests[instruments]", "httpretty ~= 1.0", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 c3dabf05a5..535b14285f 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py @@ -277,13 +277,19 @@ def _instrument(self, **kwargs): list of regexes used to exclude URLs from tracking """ tracer_provider = kwargs.get("tracer_provider") - tracer = get_tracer(__name__, __version__, tracer_provider) + tracer = get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) excluded_urls = kwargs.get("excluded_urls") meter_provider = kwargs.get("meter_provider") meter = get_meter( __name__, __version__, meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) duration_histogram = meter.create_histogram( name=MetricInstruments.HTTP_CLIENT_DURATION, diff --git a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py +++ b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py b/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py index 3bd76a6995..82fa4ed1e6 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py +++ b/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py @@ -456,7 +456,7 @@ class TestRequestsIntegration(RequestsIntegrationTestBase, TestBase): @staticmethod def perform_request(url: str, session: requests.Session = None): if session is None: - return requests.get(url) + return requests.get(url, timeout=5) return session.get(url) def test_credential_removal(self): @@ -467,7 +467,7 @@ def test_credential_removal(self): self.assertEqual(span.attributes[SpanAttributes.HTTP_URL], self.URL) def test_if_headers_equals_none(self): - result = requests.get(self.URL, headers=None) + result = requests.get(self.URL, headers=None, timeout=5) self.assertEqual(result.text, "Hello!") self.assert_span() @@ -501,7 +501,7 @@ def tearDown(self): @staticmethod def perform_request(url: str) -> requests.Response: - return requests.get(url) + return requests.get(url, timeout=5) def test_basic_metric_success(self): self.perform_request(self.URL) diff --git a/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_ip_support.py b/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_ip_support.py index cf2e7fb4dd..8589ac0e26 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_ip_support.py +++ b/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_ip_support.py @@ -38,7 +38,7 @@ def tearDown(self): @staticmethod def perform_request(url: str) -> requests.Response: - return requests.get(url) + return requests.get(url, timeout=5) def test_basic_http_success(self): response = self.perform_request(self.http_url) diff --git a/instrumentation/opentelemetry-instrumentation-sklearn/pyproject.toml b/instrumentation/opentelemetry-instrumentation-sklearn/pyproject.toml index 85a145f662..c4864cbeb8 100644 --- a/instrumentation/opentelemetry-instrumentation-sklearn/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-sklearn/pyproject.toml @@ -26,7 +26,7 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", ] [project.optional-dependencies] @@ -35,7 +35,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-sklearn[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 08abeb1d0e..a67bfa6ef4 100644 --- a/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/__init__.py @@ -82,6 +82,8 @@ from sklearn.utils.metaestimators import _IffHasAttrDescriptor from opentelemetry.instrumentation.instrumentor import BaseInstrumentor + +# pylint: disable=no-name-in-module from opentelemetry.instrumentation.sklearn.package import _instruments from opentelemetry.instrumentation.sklearn.version import __version__ from opentelemetry.trace import get_tracer @@ -129,9 +131,11 @@ def implement_span_function(func: Callable, name: str, attributes: Attributes): @wraps(func) def wrapper(*args, **kwargs): - with get_tracer(__name__, __version__).start_as_current_span( - name=name - ) as span: + with get_tracer( + __name__, + __version__, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ).start_as_current_span(name=name) as span: if span.is_recording(): for key, val in attributes.items(): span.set_attribute(key, val) diff --git a/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/version.py b/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/version.py index e9ca2a1777..0d568a8987 100644 --- a/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/version.py +++ b/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-sklearn/tests/test_sklearn.py b/instrumentation/opentelemetry-instrumentation-sklearn/tests/test_sklearn.py index ad4d032280..db69761ece 100644 --- a/instrumentation/opentelemetry-instrumentation-sklearn/tests/test_sklearn.py +++ b/instrumentation/opentelemetry-instrumentation-sklearn/tests/test_sklearn.py @@ -14,6 +14,7 @@ from sklearn.ensemble import RandomForestClassifier +# pylint: disable=no-name-in-module from opentelemetry.instrumentation.sklearn import ( DEFAULT_EXCLUDE_CLASSES, DEFAULT_METHODS, diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/pyproject.toml b/instrumentation/opentelemetry-instrumentation-sqlalchemy/pyproject.toml index 3b96607b41..a1ca23779e 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", "packaging >= 21.0", "wrapt >= 1.11.2", ] 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 e14ac9600c..2107bc3e23 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/__init__.py @@ -142,10 +142,20 @@ def _instrument(self, **kwargs): An instrumented engine if passed in as an argument or list of instrumented engines, None otherwise. """ tracer_provider = kwargs.get("tracer_provider") - tracer = get_tracer(__name__, __version__, tracer_provider) + tracer = get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) meter_provider = kwargs.get("meter_provider") - meter = get_meter(__name__, __version__, meter_provider) + meter = get_meter( + __name__, + __version__, + meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) connections_usage = meter.create_up_down_counter( name=MetricInstruments.DB_CLIENT_CONNECTIONS_USAGE, 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 1cf980929b..0632d71faf 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py @@ -224,11 +224,11 @@ def _before_cur_exec( for key, value in attrs.items(): span.set_attribute(key, value) if self.enable_commenter: - commenter_data = dict( - db_driver=conn.engine.driver, + commenter_data = { + "db_driver": conn.engine.driver, # Driver/framework centric information. - db_framework=f"sqlalchemy:{__version__}", - ) + "db_framework": f"sqlalchemy:{__version__}", + } if self.commenter_options.get("opentelemetry_values", True): commenter_data.update(**_get_opentelemetry_values()) @@ -296,7 +296,9 @@ def _get_attributes_from_cursor(vendor, cursor, attrs): is_unix_socket = info.host and info.host.startswith("/") if is_unix_socket: - attrs[SpanAttributes.NET_TRANSPORT] = NetTransportValues.UNIX.value + attrs[ + SpanAttributes.NET_TRANSPORT + ] = NetTransportValues.OTHER.value if info.port: # postgresql enforces this pattern on all socket names attrs[SpanAttributes.NET_PEER_NAME] = os.path.join( diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/version.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/version.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy_metrics.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy_metrics.py index 2d753c3c42..8d89959428 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy_metrics.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy_metrics.py @@ -56,8 +56,7 @@ def test_metrics_one_connection(self): pool_logging_name=pool_name, ) - metrics = self.get_sorted_metrics() - self.assertEqual(len(metrics), 0) + self.assertIsNone(self.memory_metrics_reader.get_metrics_data()) with engine.connect(): self.assert_pool_idle_used_expected( @@ -78,8 +77,7 @@ def test_metrics_without_pool_name(self): pool_logging_name=pool_name, ) - metrics = self.get_sorted_metrics() - self.assertEqual(len(metrics), 0) + self.assertIsNone(self.memory_metrics_reader.get_metrics_data()) with engine.connect(): self.assert_pool_idle_used_expected( @@ -100,8 +98,7 @@ def test_metrics_two_connections(self): pool_logging_name=pool_name, ) - metrics = self.get_sorted_metrics() - self.assertEqual(len(metrics), 0) + self.assertIsNone(self.memory_metrics_reader.get_metrics_data()) with engine.connect(): with engine.connect(): @@ -122,8 +119,7 @@ def test_metrics_connections(self): pool_logging_name=pool_name, ) - metrics = self.get_sorted_metrics() - self.assertEqual(len(metrics), 0) + self.assertIsNone(self.memory_metrics_reader.get_metrics_data()) with engine.connect(): with engine.connect(): @@ -156,5 +152,4 @@ def test_metric_uninstrument(self): engine.connect() - metrics = self.get_sorted_metrics() - self.assertEqual(len(metrics), 0) + self.assertIsNone(self.memory_metrics_reader.get_metrics_data()) diff --git a/instrumentation/opentelemetry-instrumentation-sqlite3/pyproject.toml b/instrumentation/opentelemetry-instrumentation-sqlite3/pyproject.toml index d7f6d6aae9..b67bb1d695 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlite3/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-sqlite3/pyproject.toml @@ -26,14 +26,14 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-dbapi == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-dbapi == 0.43b0.dev", ] [project.optional-dependencies] instruments = [] test = [ - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/version.py b/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/version.py index 084725a38e..633040fa58 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/version.py +++ b/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/version.py @@ -12,6 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" _instruments = tuple() diff --git a/instrumentation/opentelemetry-instrumentation-starlette/pyproject.toml b/instrumentation/opentelemetry-instrumentation-starlette/pyproject.toml index 4c884bcc5e..a35920530c 100644 --- a/instrumentation/opentelemetry-instrumentation-starlette/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-starlette/pyproject.toml @@ -26,10 +26,10 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-instrumentation-asgi == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-instrumentation-asgi == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", ] [project.optional-dependencies] @@ -38,7 +38,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-starlette[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", "requests ~= 2.23", # needed for testclient "httpx ~= 0.22", # needed for testclient ] 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 2d123aa70e..1ebc3348d4 100644 --- a/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/__init__.py @@ -207,7 +207,12 @@ def instrument_app( tracer_provider=None, ): """Instrument an uninstrumented Starlette application.""" - meter = get_meter(__name__, __version__, meter_provider) + meter = get_meter( + __name__, + __version__, + meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) if not getattr(app, "is_instrumented_by_opentelemetry", False): app.add_middleware( OpenTelemetryMiddleware, @@ -273,7 +278,10 @@ class _InstrumentedStarlette(applications.Starlette): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) meter = get_meter( - __name__, __version__, _InstrumentedStarlette._meter_provider + __name__, + __version__, + _InstrumentedStarlette._meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) self.add_middleware( OpenTelemetryMiddleware, diff --git a/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/version.py b/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/version.py +++ b/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/pyproject.toml b/instrumentation/opentelemetry-instrumentation-system-metrics/pyproject.toml index 3c9f363a4c..227069f584 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/pyproject.toml @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-system-metrics[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py index 3d6a0c6775..32766fa0c5 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py @@ -76,7 +76,9 @@ """ import gc +import logging import os +import sys import threading from platform import python_implementation from typing import Collection, Dict, Iterable, List, Optional @@ -91,6 +93,9 @@ from opentelemetry.metrics import CallbackOptions, Observation, get_meter from opentelemetry.sdk.util import get_dict_as_key +_logger = logging.getLogger(__name__) + + _DEFAULT_CONFIG = { "system.cpu.time": ["idle", "user", "system", "irq"], "system.cpu.utilization": ["idle", "user", "system", "irq"], @@ -115,6 +120,10 @@ "process.runtime.context_switches": ["involuntary", "voluntary"], } +if sys.platform == "darwin": + # see https://github.com/giampaolo/psutil/issues/1219 + _DEFAULT_CONFIG.pop("system.network.connections") + class SystemMetricsInstrumentor(BaseInstrumentor): def __init__( @@ -172,6 +181,7 @@ def _instrument(self, **kwargs): __name__, __version__, meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", ) if "system.cpu.time" in self._config: @@ -351,12 +361,17 @@ def _instrument(self, **kwargs): ) if "process.runtime.gc_count" in self._config: - self._meter.create_observable_counter( - name=f"process.runtime.{self._python_implementation}.gc_count", - callbacks=[self._get_runtime_gc_count], - description=f"Runtime {self._python_implementation} GC count", - unit="bytes", - ) + if self._python_implementation == "pypy": + _logger.warning( + "The process.runtime.gc_count metric won't be collected because the interpreter is PyPy" + ) + else: + self._meter.create_observable_counter( + name=f"process.runtime.{self._python_implementation}.gc_count", + callbacks=[self._get_runtime_gc_count], + description=f"Runtime {self._python_implementation} GC count", + unit="bytes", + ) if "process.runtime.thread_count" in self._config: self._meter.create_observable_up_down_counter( diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/version.py b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/version.py +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py b/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py index e28c437009..3986a32c16 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py @@ -16,15 +16,14 @@ from collections import namedtuple from platform import python_implementation -from unittest import mock - -from opentelemetry.sdk.metrics import MeterProvider -from opentelemetry.sdk.metrics.export import InMemoryMetricReader -from opentelemetry.test.test_base import TestBase +from unittest import mock, skipIf from opentelemetry.instrumentation.system_metrics import ( SystemMetricsInstrumentor, ) +from opentelemetry.sdk.metrics import MeterProvider +from opentelemetry.sdk.metrics.export import InMemoryMetricReader +from opentelemetry.test.test_base import TestBase def _mock_netconnection(): @@ -97,7 +96,6 @@ def test_system_metrics_instrument(self): for scope_metrics in resource_metrics.scope_metrics: for metric in scope_metrics.metrics: metric_names.append(metric.name) - self.assertEqual(len(metric_names), 21) observer_names = [ "system.cpu.time", @@ -117,12 +115,19 @@ def test_system_metrics_instrument(self): "system.thread_count", f"process.runtime.{self.implementation}.memory", f"process.runtime.{self.implementation}.cpu_time", - f"process.runtime.{self.implementation}.gc_count", f"process.runtime.{self.implementation}.thread_count", f"process.runtime.{self.implementation}.context_switches", f"process.runtime.{self.implementation}.cpu.utilization", ] + if self.implementation == "pypy": + self.assertEqual(len(metric_names), 20) + else: + self.assertEqual(len(metric_names), 21) + observer_names.append( + f"process.runtime.{self.implementation}.gc_count", + ) + for observer in metric_names: self.assertIn(observer, observer_names) observer_names.remove(observer) @@ -131,12 +136,14 @@ def test_runtime_metrics_instrument(self): runtime_config = { "process.runtime.memory": ["rss", "vms"], "process.runtime.cpu.time": ["user", "system"], - "process.runtime.gc_count": None, "process.runtime.thread_count": None, "process.runtime.cpu.utilization": None, "process.runtime.context_switches": ["involuntary", "voluntary"], } + if self.implementation != "pypy": + runtime_config["process.runtime.gc_count"] = None + reader = InMemoryMetricReader() meter_provider = MeterProvider(metric_readers=[reader]) runtime_metrics = SystemMetricsInstrumentor(config=runtime_config) @@ -147,17 +154,23 @@ def test_runtime_metrics_instrument(self): for scope_metrics in resource_metrics.scope_metrics: for metric in scope_metrics.metrics: metric_names.append(metric.name) - self.assertEqual(len(metric_names), 6) observer_names = [ f"process.runtime.{self.implementation}.memory", f"process.runtime.{self.implementation}.cpu_time", - f"process.runtime.{self.implementation}.gc_count", f"process.runtime.{self.implementation}.thread_count", f"process.runtime.{self.implementation}.context_switches", f"process.runtime.{self.implementation}.cpu.utilization", ] + if self.implementation == "pypy": + self.assertEqual(len(metric_names), 5) + else: + self.assertEqual(len(metric_names), 6) + observer_names.append( + f"process.runtime.{self.implementation}.gc_count" + ) + for observer in metric_names: self.assertIn(observer, observer_names) observer_names.remove(observer) @@ -171,9 +184,9 @@ def _assert_metrics(self, observer_name, reader, expected): for data_point in metric.data.data_points: for expect in expected: if ( - dict(data_point.attributes) - == expect.attributes - and metric.name == observer_name + dict(data_point.attributes) + == expect.attributes + and metric.name == observer_name ): self.assertEqual( data_point.value, @@ -781,6 +794,9 @@ def test_runtime_cpu_time(self, mock_process_cpu_times): ) @mock.patch("gc.get_count") + @skipIf( + python_implementation().lower() == "pypy", "not supported for pypy" + ) def test_runtime_get_count(self, mock_gc_get_count): mock_gc_get_count.configure_mock(**{"return_value": (1, 2, 3)}) diff --git a/instrumentation/opentelemetry-instrumentation-tornado/pyproject.toml b/instrumentation/opentelemetry-instrumentation-tornado/pyproject.toml index 1a286e5114..191c30d980 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-tornado/pyproject.toml @@ -25,9 +25,9 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", ] [project.optional-dependencies] @@ -36,7 +36,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-tornado[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", "http-server-mock" ] 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 1e2f0e5162..dfa4b217df 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py @@ -236,10 +236,20 @@ def _instrument(self, **kwargs): process lifetime. """ tracer_provider = kwargs.get("tracer_provider") - tracer = trace.get_tracer(__name__, __version__, tracer_provider) + tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) meter_provider = kwargs.get("meter_provider") - meter = get_meter(__name__, __version__, meter_provider) + meter = get_meter( + __name__, + __version__, + meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) client_histograms = _create_client_histograms(meter) server_histograms = _create_server_histograms(meter) diff --git a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/version.py b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/version.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-tortoiseorm/pyproject.toml b/instrumentation/opentelemetry-instrumentation-tortoiseorm/pyproject.toml index 42e3573806..695bb6a219 100644 --- a/instrumentation/opentelemetry-instrumentation-tortoiseorm/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-tortoiseorm/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", ] [project.optional-dependencies] @@ -37,7 +37,7 @@ instruments = [ ] test = [ "opentelemetry-instrumentation-tortoiseorm[instruments]", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] diff --git a/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/__init__.py b/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/__init__.py index 0b1ae4a29e..7988daf130 100644 --- a/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/__init__.py @@ -95,7 +95,12 @@ def _instrument(self, **kwargs): """ tracer_provider = kwargs.get("tracer_provider") # pylint: disable=attribute-defined-outside-init - self._tracer = trace.get_tracer(__name__, __version__, tracer_provider) + self._tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) self.capture_parameters = kwargs.get("capture_parameters", False) if TORTOISE_SQLITE_SUPPORT: funcs = [ diff --git a/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/version.py b/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/version.py +++ b/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-urllib/pyproject.toml b/instrumentation/opentelemetry-instrumentation-urllib/pyproject.toml index 56bfb5e869..222f229a2d 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-urllib/pyproject.toml @@ -26,16 +26,16 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", ] [project.optional-dependencies] instruments = [] test = [ "httpretty ~= 1.0", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 cdd35a0bad..eca8fbda77 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py @@ -137,10 +137,20 @@ def _instrument(self, **kwargs): list of regexes used to exclude URLs from tracking """ tracer_provider = kwargs.get("tracer_provider") - tracer = get_tracer(__name__, __version__, tracer_provider) + tracer = get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) excluded_urls = kwargs.get("excluded_urls") meter_provider = kwargs.get("meter_provider") - meter = get_meter(__name__, __version__, meter_provider) + meter = get_meter( + __name__, + __version__, + meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) histograms = _create_client_histograms(meter) @@ -229,8 +239,8 @@ def _instrumented_open_call( token = context.attach( context.set_value(_SUPPRESS_HTTP_INSTRUMENTATION_KEY, True) ) + start_time = default_timer() try: - start_time = default_timer() result = call_wrapped() # *** PROCEED except Exception as exc: # pylint: disable=W0703 exception = exc @@ -297,17 +307,17 @@ def _create_client_histograms(meter) -> Dict[str, Histogram]: MetricInstruments.HTTP_CLIENT_DURATION: meter.create_histogram( name=MetricInstruments.HTTP_CLIENT_DURATION, unit="ms", - description="measures the duration outbound HTTP requests", + description="Measures the duration of outbound HTTP requests.", ), MetricInstruments.HTTP_CLIENT_REQUEST_SIZE: meter.create_histogram( name=MetricInstruments.HTTP_CLIENT_REQUEST_SIZE, unit="By", - description="measures the size of HTTP request messages (compressed)", + description="Measures the size of HTTP request messages.", ), MetricInstruments.HTTP_CLIENT_RESPONSE_SIZE: meter.create_histogram( name=MetricInstruments.HTTP_CLIENT_RESPONSE_SIZE, unit="By", - description="measures the size of HTTP response messages (compressed)", + description="Measures the size of HTTP response messages.", ), } diff --git a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/version.py b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/version.py index 084725a38e..633040fa58 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/version.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/version.py @@ -12,6 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" _instruments = tuple() diff --git a/instrumentation/opentelemetry-instrumentation-urllib/tests/test_metrics_instrumentation.py b/instrumentation/opentelemetry-instrumentation-urllib/tests/test_metrics_instrumentation.py index f56aa4f97d..087607e606 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/tests/test_metrics_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/tests/test_metrics_instrumentation.py @@ -13,11 +13,14 @@ # limitations under the License. +from platform import python_implementation +from sys import version_info from timeit import default_timer from urllib import request from urllib.parse import urlencode import httpretty +from pytest import mark from opentelemetry.instrumentation.urllib import ( # pylint: disable=no-name-in-module,import-error URLLibInstrumentor, @@ -185,16 +188,21 @@ def test_basic_metric_request_not_empty(self): ), ) + @mark.skipif( + python_implementation() == "PyPy" or version_info.minor == 7, + reason="Fails randomly in 3.7 and pypy", + ) def test_metric_uninstrument(self): with request.urlopen(self.URL): metrics = self.get_sorted_metrics() self.assertEqual(len(metrics), 3) + self.assertEqual(metrics[0].data.data_points[0].sum, 1) + self.assertEqual(metrics[1].data.data_points[0].sum, 0) + self.assertEqual(metrics[2].data.data_points[0].sum, 6) + URLLibInstrumentor().uninstrument() with request.urlopen(self.URL): - metrics = self.get_sorted_metrics() - self.assertEqual(len(metrics), 3) - - for metric in metrics: - for point in list(metric.data.data_points): - self.assertEqual(point.count, 1) + self.assertIsNone( + self.memory_metrics_reader.get_metrics_data() + ) diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/pyproject.toml b/instrumentation/opentelemetry-instrumentation-urllib3/pyproject.toml index db4d485d8e..965df9ea77 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-urllib3/pyproject.toml @@ -26,9 +26,9 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", "wrapt >= 1.0.0, < 2.0.0", ] @@ -39,7 +39,7 @@ instruments = [ test = [ "opentelemetry-instrumentation-urllib3[instruments]", "httpretty ~= 1.0", - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.entry-points.opentelemetry_instrumentor] 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 d3016ea5ee..5580cb529f 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py @@ -163,27 +163,37 @@ def _instrument(self, **kwargs): list of regexes used to exclude URLs from tracking """ tracer_provider = kwargs.get("tracer_provider") - tracer = get_tracer(__name__, __version__, tracer_provider) + tracer = get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) excluded_urls = kwargs.get("excluded_urls") meter_provider = kwargs.get("meter_provider") - meter = get_meter(__name__, __version__, meter_provider) + meter = get_meter( + __name__, + __version__, + meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) duration_histogram = meter.create_histogram( name=MetricInstruments.HTTP_CLIENT_DURATION, unit="ms", - description="measures the duration outbound HTTP requests", + description="Measures the duration of outbound HTTP requests.", ) request_size_histogram = meter.create_histogram( name=MetricInstruments.HTTP_CLIENT_REQUEST_SIZE, unit="By", - description="measures the size of HTTP request messages (compressed)", + description="Measures the size of HTTP request messages.", ) response_size_histogram = meter.create_histogram( name=MetricInstruments.HTTP_CLIENT_RESPONSE_SIZE, unit="By", - description="measures the size of HTTP response messages (compressed)", + description="Measures the size of HTTP response messages.", ) _instrument( diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py index 7ba7e2731b..27e1b81269 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py @@ -138,6 +138,17 @@ def test_basic_https_success_using_connection_pool(self): self.assert_success_span(response, self.HTTPS_URL) + def test_schema_url(self): + pool = urllib3.HTTPSConnectionPool("mock") + response = pool.request("GET", "/status/200") + + self.assertEqual(b"Hello!", response.data) + span = self.assert_span() + self.assertEqual( + span.instrumentation_info.schema_url, + "https://opentelemetry.io/schemas/1.11.0", + ) + def test_basic_not_found(self): url_404 = "http://mock/status/404" httpretty.register_uri(httpretty.GET, url_404, status=404) diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_metrics.py b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_metrics.py index 2fd4cb2c5c..787b920d7c 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_metrics.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_metrics.py @@ -155,6 +155,20 @@ def test_str_request_body_size_metrics(self): ], ) + def test_schema_url(self): + self.pool.request("POST", self.HTTP_URL, body="foobar") + + resource_metrics = ( + self.memory_metrics_reader.get_metrics_data().resource_metrics + ) + + for metrics in resource_metrics: + for scope_metrics in metrics.scope_metrics: + self.assertEqual( + scope_metrics.scope.schema_url, + "https://opentelemetry.io/schemas/1.11.0", + ) + def test_bytes_request_body_size_metrics(self): self.pool.request("POST", self.HTTP_URL, body=b"foobar") diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml b/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml index 50860fb0d6..70afad641c 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-wsgi/pyproject.toml @@ -26,15 +26,15 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", - "opentelemetry-semantic-conventions == 0.42b0.dev", - "opentelemetry-util-http == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", + "opentelemetry-semantic-conventions == 0.43b0.dev", + "opentelemetry-util-http == 0.43b0.dev", ] [project.optional-dependencies] instruments = [] test = [ - "opentelemetry-test-utils == 0.42b0.dev", + "opentelemetry-test-utils == 0.43b0.dev", ] [project.urls] 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 35e217264d..87c73cc737 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py @@ -302,7 +302,9 @@ def collect_request_attributes(environ): """ result = { - SpanAttributes.HTTP_METHOD: sanitize_method(environ.get("REQUEST_METHOD")), + SpanAttributes.HTTP_METHOD: sanitize_method( + environ.get("REQUEST_METHOD") + ), SpanAttributes.HTTP_SERVER_NAME: environ.get("SERVER_NAME"), SpanAttributes.HTTP_SCHEME: environ.get("wsgi.url_scheme"), } @@ -490,8 +492,18 @@ def __init__( meter_provider=None, ): self.wsgi = wsgi - self.tracer = trace.get_tracer(__name__, __version__, tracer_provider) - self.meter = get_meter(__name__, __version__, meter_provider) + self.tracer = trace.get_tracer( + __name__, + __version__, + tracer_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) + self.meter = get_meter( + __name__, + __version__, + meter_provider, + schema_url="https://opentelemetry.io/schemas/1.11.0", + ) self.duration_histogram = self.meter.create_histogram( name=MetricInstruments.HTTP_SERVER_DURATION, unit="ms", diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py index c2996671d6..2e4aa8c751 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py index 6aef096218..d71e584ca8 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py @@ -78,6 +78,7 @@ def gen_wsgi(environ, start_response): def error_wsgi(environ, start_response): assert isinstance(environ, dict) + exc_info = None try: raise ValueError except ValueError: @@ -286,22 +287,26 @@ def test_wsgi_metrics(self): self.assertTrue(number_data_point_seen and histogram_data_point_seen) def test_nonstandard_http_method(self): - self.environ["REQUEST_METHOD"]= "NONSTANDARD" + self.environ["REQUEST_METHOD"] = "NONSTANDARD" app = otel_wsgi.OpenTelemetryMiddleware(simple_wsgi) response = app(self.environ, self.start_response) - self.validate_response(response, span_name="UNKNOWN /", http_method="UNKNOWN") + self.validate_response( + response, span_name="UNKNOWN /", http_method="UNKNOWN" + ) @mock.patch.dict( - "os.environ", + "os.environ", { OTEL_PYTHON_INSTRUMENTATION_HTTP_CAPTURE_ALL_METHODS: "1", }, ) def test_nonstandard_http_method_allowed(self): - self.environ["REQUEST_METHOD"]= "NONSTANDARD" + self.environ["REQUEST_METHOD"] = "NONSTANDARD" app = otel_wsgi.OpenTelemetryMiddleware(simple_wsgi) response = app(self.environ, self.start_response) - self.validate_response(response, span_name="NONSTANDARD /", http_method="NONSTANDARD") + self.validate_response( + response, span_name="NONSTANDARD /", http_method="NONSTANDARD" + ) def test_default_span_name_missing_path_info(self): """Test that default span_names with missing path info.""" diff --git a/opentelemetry-contrib-instrumentations/pyproject.toml b/opentelemetry-contrib-instrumentations/pyproject.toml index feb229e384..b4e1db321e 100644 --- a/opentelemetry-contrib-instrumentations/pyproject.toml +++ b/opentelemetry-contrib-instrumentations/pyproject.toml @@ -29,50 +29,51 @@ classifiers = [ "Programming Language :: Python :: 3.11", ] dependencies = [ - "opentelemetry-instrumentation-aio-pika==0.42b0.dev", - "opentelemetry-instrumentation-aiohttp-client==0.42b0.dev", - "opentelemetry-instrumentation-aiopg==0.42b0.dev", - "opentelemetry-instrumentation-asgi==0.42b0.dev", - "opentelemetry-instrumentation-asyncpg==0.42b0.dev", - "opentelemetry-instrumentation-aws-lambda==0.42b0.dev", - "opentelemetry-instrumentation-boto==0.42b0.dev", - "opentelemetry-instrumentation-boto3sqs==0.42b0.dev", - "opentelemetry-instrumentation-botocore==0.42b0.dev", - "opentelemetry-instrumentation-cassandra==0.42b0.dev", - "opentelemetry-instrumentation-celery==0.42b0.dev", - "opentelemetry-instrumentation-confluent-kafka==0.42b0.dev", - "opentelemetry-instrumentation-dbapi==0.42b0.dev", - "opentelemetry-instrumentation-django==0.42b0.dev", - "opentelemetry-instrumentation-elasticsearch==0.42b0.dev", - "opentelemetry-instrumentation-falcon==0.42b0.dev", - "opentelemetry-instrumentation-fastapi==0.42b0.dev", - "opentelemetry-instrumentation-flask==0.42b0.dev", - "opentelemetry-instrumentation-grpc==0.42b0.dev", - "opentelemetry-instrumentation-httpx==0.42b0.dev", - "opentelemetry-instrumentation-jinja2==0.42b0.dev", - "opentelemetry-instrumentation-kafka-python==0.42b0.dev", - "opentelemetry-instrumentation-logging==0.42b0.dev", - "opentelemetry-instrumentation-mysql==0.42b0.dev", - "opentelemetry-instrumentation-mysqlclient==0.42b0.dev", - "opentelemetry-instrumentation-pika==0.42b0.dev", - "opentelemetry-instrumentation-psycopg2==0.42b0.dev", - "opentelemetry-instrumentation-pymemcache==0.42b0.dev", - "opentelemetry-instrumentation-pymongo==0.42b0.dev", - "opentelemetry-instrumentation-pymysql==0.42b0.dev", - "opentelemetry-instrumentation-pyramid==0.42b0.dev", - "opentelemetry-instrumentation-redis==0.42b0.dev", - "opentelemetry-instrumentation-remoulade==0.42b0.dev", - "opentelemetry-instrumentation-requests==0.42b0.dev", - "opentelemetry-instrumentation-sklearn==0.42b0.dev", - "opentelemetry-instrumentation-sqlalchemy==0.42b0.dev", - "opentelemetry-instrumentation-sqlite3==0.42b0.dev", - "opentelemetry-instrumentation-starlette==0.42b0.dev", - "opentelemetry-instrumentation-system-metrics==0.42b0.dev", - "opentelemetry-instrumentation-tornado==0.42b0.dev", - "opentelemetry-instrumentation-tortoiseorm==0.42b0.dev", - "opentelemetry-instrumentation-urllib==0.42b0.dev", - "opentelemetry-instrumentation-urllib3==0.42b0.dev", - "opentelemetry-instrumentation-wsgi==0.42b0.dev", + "opentelemetry-instrumentation-aio-pika==0.43b0.dev", + "opentelemetry-instrumentation-aiohttp-client==0.43b0.dev", + "opentelemetry-instrumentation-aiohttp-server==0.43b0.dev", + "opentelemetry-instrumentation-aiopg==0.43b0.dev", + "opentelemetry-instrumentation-asgi==0.43b0.dev", + "opentelemetry-instrumentation-asyncpg==0.43b0.dev", + "opentelemetry-instrumentation-aws-lambda==0.43b0.dev", + "opentelemetry-instrumentation-boto==0.43b0.dev", + "opentelemetry-instrumentation-boto3sqs==0.43b0.dev", + "opentelemetry-instrumentation-botocore==0.43b0.dev", + "opentelemetry-instrumentation-cassandra==0.43b0.dev", + "opentelemetry-instrumentation-celery==0.43b0.dev", + "opentelemetry-instrumentation-confluent-kafka==0.43b0.dev", + "opentelemetry-instrumentation-dbapi==0.43b0.dev", + "opentelemetry-instrumentation-django==0.43b0.dev", + "opentelemetry-instrumentation-elasticsearch==0.43b0.dev", + "opentelemetry-instrumentation-falcon==0.43b0.dev", + "opentelemetry-instrumentation-fastapi==0.43b0.dev", + "opentelemetry-instrumentation-flask==0.43b0.dev", + "opentelemetry-instrumentation-grpc==0.43b0.dev", + "opentelemetry-instrumentation-httpx==0.43b0.dev", + "opentelemetry-instrumentation-jinja2==0.43b0.dev", + "opentelemetry-instrumentation-kafka-python==0.43b0.dev", + "opentelemetry-instrumentation-logging==0.43b0.dev", + "opentelemetry-instrumentation-mysql==0.43b0.dev", + "opentelemetry-instrumentation-mysqlclient==0.43b0.dev", + "opentelemetry-instrumentation-pika==0.43b0.dev", + "opentelemetry-instrumentation-psycopg2==0.43b0.dev", + "opentelemetry-instrumentation-pymemcache==0.43b0.dev", + "opentelemetry-instrumentation-pymongo==0.43b0.dev", + "opentelemetry-instrumentation-pymysql==0.43b0.dev", + "opentelemetry-instrumentation-pyramid==0.43b0.dev", + "opentelemetry-instrumentation-redis==0.43b0.dev", + "opentelemetry-instrumentation-remoulade==0.43b0.dev", + "opentelemetry-instrumentation-requests==0.43b0.dev", + "opentelemetry-instrumentation-sklearn==0.43b0.dev", + "opentelemetry-instrumentation-sqlalchemy==0.43b0.dev", + "opentelemetry-instrumentation-sqlite3==0.43b0.dev", + "opentelemetry-instrumentation-starlette==0.43b0.dev", + "opentelemetry-instrumentation-system-metrics==0.43b0.dev", + "opentelemetry-instrumentation-tornado==0.43b0.dev", + "opentelemetry-instrumentation-tortoiseorm==0.43b0.dev", + "opentelemetry-instrumentation-urllib==0.43b0.dev", + "opentelemetry-instrumentation-urllib3==0.43b0.dev", + "opentelemetry-instrumentation-wsgi==0.43b0.dev", ] [project.optional-dependencies] diff --git a/opentelemetry-contrib-instrumentations/src/opentelemetry/contrib-instrumentations/version.py b/opentelemetry-contrib-instrumentations/src/opentelemetry/contrib-instrumentations/version.py index c2996671d6..2e4aa8c751 100644 --- a/opentelemetry-contrib-instrumentations/src/opentelemetry/contrib-instrumentations/version.py +++ b/opentelemetry-contrib-instrumentations/src/opentelemetry/contrib-instrumentations/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/opentelemetry-distro/pyproject.toml b/opentelemetry-distro/pyproject.toml index 9898884319..6d5e2228bf 100644 --- a/opentelemetry-distro/pyproject.toml +++ b/opentelemetry-distro/pyproject.toml @@ -24,13 +24,13 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.12", - "opentelemetry-instrumentation == 0.42b0.dev", + "opentelemetry-instrumentation == 0.43b0.dev", "opentelemetry-sdk ~= 1.13", ] [project.optional-dependencies] otlp = [ - "opentelemetry-exporter-otlp == 1.21.0.dev", + "opentelemetry-exporter-otlp == 1.22.0.dev", ] test = [] diff --git a/opentelemetry-distro/src/opentelemetry/distro/version.py b/opentelemetry-distro/src/opentelemetry/distro/version.py index c2996671d6..2e4aa8c751 100644 --- a/opentelemetry-distro/src/opentelemetry/distro/version.py +++ b/opentelemetry-distro/src/opentelemetry/distro/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py index 6fa36f0463..afd5a045d9 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py @@ -77,7 +77,7 @@ def _pip_check(): ) as check_pipe: pip_check = check_pipe.communicate()[0].decode() pip_check_lower = pip_check.lower() - for package_tup in libraries.values(): + for package_tup in libraries: for package in package_tup: if package.lower() in pip_check_lower: raise RuntimeError(f"Dependency conflict found: {pip_check}") @@ -102,15 +102,12 @@ def _is_installed(req): def _find_installed_libraries(): - libs = default_instrumentations[:] - libs.extend( - [ - v["instrumentation"] - for _, v in libraries.items() - if _is_installed(v["library"]) - ] - ) - return libs + for lib in default_instrumentations: + yield lib + + for lib in libraries: + if _is_installed(lib["library"]): + yield lib["instrumentation"] def _run_requirements(): diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py index 49b044a2a3..dc386cf9cc 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py @@ -15,177 +15,181 @@ # DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM INSTRUMENTATION PACKAGES. # RUN `python scripts/generate_instrumentation_bootstrap.py` TO REGENERATE. -libraries = { - "aio_pika": { +libraries = [ + { "library": "aio_pika >= 7.2.0, < 10.0.0", - "instrumentation": "opentelemetry-instrumentation-aio-pika==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-aio-pika==0.43b0.dev", }, - "aiohttp": { + { "library": "aiohttp ~= 3.0", - "instrumentation": "opentelemetry-instrumentation-aiohttp-client==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-aiohttp-client==0.43b0.dev", }, - "aiopg": { + { + "library": "aiohttp ~= 3.0", + "instrumentation": "opentelemetry-instrumentation-aiohttp-server==0.43b0.dev", + }, + { "library": "aiopg >= 0.13.0, < 2.0.0", - "instrumentation": "opentelemetry-instrumentation-aiopg==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-aiopg==0.43b0.dev", }, - "asgiref": { + { "library": "asgiref ~= 3.0", - "instrumentation": "opentelemetry-instrumentation-asgi==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-asgi==0.43b0.dev", }, - "asyncpg": { + { "library": "asyncpg >= 0.12.0", - "instrumentation": "opentelemetry-instrumentation-asyncpg==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-asyncpg==0.43b0.dev", }, - "boto": { + { "library": "boto~=2.0", - "instrumentation": "opentelemetry-instrumentation-boto==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-boto==0.43b0.dev", }, - "boto3": { + { "library": "boto3 ~= 1.0", - "instrumentation": "opentelemetry-instrumentation-boto3sqs==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-boto3sqs==0.43b0.dev", }, - "botocore": { + { "library": "botocore ~= 1.0", - "instrumentation": "opentelemetry-instrumentation-botocore==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-botocore==0.43b0.dev", }, - "cassandra-driver": { + { "library": "cassandra-driver ~= 3.25", - "instrumentation": "opentelemetry-instrumentation-cassandra==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-cassandra==0.43b0.dev", }, - "scylla-driver": { + { "library": "scylla-driver ~= 3.25", - "instrumentation": "opentelemetry-instrumentation-cassandra==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-cassandra==0.43b0.dev", }, - "celery": { + { "library": "celery >= 4.0, < 6.0", - "instrumentation": "opentelemetry-instrumentation-celery==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-celery==0.43b0.dev", }, - "confluent-kafka": { + { "library": "confluent-kafka >= 1.8.2, <= 2.2.0", - "instrumentation": "opentelemetry-instrumentation-confluent-kafka==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-confluent-kafka==0.43b0.dev", }, - "django": { + { "library": "django >= 1.10", - "instrumentation": "opentelemetry-instrumentation-django==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-django==0.43b0.dev", }, - "elasticsearch": { + { "library": "elasticsearch >= 2.0", - "instrumentation": "opentelemetry-instrumentation-elasticsearch==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-elasticsearch==0.43b0.dev", }, - "falcon": { + { "library": "falcon >= 1.4.1, < 4.0.0", - "instrumentation": "opentelemetry-instrumentation-falcon==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-falcon==0.43b0.dev", }, - "fastapi": { + { "library": "fastapi ~= 0.58", - "instrumentation": "opentelemetry-instrumentation-fastapi==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-fastapi==0.43b0.dev", }, - "flask": { + { "library": "flask >= 1.0, < 3.0", - "instrumentation": "opentelemetry-instrumentation-flask==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-flask==0.43b0.dev", }, - "werkzeug": { + { "library": "werkzeug < 3.0.0", - "instrumentation": "opentelemetry-instrumentation-flask==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-flask==0.43b0.dev", }, - "grpcio": { + { "library": "grpcio ~= 1.27", - "instrumentation": "opentelemetry-instrumentation-grpc==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-grpc==0.43b0.dev", }, - "httpx": { + { "library": "httpx >= 0.18.0", - "instrumentation": "opentelemetry-instrumentation-httpx==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-httpx==0.43b0.dev", }, - "jinja2": { + { "library": "jinja2 >= 2.7, < 4.0", - "instrumentation": "opentelemetry-instrumentation-jinja2==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-jinja2==0.43b0.dev", }, - "kafka-python": { + { "library": "kafka-python >= 2.0", - "instrumentation": "opentelemetry-instrumentation-kafka-python==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-kafka-python==0.43b0.dev", }, - "mysql-connector-python": { + { "library": "mysql-connector-python ~= 8.0", - "instrumentation": "opentelemetry-instrumentation-mysql==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-mysql==0.43b0.dev", }, - "mysqlclient": { + { "library": "mysqlclient < 3", - "instrumentation": "opentelemetry-instrumentation-mysqlclient==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-mysqlclient==0.43b0.dev", }, - "pika": { + { "library": "pika >= 0.12.0", - "instrumentation": "opentelemetry-instrumentation-pika==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-pika==0.43b0.dev", }, - "psycopg2": { + { "library": "psycopg2 >= 2.7.3.1", - "instrumentation": "opentelemetry-instrumentation-psycopg2==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-psycopg2==0.43b0.dev", }, - "pymemcache": { + { "library": "pymemcache >= 1.3.5, < 5", - "instrumentation": "opentelemetry-instrumentation-pymemcache==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-pymemcache==0.43b0.dev", }, - "pymongo": { + { "library": "pymongo >= 3.1, < 5.0", - "instrumentation": "opentelemetry-instrumentation-pymongo==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-pymongo==0.43b0.dev", }, - "PyMySQL": { + { "library": "PyMySQL < 2", - "instrumentation": "opentelemetry-instrumentation-pymysql==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-pymysql==0.43b0.dev", }, - "pyramid": { + { "library": "pyramid >= 1.7", - "instrumentation": "opentelemetry-instrumentation-pyramid==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-pyramid==0.43b0.dev", }, - "redis": { + { "library": "redis >= 2.6", - "instrumentation": "opentelemetry-instrumentation-redis==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-redis==0.43b0.dev", }, - "remoulade": { + { "library": "remoulade >= 0.50", - "instrumentation": "opentelemetry-instrumentation-remoulade==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-remoulade==0.43b0.dev", }, - "requests": { + { "library": "requests ~= 2.0", - "instrumentation": "opentelemetry-instrumentation-requests==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-requests==0.43b0.dev", }, - "scikit-learn": { + { "library": "scikit-learn ~= 0.24.0", - "instrumentation": "opentelemetry-instrumentation-sklearn==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-sklearn==0.43b0.dev", }, - "sqlalchemy": { + { "library": "sqlalchemy", - "instrumentation": "opentelemetry-instrumentation-sqlalchemy==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-sqlalchemy==0.43b0.dev", }, - "starlette": { + { "library": "starlette ~= 0.13.0", - "instrumentation": "opentelemetry-instrumentation-starlette==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-starlette==0.43b0.dev", }, - "psutil": { + { "library": "psutil >= 5", - "instrumentation": "opentelemetry-instrumentation-system-metrics==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-system-metrics==0.43b0.dev", }, - "tornado": { + { "library": "tornado >= 5.1.1", - "instrumentation": "opentelemetry-instrumentation-tornado==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-tornado==0.43b0.dev", }, - "tortoise-orm": { + { "library": "tortoise-orm >= 0.17.0", - "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.43b0.dev", }, - "pydantic": { + { "library": "pydantic >= 1.10.2", - "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.43b0.dev", }, - "urllib3": { + { "library": "urllib3 >= 1.0.0, < 3.0.0", - "instrumentation": "opentelemetry-instrumentation-urllib3==0.42b0.dev", + "instrumentation": "opentelemetry-instrumentation-urllib3==0.43b0.dev", }, -} +] default_instrumentations = [ - "opentelemetry-instrumentation-aws-lambda==0.42b0.dev", - "opentelemetry-instrumentation-dbapi==0.42b0.dev", - "opentelemetry-instrumentation-logging==0.42b0.dev", - "opentelemetry-instrumentation-sqlite3==0.42b0.dev", - "opentelemetry-instrumentation-urllib==0.42b0.dev", - "opentelemetry-instrumentation-wsgi==0.42b0.dev", + "opentelemetry-instrumentation-aws-lambda==0.43b0.dev", + "opentelemetry-instrumentation-dbapi==0.43b0.dev", + "opentelemetry-instrumentation-logging==0.43b0.dev", + "opentelemetry-instrumentation-sqlite3==0.43b0.dev", + "opentelemetry-instrumentation-urllib==0.43b0.dev", + "opentelemetry-instrumentation-wsgi==0.43b0.dev", ] diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py index 7f05e7f30a..6c6f86fd51 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py @@ -25,6 +25,9 @@ DependencyConflict, get_dependency_conflicts, ) +from opentelemetry.instrumentation.utils import ( + _OpenTelemetrySemanticConventionStability, +) _LOG = getLogger(__name__) @@ -105,6 +108,9 @@ def instrument(self, **kwargs): _LOG.error(conflict) return None + # initialize semantic conventions opt-in if needed + _OpenTelemetrySemanticConventionStability._initialize() + result = self._instrument( # pylint: disable=assignment-from-no-return **kwargs ) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py index 35a55a1279..71a0087149 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py @@ -12,7 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os +import threading import urllib.parse +from enum import Enum from re import escape, sub from typing import Dict, Sequence @@ -152,3 +155,61 @@ def _python_path_without_directory(python_path, directory, path_separator): "", python_path, ) + + +_OTEL_SEMCONV_STABILITY_OPT_IN_KEY = "OTEL_SEMCONV_STABILITY_OPT_IN" + + +class _OpenTelemetryStabilitySignalType: + HTTP = "http" + + +class _OpenTelemetryStabilityMode(Enum): + # http - emit the new, stable HTTP and networking conventions ONLY + HTTP = "http" + # http/dup - emit both the old and the stable HTTP and networking conventions + HTTP_DUP = "http/dup" + # default - continue emitting old experimental HTTP and networking conventions + DEFAULT = "default" + + +class _OpenTelemetrySemanticConventionStability: + _initialized = False + _lock = threading.Lock() + _OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING = {} + + @classmethod + def _initialize(cls): + with _OpenTelemetrySemanticConventionStability._lock: + if not _OpenTelemetrySemanticConventionStability._initialized: + # Users can pass in comma delimited string for opt-in options + # Only values for http stability are supported for now + opt_in = os.environ.get(_OTEL_SEMCONV_STABILITY_OPT_IN_KEY, "") + opt_in_list = [] + if opt_in: + opt_in_list = [s.strip() for s in opt_in.split(",")] + http_opt_in = _OpenTelemetryStabilityMode.DEFAULT + if opt_in_list: + # Process http opt-in + # http/dup takes priority over http + if ( + _OpenTelemetryStabilityMode.HTTP_DUP.value + in opt_in_list + ): + http_opt_in = _OpenTelemetryStabilityMode.HTTP_DUP + elif _OpenTelemetryStabilityMode.HTTP.value in opt_in_list: + http_opt_in = _OpenTelemetryStabilityMode.HTTP + _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING[ + _OpenTelemetryStabilitySignalType.HTTP + ] = http_opt_in + _OpenTelemetrySemanticConventionStability._initialized = True + + @classmethod + def _get_opentelemetry_stability_opt_in( + cls, + signal_type: _OpenTelemetryStabilitySignalType, + ) -> _OpenTelemetryStabilityMode: + with _OpenTelemetrySemanticConventionStability._lock: + return _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING.get( + signal_type, _OpenTelemetryStabilityMode.DEFAULT + ) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/version.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/version.py index c2996671d6..2e4aa8c751 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/version.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/opentelemetry-instrumentation/tests/test_bootstrap.py b/opentelemetry-instrumentation/tests/test_bootstrap.py index 416aad0667..bbe2f5623b 100644 --- a/opentelemetry-instrumentation/tests/test_bootstrap.py +++ b/opentelemetry-instrumentation/tests/test_bootstrap.py @@ -36,7 +36,7 @@ class TestBootstrap(TestCase): @classmethod def setUpClass(cls): cls.installed_libraries = sample_packages( - [lib["instrumentation"] for lib in libraries.values()], 0.6 + [lib["instrumentation"] for lib in libraries], 0.6 ) # treat 50% of sampled packages as pre-installed diff --git a/propagator/opentelemetry-propagator-ot-trace/src/opentelemetry/propagators/ot_trace/version.py b/propagator/opentelemetry-propagator-ot-trace/src/opentelemetry/propagators/ot_trace/version.py index c2996671d6..2e4aa8c751 100644 --- a/propagator/opentelemetry-propagator-ot-trace/src/opentelemetry/propagators/ot_trace/version.py +++ b/propagator/opentelemetry-propagator-ot-trace/src/opentelemetry/propagators/ot_trace/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/app_service.py b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/app_service.py index 823aac30fd..1e853acc57 100644 --- a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/app_service.py +++ b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/app_service.py @@ -14,8 +14,12 @@ from os import environ -from opentelemetry.sdk.resources import ResourceDetector, Resource -from opentelemetry.semconv.resource import ResourceAttributes, CloudPlatformValues, CloudProviderValues +from opentelemetry.sdk.resources import Resource, ResourceDetector +from opentelemetry.semconv.resource import ( + CloudPlatformValues, + CloudProviderValues, + ResourceAttributes, +) _AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE = "azure.app.service.stamp" _REGION_NAME = "REGION_NAME" @@ -36,18 +40,25 @@ _AZURE_APP_SERVICE_STAMP_RESOURCE_ATTRIBUTE: _WEBSITE_HOME_STAMPNAME, } + class AzureAppServiceResourceDetector(ResourceDetector): def detect(self) -> Resource: attributes = {} website_site_name = environ.get(_WEBSITE_SITE_NAME) if website_site_name: attributes[ResourceAttributes.SERVICE_NAME] = website_site_name - attributes[ResourceAttributes.CLOUD_PROVIDER] = CloudProviderValues.AZURE.value - attributes[ResourceAttributes.CLOUD_PLATFORM] = CloudPlatformValues.AZURE_APP_SERVICE.value + attributes[ + ResourceAttributes.CLOUD_PROVIDER + ] = CloudProviderValues.AZURE.value + attributes[ + ResourceAttributes.CLOUD_PLATFORM + ] = CloudPlatformValues.AZURE_APP_SERVICE.value azure_resource_uri = _get_azure_resource_uri(website_site_name) if azure_resource_uri: - attributes[ResourceAttributes.CLOUD_RESOURCE_ID] = azure_resource_uri + attributes[ + ResourceAttributes.CLOUD_RESOURCE_ID + ] = azure_resource_uri for (key, env_var) in _APP_SERVICE_ATTRIBUTE_ENV_VARS.items(): value = environ.get(env_var) if value: @@ -55,19 +66,16 @@ def detect(self) -> Resource: return Resource(attributes) + def _get_azure_resource_uri(website_site_name): website_resource_group = environ.get(_WEBSITE_RESOURCE_GROUP) website_owner_name = environ.get(_WEBSITE_OWNER_NAME) subscription_id = website_owner_name - if website_owner_name and '+' in website_owner_name: - subscription_id = website_owner_name[0:website_owner_name.index('+')] + if website_owner_name and "+" in website_owner_name: + subscription_id = website_owner_name[0 : website_owner_name.index("+")] if not (website_resource_group and subscription_id): return None - return "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s" % ( - subscription_id, - website_resource_group, - website_site_name, - ) + return f"/subscriptions/{subscription_id}/resourceGroups/{website_resource_group}/providers/Microsoft.Web/sites/{website_site_name}" diff --git a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py index 11b04ebff3..fd14b482ed 100644 --- a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py +++ b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py @@ -14,18 +14,16 @@ from json import loads from logging import getLogger -from os import environ -from urllib.request import Request, urlopen from urllib.error import URLError +from urllib.request import Request, urlopen -from opentelemetry.sdk.resources import ResourceDetector, Resource +from opentelemetry.sdk.resources import Resource, ResourceDetector from opentelemetry.semconv.resource import ( - ResourceAttributes, CloudPlatformValues, CloudProviderValues, + ResourceAttributes, ) - # TODO: Remove when cloud resource id is no longer missing in Resource Attributes _AZURE_VM_METADATA_ENDPOINT = "http://169.254.169.254/metadata/instance/compute?api-version=2021-12-13&format=json" _AZURE_VM_SCALE_SET_NAME_ATTRIBUTE = "azure.vm.scaleset.name" @@ -47,32 +45,42 @@ ResourceAttributes.SERVICE_INSTANCE_ID, ] + class AzureVMResourceDetector(ResourceDetector): # pylint: disable=no-self-use def detect(self) -> "Resource": attributes = {} - metadata_json = _AzureVMMetadataServiceRequestor().get_azure_vm_metadata() + metadata_json = ( + _AzureVMMetadataServiceRequestor().get_azure_vm_metadata() + ) if not metadata_json: return Resource(attributes) for attribute_key in EXPECTED_AZURE_AMS_ATTRIBUTES: - attributes[attribute_key] = _AzureVMMetadataServiceRequestor().get_attribute_from_metadata(metadata_json, attribute_key) + attributes[ + attribute_key + ] = _AzureVMMetadataServiceRequestor().get_attribute_from_metadata( + metadata_json, attribute_key + ) return Resource(attributes) + class _AzureVMMetadataServiceRequestor: - def get_azure_vm_metadata(self): + def get_azure_vm_metadata(self): # pylint: disable=no-self-use request = Request(_AZURE_VM_METADATA_ENDPOINT) request.add_header("Metadata", "True") try: - response = urlopen(request).read() - return loads(response) + with urlopen(request).read() as response: + return loads(response) except URLError: # Not on Azure VM return None - except Exception as e: + except Exception as e: # pylint: disable=broad-except,invalid-name _logger.exception("Failed to receive Azure VM metadata: %s", e) return None - def get_attribute_from_metadata(self, metadata_json, attribute_key): + def get_attribute_from_metadata( + self, metadata_json, attribute_key + ): # pylint: disable=no-self-use ams_value = "" if attribute_key == _AZURE_VM_SCALE_SET_NAME_ATTRIBUTE: ams_value = metadata_json["vmScaleSetName"] @@ -86,8 +94,10 @@ def get_attribute_from_metadata(self, metadata_json, attribute_key): ams_value = metadata_json["location"] elif attribute_key == ResourceAttributes.CLOUD_RESOURCE_ID: ams_value = metadata_json["resourceId"] - elif attribute_key == ResourceAttributes.HOST_ID or \ - attribute_key == ResourceAttributes.SERVICE_INSTANCE_ID: + elif attribute_key in ( + ResourceAttributes.HOST_ID, + ResourceAttributes.SERVICE_INSTANCE_ID, + ): ams_value = metadata_json["vmId"] elif attribute_key == ResourceAttributes.HOST_NAME: ams_value = metadata_json["name"] diff --git a/resource/opentelemetry-resource-detector-azure/tests/test_app_service.py b/resource/opentelemetry-resource-detector-azure/tests/test_app_service.py index f5d6a0dd3d..c5d2396dab 100644 --- a/resource/opentelemetry-resource-detector-azure/tests/test_app_service.py +++ b/resource/opentelemetry-resource-detector-azure/tests/test_app_service.py @@ -14,6 +14,7 @@ import unittest from unittest.mock import patch +# pylint: disable=no-name-in-module from opentelemetry.resource.detector.azure.app_service import ( AzureAppServiceResourceDetector, ) @@ -28,17 +29,22 @@ TEST_WEBSITE_RESOURCE_GROUP = "TEST_WEBSITE_RESOURCE_GROUP" TEST_WEBSITE_OWNER_NAME = "TEST_WEBSITE_OWNER_NAME" + class TestAzureAppServiceResourceDetector(unittest.TestCase): - @patch.dict("os.environ", { - "WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME, - "REGION_NAME": TEST_REGION_NAME, - "WEBSITE_SLOT_NAME": TEST_WEBSITE_SLOT_NAME, - "WEBSITE_HOSTNAME": TEST_WEBSITE_HOSTNAME, - "WEBSITE_INSTANCE_ID": TEST_WEBSITE_INSTANCE_ID, - "WEBSITE_HOME_STAMPNAME": TEST_WEBSITE_HOME_STAMPNAME, - "WEBSITE_RESOURCE_GROUP": TEST_WEBSITE_RESOURCE_GROUP, - "WEBSITE_OWNER_NAME": TEST_WEBSITE_OWNER_NAME, - }, clear=True) + @patch.dict( + "os.environ", + { + "WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME, + "REGION_NAME": TEST_REGION_NAME, + "WEBSITE_SLOT_NAME": TEST_WEBSITE_SLOT_NAME, + "WEBSITE_HOSTNAME": TEST_WEBSITE_HOSTNAME, + "WEBSITE_INSTANCE_ID": TEST_WEBSITE_INSTANCE_ID, + "WEBSITE_HOME_STAMPNAME": TEST_WEBSITE_HOME_STAMPNAME, + "WEBSITE_RESOURCE_GROUP": TEST_WEBSITE_RESOURCE_GROUP, + "WEBSITE_OWNER_NAME": TEST_WEBSITE_OWNER_NAME, + }, + clear=True, + ) def test_on_app_service(self): resource = AzureAppServiceResourceDetector().detect() attributes = resource.attributes @@ -46,24 +52,36 @@ def test_on_app_service(self): self.assertEqual(attributes["cloud.provider"], "azure") self.assertEqual(attributes["cloud.platform"], "azure_app_service") - self.assertEqual(attributes["cloud.resource_id"], \ - f"/subscriptions/{TEST_WEBSITE_OWNER_NAME}/resourceGroups/{TEST_WEBSITE_RESOURCE_GROUP}/providers/Microsoft.Web/sites/{TEST_WEBSITE_SITE_NAME}") + self.assertEqual( + attributes["cloud.resource_id"], + f"/subscriptions/{TEST_WEBSITE_OWNER_NAME}/resourceGroups/{TEST_WEBSITE_RESOURCE_GROUP}/providers/Microsoft.Web/sites/{TEST_WEBSITE_SITE_NAME}", + ) self.assertEqual(attributes["cloud.region"], TEST_REGION_NAME) - self.assertEqual(attributes["deployment.environment"], TEST_WEBSITE_SLOT_NAME) + self.assertEqual( + attributes["deployment.environment"], TEST_WEBSITE_SLOT_NAME + ) self.assertEqual(attributes["host.id"], TEST_WEBSITE_HOSTNAME) - self.assertEqual(attributes["service.instance.id"], TEST_WEBSITE_INSTANCE_ID) - self.assertEqual(attributes["azure.app.service.stamp"], TEST_WEBSITE_HOME_STAMPNAME) + self.assertEqual( + attributes["service.instance.id"], TEST_WEBSITE_INSTANCE_ID + ) + self.assertEqual( + attributes["azure.app.service.stamp"], TEST_WEBSITE_HOME_STAMPNAME + ) - @patch.dict("os.environ", { - "WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME, - "REGION_NAME": TEST_REGION_NAME, - "WEBSITE_SLOT_NAME": TEST_WEBSITE_SLOT_NAME, - "WEBSITE_HOSTNAME": TEST_WEBSITE_HOSTNAME, - "WEBSITE_INSTANCE_ID": TEST_WEBSITE_INSTANCE_ID, - "WEBSITE_HOME_STAMPNAME": TEST_WEBSITE_HOME_STAMPNAME, - "WEBSITE_OWNER_NAME": TEST_WEBSITE_OWNER_NAME, - }, clear=True) + @patch.dict( + "os.environ", + { + "WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME, + "REGION_NAME": TEST_REGION_NAME, + "WEBSITE_SLOT_NAME": TEST_WEBSITE_SLOT_NAME, + "WEBSITE_HOSTNAME": TEST_WEBSITE_HOSTNAME, + "WEBSITE_INSTANCE_ID": TEST_WEBSITE_INSTANCE_ID, + "WEBSITE_HOME_STAMPNAME": TEST_WEBSITE_HOME_STAMPNAME, + "WEBSITE_OWNER_NAME": TEST_WEBSITE_OWNER_NAME, + }, + clear=True, + ) def test_on_app_service_no_resource_group(self): resource = AzureAppServiceResourceDetector().detect() attributes = resource.attributes @@ -74,20 +92,30 @@ def test_on_app_service_no_resource_group(self): self.assertTrue("cloud.resource_id" not in attributes) self.assertEqual(attributes["cloud.region"], TEST_REGION_NAME) - self.assertEqual(attributes["deployment.environment"], TEST_WEBSITE_SLOT_NAME) + self.assertEqual( + attributes["deployment.environment"], TEST_WEBSITE_SLOT_NAME + ) self.assertEqual(attributes["host.id"], TEST_WEBSITE_HOSTNAME) - self.assertEqual(attributes["service.instance.id"], TEST_WEBSITE_INSTANCE_ID) - self.assertEqual(attributes["azure.app.service.stamp"], TEST_WEBSITE_HOME_STAMPNAME) + self.assertEqual( + attributes["service.instance.id"], TEST_WEBSITE_INSTANCE_ID + ) + self.assertEqual( + attributes["azure.app.service.stamp"], TEST_WEBSITE_HOME_STAMPNAME + ) - @patch.dict("os.environ", { - "WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME, - "REGION_NAME": TEST_REGION_NAME, - "WEBSITE_SLOT_NAME": TEST_WEBSITE_SLOT_NAME, - "WEBSITE_HOSTNAME": TEST_WEBSITE_HOSTNAME, - "WEBSITE_INSTANCE_ID": TEST_WEBSITE_INSTANCE_ID, - "WEBSITE_HOME_STAMPNAME": TEST_WEBSITE_HOME_STAMPNAME, - "WEBSITE_OWNER_NAME": TEST_WEBSITE_OWNER_NAME, - }, clear=True) + @patch.dict( + "os.environ", + { + "WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME, + "REGION_NAME": TEST_REGION_NAME, + "WEBSITE_SLOT_NAME": TEST_WEBSITE_SLOT_NAME, + "WEBSITE_HOSTNAME": TEST_WEBSITE_HOSTNAME, + "WEBSITE_INSTANCE_ID": TEST_WEBSITE_INSTANCE_ID, + "WEBSITE_HOME_STAMPNAME": TEST_WEBSITE_HOME_STAMPNAME, + "WEBSITE_OWNER_NAME": TEST_WEBSITE_OWNER_NAME, + }, + clear=True, + ) def test_on_app_service_no_owner(self): resource = AzureAppServiceResourceDetector().detect() attributes = resource.attributes @@ -98,19 +126,29 @@ def test_on_app_service_no_owner(self): self.assertTrue("cloud.resource_id" not in attributes) self.assertEqual(attributes["cloud.region"], TEST_REGION_NAME) - self.assertEqual(attributes["deployment.environment"], TEST_WEBSITE_SLOT_NAME) + self.assertEqual( + attributes["deployment.environment"], TEST_WEBSITE_SLOT_NAME + ) self.assertEqual(attributes["host.id"], TEST_WEBSITE_HOSTNAME) - self.assertEqual(attributes["service.instance.id"], TEST_WEBSITE_INSTANCE_ID) - self.assertEqual(attributes["azure.app.service.stamp"], TEST_WEBSITE_HOME_STAMPNAME) + self.assertEqual( + attributes["service.instance.id"], TEST_WEBSITE_INSTANCE_ID + ) + self.assertEqual( + attributes["azure.app.service.stamp"], TEST_WEBSITE_HOME_STAMPNAME + ) - @patch.dict("os.environ", { - "REGION_NAME": TEST_REGION_NAME, - "WEBSITE_SLOT_NAME": TEST_WEBSITE_SLOT_NAME, - "WEBSITE_HOSTNAME": TEST_WEBSITE_HOSTNAME, - "WEBSITE_INSTANCE_ID": TEST_WEBSITE_INSTANCE_ID, - "WEBSITE_HOME_STAMPNAME": TEST_WEBSITE_HOME_STAMPNAME, - "WEBSITE_OWNER_NAME": TEST_WEBSITE_OWNER_NAME, - }, clear=True) + @patch.dict( + "os.environ", + { + "REGION_NAME": TEST_REGION_NAME, + "WEBSITE_SLOT_NAME": TEST_WEBSITE_SLOT_NAME, + "WEBSITE_HOSTNAME": TEST_WEBSITE_HOSTNAME, + "WEBSITE_INSTANCE_ID": TEST_WEBSITE_INSTANCE_ID, + "WEBSITE_HOME_STAMPNAME": TEST_WEBSITE_HOME_STAMPNAME, + "WEBSITE_OWNER_NAME": TEST_WEBSITE_OWNER_NAME, + }, + clear=True, + ) def test_off_app_service(self): resource = AzureAppServiceResourceDetector().detect() self.assertEqual(resource.attributes, {}) diff --git a/resource/opentelemetry-resource-detector-azure/tests/test_vm.py b/resource/opentelemetry-resource-detector-azure/tests/test_vm.py index 0531fa02b1..13ec225c82 100644 --- a/resource/opentelemetry-resource-detector-azure/tests/test_vm.py +++ b/resource/opentelemetry-resource-detector-azure/tests/test_vm.py @@ -12,12 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. import unittest -from unittest.mock import patch, Mock +from unittest.mock import Mock, patch -from opentelemetry.semconv.resource import ResourceAttributes -from opentelemetry.resource.detector.azure.vm import ( - AzureVMResourceDetector, -) +# pylint: disable=no-name-in-module +from opentelemetry.resource.detector.azure.vm import AzureVMResourceDetector LINUX_JSON = """ { @@ -175,7 +173,7 @@ "zone": "1" } """ -WINDOWS_JSON =""" +WINDOWS_JSON = """ { "additionalCapabilities": { "hibernationEnabled": "false" @@ -369,8 +367,8 @@ def test_linux(self, mock_urlopen): mock_urlopen.return_value = mock_open mock_open.read.return_value = LINUX_JSON attributes = AzureVMResourceDetector().detect().attributes - for attribute_key in LINUX_ATTRIBUTES: - self.assertEqual(attributes[attribute_key], LINUX_ATTRIBUTES[attribute_key]) + for attribute_key, attribute_value in LINUX_ATTRIBUTES.items(): + self.assertEqual(attributes[attribute_key], attribute_value) @patch("opentelemetry.resource.detector.azure.vm.urlopen") def test_windows(self, mock_urlopen): @@ -378,5 +376,5 @@ def test_windows(self, mock_urlopen): mock_urlopen.return_value = mock_open mock_open.read.return_value = WINDOWS_JSON attributes = AzureVMResourceDetector().detect().attributes - for attribute_key in WINDOWS_ATTRIBUTES: - self.assertEqual(attributes[attribute_key], WINDOWS_ATTRIBUTES[attribute_key]) + for attribute_key, attribute_value in LINUX_ATTRIBUTES.items(): + self.assertEqual(attributes[attribute_key], attribute_value) diff --git a/resource/opentelemetry-resource-detector-container/src/opentelemetry/resource/detector/container/version.py b/resource/opentelemetry-resource-detector-container/src/opentelemetry/resource/detector/container/version.py index c2996671d6..2e4aa8c751 100644 --- a/resource/opentelemetry-resource-detector-container/src/opentelemetry/resource/detector/container/version.py +++ b/resource/opentelemetry-resource-detector-container/src/opentelemetry/resource/detector/container/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/scripts/generate_instrumentation_bootstrap.py b/scripts/generate_instrumentation_bootstrap.py index 23841309ff..1c0cc30f7b 100755 --- a/scripts/generate_instrumentation_bootstrap.py +++ b/scripts/generate_instrumentation_bootstrap.py @@ -21,7 +21,6 @@ import sys import astor -import pkg_resources from otel_packaging import ( get_instrumentation_packages, root_path, @@ -58,14 +57,12 @@ def main(): # pylint: disable=no-member default_instrumentations = ast.List(elts=[]) - libraries = ast.Dict(keys=[], values=[]) + libraries = ast.List(elts=[]) for pkg in get_instrumentation_packages(): if not pkg["instruments"]: default_instrumentations.elts.append(ast.Str(pkg["requirement"])) for target_pkg in pkg["instruments"]: - parsed = pkg_resources.Requirement.parse(target_pkg) - libraries.keys.append(ast.Str(parsed.name)) - libraries.values.append( + libraries.elts.append( ast.Dict( keys=[ast.Str("library"), ast.Str("instrumentation")], values=[ast.Str(target_pkg), ast.Str(pkg["requirement"])], diff --git a/scripts/update_sha.py b/scripts/update_sha.py index d74ccc12db..1c913249a2 100644 --- a/scripts/update_sha.py +++ b/scripts/update_sha.py @@ -27,7 +27,7 @@ def get_sha(branch): url = API_URL + branch - response = requests.get(url) + response = requests.get(url, timeout=15) response.raise_for_status() return response.json()["sha"] diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/resource/__init__.py b/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/resource/__init__.py index 550fde612b..81877eea58 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/resource/__init__.py +++ b/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/resource/__init__.py @@ -11,6 +11,7 @@ # 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=no-name-in-module from opentelemetry.sdk.extension.aws.resource._lambda import ( AwsLambdaResourceDetector, diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/__init__.py b/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/__init__.py index bb36ae45d5..671358dddb 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/__init__.py +++ b/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/__init__.py @@ -11,6 +11,7 @@ # 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=no-name-in-module from opentelemetry.sdk.extension.aws.trace.aws_xray_id_generator import ( AwsXRayIdGenerator, diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/aws_xray_id_generator.py b/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/aws_xray_id_generator.py index 562ec3ff55..6068511844 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/aws_xray_id_generator.py +++ b/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/aws_xray_id_generator.py @@ -77,8 +77,7 @@ class AwsXRayIdGenerator(IdGenerator): def generate_span_id(self) -> int: return self.random_id_generator.generate_span_id() - @staticmethod - def generate_trace_id() -> int: + def generate_trace_id(self) -> int: trace_time = int(time.time()) trace_identifier = random.getrandbits(96) return (trace_time << 96) + trace_identifier diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/test_aws_xray_ids_generator.py b/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/test_aws_xray_ids_generator.py index ed78c8f0e7..d2e05240e3 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/test_aws_xray_ids_generator.py +++ b/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/test_aws_xray_ids_generator.py @@ -16,6 +16,7 @@ import time import unittest +# pylint: disable=no-name-in-module from opentelemetry.sdk.extension.aws.trace import AwsXRayIdGenerator from opentelemetry.trace.span import INVALID_TRACE_ID diff --git a/tox.ini b/tox.ini index aea0b49d4a..e3d3a1fe16 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,10 @@ envlist = py3{7,8,9,10,11}-test-instrumentation-aiohttp-client pypy3-test-instrumentation-aiohttp-client + ; opentelemetry-instrumentation-aiohttp-server + py3{6,7,8,9,10,11}-test-instrumentation-aiohttp-server + pypy3-test-instrumentation-aiohttp-server + ; opentelemetry-instrumentation-aiopg py3{7,8,9,10,11}-test-instrumentation-aiopg ; instrumentation-aiopg intentionally excluded from pypy3 @@ -190,7 +194,7 @@ envlist = ; opentelemetry-instrumentation-system-metrics py3{6,7,8,9,10,11}-test-instrumentation-system-metrics - ; instrumentation-system-metrics intentionally excluded from pypy3 + pypy3-test-instrumentation-system-metrics ; opentelemetry-instrumentation-tornado py3{7,8,9,10,11}-test-instrumentation-tornado @@ -305,6 +309,7 @@ changedir = test-opentelemetry-instrumentation: opentelemetry-instrumentation/tests test-instrumentation-aio-pika: instrumentation/opentelemetry-instrumentation-aio-pika/tests test-instrumentation-aiohttp-client: instrumentation/opentelemetry-instrumentation-aiohttp-client/tests + test-instrumentation-aiohttp-server: instrumentation/opentelemetry-instrumentation-aiohttp-server/tests test-instrumentation-aiopg: instrumentation/opentelemetry-instrumentation-aiopg/tests test-instrumentation-asgi: instrumentation/opentelemetry-instrumentation-asgi/tests test-instrumentation-asyncpg: instrumentation/opentelemetry-instrumentation-asyncpg/tests @@ -450,6 +455,8 @@ commands_pre = aiohttp-client: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-aiohttp-client[test] + aiohttp-server: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-aiohttp-server[test] + aiopg: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-dbapi pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-aiopg[test] richconsole: pip install flaky {toxinidir}/exporter/opentelemetry-exporter-richconsole[test] @@ -500,7 +507,7 @@ commands = sphinx-build -E -a -W -b html -T . _build/html [testenv:spellcheck] -basepython: python3.10 +basepython: python3 recreate = True deps = codespell @@ -509,17 +516,10 @@ commands = codespell [testenv:lint] -basepython: python3.9 -recreate = False +basepython: python3 +recreate = True deps = - -c dev-requirements.txt - flaky - pylint - flake8 - isort - black - readme_renderer - httpretty + -r dev-requirements.txt commands_pre = python -m pip install "{env:CORE_REPO}#egg=opentelemetry-api&subdirectory=opentelemetry-api" @@ -544,7 +544,7 @@ commands_pre = python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-celery[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-pika[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-aio-pika[test] - python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-sklearn[test] + ; python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-sklearn[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-redis[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-remoulade[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-fastapi[test] @@ -555,6 +555,7 @@ commands_pre = python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-pymemcache[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-psycopg2[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-aiohttp-client[test] + python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-aiohttp-server[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-aiopg[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-sqlite3[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-pyramid[test] @@ -562,6 +563,8 @@ commands_pre = python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-urllib[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-urllib3[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-pymysql[test] + # prerequisite: follow the instructions here https://github.com/PyMySQL/mysqlclient#install + # for your OS to install the required dependencies python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-mysqlclient[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-pymongo[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-elasticsearch[test] @@ -573,7 +576,7 @@ commands_pre = python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-aws-lambda[test] python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-system-metrics[test] python -m pip install -e {toxinidir}/exporter/opentelemetry-exporter-richconsole[test] - python -m pip install -e {toxinidir}/exporter/opentelemetry-exporter-prometheus-remote-write[test] + # requires snappy headers to be available on the system python -m pip install -e {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws[test] python -m pip install -e {toxinidir}/resource/opentelemetry-resource-detector-container[test] python -m pip install -e {toxinidir}/propagator/opentelemetry-propagator-aws-xray[test] @@ -584,7 +587,7 @@ commands = python scripts/eachdist.py lint --check-only [testenv:docker-tests] -basepython: python3.10 +basepython: python3 deps = pip >= 20.3.3 pytest @@ -593,6 +596,9 @@ deps = mysql-connector-python ~= 8.0 pymongo >= 3.1, < 5.0 PyMySQL ~= 0.10.1 + # prerequisite: install libpq-dev (debian) or postgresql-devel (rhel), postgresql (mac) + # see https://www.psycopg.org/docs/install.html#build-prerequisites + # you might have to install additional packages depending on your OS psycopg2 ~= 2.9.5 aiopg >= 0.13.0, < 1.3.0 sqlalchemy ~= 1.4 @@ -600,6 +606,7 @@ deps = celery[pytest] >= 4.0, < 6.0 protobuf~=3.13 requests==2.25.0 + # prerequisite: install unixodbc pyodbc~=4.0.30 flaky==3.7.0 remoulade>=0.50 diff --git a/util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py b/util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py index 4f4a5d0353..054ade6d27 100644 --- a/util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py +++ b/util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py @@ -190,16 +190,32 @@ def normalise_response_header_name(header: str) -> str: key = header.lower().replace("-", "_") return f"http.response.header.{key}" + def sanitize_method(method: Optional[str]) -> Optional[str]: if method is None: return None method = method.upper() - if (environ.get(OTEL_PYTHON_INSTRUMENTATION_HTTP_CAPTURE_ALL_METHODS) or + if ( + environ.get(OTEL_PYTHON_INSTRUMENTATION_HTTP_CAPTURE_ALL_METHODS) + or # Based on https://www.rfc-editor.org/rfc/rfc7231#section-4.1 and https://www.rfc-editor.org/rfc/rfc5789#section-2. - method in ["GET", "HEAD", "POST", "PUT", "DELETE", "CONNECT", "OPTIONS", "TRACE", "PATCH"]): + method + in [ + "GET", + "HEAD", + "POST", + "PUT", + "DELETE", + "CONNECT", + "OPTIONS", + "TRACE", + "PATCH", + ] + ): return method return "UNKNOWN" + def get_custom_headers(env_var: str) -> List[str]: custom_headers = environ.get(env_var, []) if custom_headers: diff --git a/util/opentelemetry-util-http/src/opentelemetry/util/http/httplib.py b/util/opentelemetry-util-http/src/opentelemetry/util/http/httplib.py index de95a0aa92..3d6b875752 100644 --- a/util/opentelemetry-util-http/src/opentelemetry/util/http/httplib.py +++ b/util/opentelemetry-util-http/src/opentelemetry/util/http/httplib.py @@ -78,7 +78,7 @@ def trysetip(conn: http.client.HTTPConnection, loglevel=logging.DEBUG) -> bool: state = _getstate() if not state: return True - spanlist = state.get("need_ip") # type: typing.List[Span] + spanlist: typing.List[Span] = state.get("need_ip") if not spanlist: return True @@ -88,7 +88,7 @@ def trysetip(conn: http.client.HTTPConnection, loglevel=logging.DEBUG) -> bool: sock = "" try: - sock = conn.sock # type: typing.Optional[socket.socket] + sock: typing.Optional[socket.socket] = conn.sock logger.debug("Got socket: %s", sock) if sock is None: return False @@ -163,7 +163,7 @@ def set_ip_on_next_http_connection(span: Span): finally: context.detach(token) else: - spans = state["need_ip"] # type: typing.List[Span] + spans: typing.List[Span] = state["need_ip"] spans.append(span) try: yield diff --git a/util/opentelemetry-util-http/src/opentelemetry/util/http/version.py b/util/opentelemetry-util-http/src/opentelemetry/util/http/version.py index c2996671d6..2e4aa8c751 100644 --- a/util/opentelemetry-util-http/src/opentelemetry/util/http/version.py +++ b/util/opentelemetry-util-http/src/opentelemetry/util/http/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.42b0.dev" +__version__ = "0.43b0.dev" diff --git a/util/opentelemetry-util-http/tests/test_sanitize_method.py b/util/opentelemetry-util-http/tests/test_sanitize_method.py index a488ef589e..b4095324a6 100644 --- a/util/opentelemetry-util-http/tests/test_sanitize_method.py +++ b/util/opentelemetry-util-http/tests/test_sanitize_method.py @@ -20,6 +20,7 @@ sanitize_method, ) + class TestSanitizeMethod(unittest.TestCase): def test_standard_method_uppercase(self): method = sanitize_method("GET") @@ -34,7 +35,7 @@ def test_nonstandard_method(self): self.assertEqual(method, "NONSTANDARD") @patch.dict( - "os.environ", + "os.environ", { OTEL_PYTHON_INSTRUMENTATION_HTTP_CAPTURE_ALL_METHODS: "1", },