diff --git a/.github/workflows/test_0.yml b/.github/workflows/test_0.yml index ec189c09b1..d251737227 100644 --- a/.github/workflows/test_0.yml +++ b/.github/workflows/test_0.yml @@ -2194,8 +2194,8 @@ jobs: - name: Run tests run: tox -e pypy3-test-instrumentation-falcon-2 -- -ra - py38-test-instrumentation-fastapi-main_ubuntu-latest: - name: instrumentation-fastapi-main 3.8 Ubuntu + py38-test-instrumentation-fastapi_ubuntu-latest: + name: instrumentation-fastapi 3.8 Ubuntu runs-on: ubuntu-latest steps: - name: Checkout repo @ SHA - ${{ github.sha }} @@ -2210,28 +2210,10 @@ jobs: run: pip install tox - name: Run tests - run: tox -e py38-test-instrumentation-fastapi-main -- -ra + run: tox -e py38-test-instrumentation-fastapi -- -ra - py38-test-instrumentation-fastapi-slim_ubuntu-latest: - name: instrumentation-fastapi-slim 3.8 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.8 - uses: actions/setup-python@v5 - with: - python-version: "3.8" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e py38-test-instrumentation-fastapi-slim -- -ra - - py39-test-instrumentation-fastapi-main_ubuntu-latest: - name: instrumentation-fastapi-main 3.9 Ubuntu + py39-test-instrumentation-fastapi_ubuntu-latest: + name: instrumentation-fastapi 3.9 Ubuntu runs-on: ubuntu-latest steps: - name: Checkout repo @ SHA - ${{ github.sha }} @@ -2246,46 +2228,10 @@ jobs: run: pip install tox - name: Run tests - run: tox -e py39-test-instrumentation-fastapi-main -- -ra - - py39-test-instrumentation-fastapi-slim_ubuntu-latest: - name: instrumentation-fastapi-slim 3.9 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: "3.9" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e py39-test-instrumentation-fastapi-slim -- -ra - - py310-test-instrumentation-fastapi-main_ubuntu-latest: - name: instrumentation-fastapi-main 3.10 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.10 - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e py310-test-instrumentation-fastapi-main -- -ra + run: tox -e py39-test-instrumentation-fastapi -- -ra - py310-test-instrumentation-fastapi-slim_ubuntu-latest: - name: instrumentation-fastapi-slim 3.10 Ubuntu + py310-test-instrumentation-fastapi_ubuntu-latest: + name: instrumentation-fastapi 3.10 Ubuntu runs-on: ubuntu-latest steps: - name: Checkout repo @ SHA - ${{ github.sha }} @@ -2300,10 +2246,10 @@ jobs: run: pip install tox - name: Run tests - run: tox -e py310-test-instrumentation-fastapi-slim -- -ra + run: tox -e py310-test-instrumentation-fastapi -- -ra - py311-test-instrumentation-fastapi-main_ubuntu-latest: - name: instrumentation-fastapi-main 3.11 Ubuntu + py311-test-instrumentation-fastapi_ubuntu-latest: + name: instrumentation-fastapi 3.11 Ubuntu runs-on: ubuntu-latest steps: - name: Checkout repo @ SHA - ${{ github.sha }} @@ -2318,28 +2264,10 @@ jobs: run: pip install tox - name: Run tests - run: tox -e py311-test-instrumentation-fastapi-main -- -ra + run: tox -e py311-test-instrumentation-fastapi -- -ra - py311-test-instrumentation-fastapi-slim_ubuntu-latest: - name: instrumentation-fastapi-slim 3.11 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e py311-test-instrumentation-fastapi-slim -- -ra - - py312-test-instrumentation-fastapi-main_ubuntu-latest: - name: instrumentation-fastapi-main 3.12 Ubuntu + py312-test-instrumentation-fastapi_ubuntu-latest: + name: instrumentation-fastapi 3.12 Ubuntu runs-on: ubuntu-latest steps: - name: Checkout repo @ SHA - ${{ github.sha }} @@ -2354,46 +2282,10 @@ jobs: run: pip install tox - name: Run tests - run: tox -e py312-test-instrumentation-fastapi-main -- -ra - - py312-test-instrumentation-fastapi-slim_ubuntu-latest: - name: instrumentation-fastapi-slim 3.12 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e py312-test-instrumentation-fastapi-slim -- -ra - - pypy3-test-instrumentation-fastapi-main_ubuntu-latest: - name: instrumentation-fastapi-main pypy-3.8 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python pypy-3.8 - uses: actions/setup-python@v5 - with: - python-version: "pypy-3.8" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e pypy3-test-instrumentation-fastapi-main -- -ra + run: tox -e py312-test-instrumentation-fastapi -- -ra - pypy3-test-instrumentation-fastapi-slim_ubuntu-latest: - name: instrumentation-fastapi-slim pypy-3.8 Ubuntu + pypy3-test-instrumentation-fastapi_ubuntu-latest: + name: instrumentation-fastapi pypy-3.8 Ubuntu runs-on: ubuntu-latest steps: - name: Checkout repo @ SHA - ${{ github.sha }} @@ -2408,7 +2300,7 @@ jobs: run: pip install tox - name: Run tests - run: tox -e pypy3-test-instrumentation-fastapi-slim -- -ra + run: tox -e pypy3-test-instrumentation-fastapi -- -ra py38-test-instrumentation-flask-0_ubuntu-latest: name: instrumentation-flask-0 3.8 Ubuntu @@ -4515,3 +4407,111 @@ jobs: - name: Run tests run: tox -e py311-test-instrumentation-pymemcache-2 -- -ra + + py311-test-instrumentation-pymemcache-3_ubuntu-latest: + name: instrumentation-pymemcache-3 3.11 Ubuntu + runs-on: ubuntu-latest + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install tox + run: pip install tox + + - name: Run tests + run: tox -e py311-test-instrumentation-pymemcache-3 -- -ra + + py311-test-instrumentation-pymemcache-4_ubuntu-latest: + name: instrumentation-pymemcache-4 3.11 Ubuntu + runs-on: ubuntu-latest + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install tox + run: pip install tox + + - name: Run tests + run: tox -e py311-test-instrumentation-pymemcache-4 -- -ra + + py312-test-instrumentation-pymemcache-0_ubuntu-latest: + name: instrumentation-pymemcache-0 3.12 Ubuntu + runs-on: ubuntu-latest + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install tox + run: pip install tox + + - name: Run tests + run: tox -e py312-test-instrumentation-pymemcache-0 -- -ra + + py312-test-instrumentation-pymemcache-1_ubuntu-latest: + name: instrumentation-pymemcache-1 3.12 Ubuntu + runs-on: ubuntu-latest + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install tox + run: pip install tox + + - name: Run tests + run: tox -e py312-test-instrumentation-pymemcache-1 -- -ra + + py312-test-instrumentation-pymemcache-2_ubuntu-latest: + name: instrumentation-pymemcache-2 3.12 Ubuntu + runs-on: ubuntu-latest + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install tox + run: pip install tox + + - name: Run tests + run: tox -e py312-test-instrumentation-pymemcache-2 -- -ra + + py312-test-instrumentation-pymemcache-3_ubuntu-latest: + name: instrumentation-pymemcache-3 3.12 Ubuntu + runs-on: ubuntu-latest + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install tox + run: pip install tox + + - name: Run tests + run: tox -e py312-test-instrumentation-pymemcache-3 -- -ra diff --git a/.github/workflows/test_1.yml b/.github/workflows/test_1.yml index e1ce8cd445..f7e71dd6b6 100644 --- a/.github/workflows/test_1.yml +++ b/.github/workflows/test_1.yml @@ -16,114 +16,6 @@ env: jobs: - py311-test-instrumentation-pymemcache-3_ubuntu-latest: - name: instrumentation-pymemcache-3 3.11 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e py311-test-instrumentation-pymemcache-3 -- -ra - - py311-test-instrumentation-pymemcache-4_ubuntu-latest: - name: instrumentation-pymemcache-4 3.11 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e py311-test-instrumentation-pymemcache-4 -- -ra - - py312-test-instrumentation-pymemcache-0_ubuntu-latest: - name: instrumentation-pymemcache-0 3.12 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e py312-test-instrumentation-pymemcache-0 -- -ra - - py312-test-instrumentation-pymemcache-1_ubuntu-latest: - name: instrumentation-pymemcache-1 3.12 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e py312-test-instrumentation-pymemcache-1 -- -ra - - py312-test-instrumentation-pymemcache-2_ubuntu-latest: - name: instrumentation-pymemcache-2 3.12 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e py312-test-instrumentation-pymemcache-2 -- -ra - - py312-test-instrumentation-pymemcache-3_ubuntu-latest: - name: instrumentation-pymemcache-3 3.12 Ubuntu - runs-on: ubuntu-latest - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - - name: Install tox - run: pip install tox - - - name: Run tests - run: tox -e py312-test-instrumentation-pymemcache-3 -- -ra - py312-test-instrumentation-pymemcache-4_ubuntu-latest: name: instrumentation-pymemcache-4 3.12 Ubuntu runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index e3b91462ba..d1a113a91e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,24 +11,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `opentelemetry-instrumentation-kafka-python` Instrument temporary fork, kafka-python-ng inside kafka-python's instrumentation - ([#2537](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2537))) + ([#2537](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2537)) ## Breaking changes +- `opentelemetry-bootstrap` Remove `opentelemetry-instrumentation-aws-lambda` from the defaults instrumentations + ([#2786](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2786)) + ## Fixed +- `opentelemetry-instrumentation-fastapi` fix `fastapi` auto-instrumentation by removing `fastapi-slim` support, `fastapi-slim` itself is discontinued from maintainers + ([2783](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2783)) - `opentelemetry-instrumentation-aws-lambda` Avoid exception when a handler is not present. ([#2750](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2750)) - `opentelemetry-instrumentation-django` Fix regression - `http.target` re-added back to old semconv duration metrics ([#2746](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2746)) - `opentelemetry-instrumentation-grpc` Fixes the issue with the gRPC instrumentation not working with the 1.63.0 and higher version of gRPC ([#2483](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2484)) -- `opentelemetry-instrumentation-fastapi` Fix fastapi-slim support - ([#2756](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2756)) - `opentelemetry-instrumentation-aws-lambda` Fixing w3c baggage support ([#2589](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2589)) - `opentelemetry-instrumentation-celery` propagates baggage ([#2385](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2385)) +- `opentelemetry-instrumentation-asyncio` Fixes async generator coroutines not being awaited + ([#2792](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2792)) ## Version 1.26.0/0.47b0 (2024-07-23) diff --git a/instrumentation/README.md b/instrumentation/README.md index 378497db79..22c4241bab 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -19,7 +19,7 @@ | [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 | Yes | experimental | [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 6.0 | No | experimental | [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 4.0.0 | Yes | experimental -| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58,fastapi-slim ~= 0.111 | Yes | migration +| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | Yes | migration | [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0 | Yes | migration | [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 | No | experimental | [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0 | No | migration diff --git a/instrumentation/opentelemetry-instrumentation-asyncio/src/opentelemetry/instrumentation/asyncio/__init__.py b/instrumentation/opentelemetry-instrumentation-asyncio/src/opentelemetry/instrumentation/asyncio/__init__.py index f5f0d34c4f..ae10560861 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncio/src/opentelemetry/instrumentation/asyncio/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asyncio/src/opentelemetry/instrumentation/asyncio/__init__.py @@ -262,7 +262,7 @@ def trace_item(self, coro_or_future): async def trace_coroutine(self, coro): if not hasattr(coro, "__name__"): - return coro + return await coro start = default_timer() attr = { "type": "coroutine", diff --git a/instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_anext.py b/instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_anext.py index e51f059ca0..5241b3f2cc 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_anext.py +++ b/instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_anext.py @@ -43,19 +43,23 @@ def tearDown(self): # Asyncio anext() does not have __name__ attribute, which is used to determine if the coroutine should be traced. # This test is to ensure that the instrumentation does not break when the coroutine does not have __name__ attribute. + # Additionally, ensure the coroutine is actually awaited. @skipIf( sys.version_info < (3, 10), "anext is only available in Python 3.10+" ) def test_asyncio_anext(self): async def main(): async def async_gen(): - for it in range(2): + # nothing special about this range other than to avoid returning a zero + # from a function named 'main' (which might cause confusion about intent) + for it in range(2, 4): yield it async_gen_instance = async_gen() agen = anext(async_gen_instance) - await asyncio.create_task(agen) + return await asyncio.create_task(agen) - asyncio.run(main()) + ret = asyncio.run(main()) + self.assertEqual(ret, 2) # first iteration from range() spans = self.memory_exporter.get_finished_spans() self.assertEqual(len(spans), 0) diff --git a/instrumentation/opentelemetry-instrumentation-django/test-requirements-2.txt b/instrumentation/opentelemetry-instrumentation-django/test-requirements-2.txt index 2ed199fbf3..4f49efb39e 100644 --- a/instrumentation/opentelemetry-instrumentation-django/test-requirements-2.txt +++ b/instrumentation/opentelemetry-instrumentation-django/test-requirements-2.txt @@ -1,7 +1,7 @@ asgiref==3.7.2 backports.zoneinfo==0.2.1 Deprecated==1.2.14 -Django==4.2.14 +Django==4.2.15 importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-django/test-requirements-3.txt b/instrumentation/opentelemetry-instrumentation-django/test-requirements-3.txt index c3e65be730..9be1266014 100644 --- a/instrumentation/opentelemetry-instrumentation-django/test-requirements-3.txt +++ b/instrumentation/opentelemetry-instrumentation-django/test-requirements-3.txt @@ -1,6 +1,6 @@ asgiref==3.7.2 Deprecated==1.2.14 -Django==4.2.14 +Django==4.2.15 importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml b/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml index eec5b0f10f..3017dc040a 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml @@ -35,7 +35,6 @@ dependencies = [ [project.optional-dependencies] instruments = [ "fastapi ~= 0.58", - "fastapi-slim ~= 0.111", ] [project.entry-points.opentelemetry_instrumentor] 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 fdb035baa8..37a293764e 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py @@ -179,7 +179,6 @@ def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, A from __future__ import annotations import logging -from importlib.metadata import PackageNotFoundError, distribution from typing import Collection import fastapi @@ -197,11 +196,7 @@ def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, A ClientResponseHook, ServerRequestHook, ) -from opentelemetry.instrumentation.fastapi.package import ( - _fastapi, - _fastapi_slim, - _instruments, -) +from opentelemetry.instrumentation.fastapi.package import _instruments from opentelemetry.instrumentation.fastapi.version import __version__ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.metrics import get_meter @@ -298,21 +293,6 @@ def uninstrument_app(app: fastapi.FastAPI): app._is_instrumented_by_opentelemetry = False def instrumentation_dependencies(self) -> Collection[str]: - # need to use distribution because find_spec("fastapi") will return - # something even with just fastapi-slim installed - try: - distribution("fastapi-slim") - return (_fastapi_slim,) - except PackageNotFoundError: - pass - - try: - distribution("fastapi") - return (_fastapi,) - except PackageNotFoundError: - pass - - # If neither is installed, return both as potential dependencies return _instruments def _instrument(self, **kwargs): diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/package.py b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/package.py index 55cf4b3646..d95a2cf6d5 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/package.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/package.py @@ -13,10 +13,7 @@ # limitations under the License. -_fastapi = "fastapi ~= 0.58" -_fastapi_slim = "fastapi-slim ~= 0.111" - -_instruments = (_fastapi, _fastapi_slim) +_instruments = ("fastapi ~= 0.58",) _supports_metrics = True diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/test-requirements-slim.txt b/instrumentation/opentelemetry-instrumentation-fastapi/test-requirements-slim.txt deleted file mode 100644 index 2ea55f1b91..0000000000 --- a/instrumentation/opentelemetry-instrumentation-fastapi/test-requirements-slim.txt +++ /dev/null @@ -1,32 +0,0 @@ -annotated-types==0.6.0 -anyio==4.3.0 -asgiref==3.7.2 -certifi==2024.7.4 -charset-normalizer==3.3.2 -Deprecated==1.2.14 -exceptiongroup==1.2.0 -fastapi-slim==0.111.0 -h11==0.14.0 -httpcore==1.0.4 -httpx==0.27.0 -idna==3.7 -importlib-metadata==6.11.0 -iniconfig==2.0.0 -packaging==24.0 -pluggy==1.5.0 -py-cpuinfo==9.0.0 -pydantic==2.6.2 -pydantic_core==2.16.3 -pytest==7.4.4 -requests==2.32.3 -sniffio==1.3.0 -starlette==0.37.2 -tomli==2.0.1 -typing_extensions==4.9.0 -urllib3==2.2.2 -wrapt==1.16.0 -zipp==3.19.2 --e opentelemetry-instrumentation --e instrumentation/opentelemetry-instrumentation-asgi --e util/opentelemetry-util-http --e instrumentation/opentelemetry-instrumentation-fastapi diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py index 03fdd6749d..91ed514096 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py @@ -1069,6 +1069,18 @@ def test_uninstrument_after_instrument(self): spans = self.memory_exporter.get_finished_spans() self.assertEqual(len(spans), 3) + def test_no_op_tracer_provider(self): + self._instrumentor.uninstrument() + self._instrumentor.instrument( + tracer_provider=trace.NoOpTracerProvider() + ) + + app = self._create_fastapi_app() + client = TestClient(app) + client.get("/foobar") + spans = self.memory_exporter.get_finished_spans() + self.assertEqual(len(spans), 0) + def tearDown(self): self._instrumentor.uninstrument() super().tearDown() diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py index 1c9bd63874..c31863bd31 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py @@ -84,10 +84,6 @@ "library": "fastapi ~= 0.58", "instrumentation": "opentelemetry-instrumentation-fastapi==0.48b0.dev", }, - { - "library": "fastapi-slim ~= 0.111", - "instrumentation": "opentelemetry-instrumentation-fastapi==0.48b0.dev", - }, { "library": "flask >= 1.0", "instrumentation": "opentelemetry-instrumentation-flask==0.48b0.dev", @@ -191,7 +187,6 @@ ] default_instrumentations = [ "opentelemetry-instrumentation-asyncio==0.48b0.dev", - "opentelemetry-instrumentation-aws-lambda==0.48b0.dev", "opentelemetry-instrumentation-dbapi==0.48b0.dev", "opentelemetry-instrumentation-logging==0.48b0.dev", "opentelemetry-instrumentation-sqlite3==0.48b0.dev", diff --git a/scripts/generate_instrumentation_bootstrap.py b/scripts/generate_instrumentation_bootstrap.py index 1c0cc30f7b..57af33e303 100755 --- a/scripts/generate_instrumentation_bootstrap.py +++ b/scripts/generate_instrumentation_bootstrap.py @@ -53,12 +53,21 @@ "bootstrap_gen.py", ) +# AWS Lambda instrumentation is excluded from the default list because it often +# requires specific configurations and dependencies that may not be set up +# in all environments. Instead, users who need AWS Lambda support can opt-in +# by manually adding it to their environment. +# See https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2787 +packages_to_exclude = ["opentelemetry-instrumentation-aws-lambda"] + def main(): # pylint: disable=no-member default_instrumentations = ast.List(elts=[]) libraries = ast.List(elts=[]) for pkg in get_instrumentation_packages(): + if pkg.get("name") in packages_to_exclude: + continue if not pkg["instruments"]: default_instrumentations.elts.append(ast.Str(pkg["requirement"])) for target_pkg in pkg["instruments"]: diff --git a/tox.ini b/tox.ini index 75e8a7f5a0..8552948b6b 100644 --- a/tox.ini +++ b/tox.ini @@ -112,8 +112,8 @@ envlist = lint-instrumentation-falcon ; opentelemetry-instrumentation-fastapi - py3{8,9,10,11,12}-test-instrumentation-fastapi-{main,slim} - pypy3-test-instrumentation-fastapi-{main,slim} + py3{8,9,10,11,12}-test-instrumentation-fastapi + pypy3-test-instrumentation-fastapi lint-instrumentation-fastapi ; opentelemetry-instrumentation-flask @@ -556,9 +556,7 @@ commands_pre = fastapi: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions fastapi: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk fastapi: pip install opentelemetry-test-utils@{env:CORE_REPO}\#egg=opentelemetry-test-utils&subdirectory=tests/opentelemetry-test-utils - fastapi-main: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-fastapi/test-requirements.txt - fastapi-slim: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-fastapi/test-requirements-slim.txt - lint-instrumentation-fastapi: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-fastapi/test-requirements.txt + fastapi: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-fastapi/test-requirements.txt mysql: pip install opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api mysql: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions