diff --git a/instrumentation/README.md b/instrumentation/README.md index fd3a0258cf..0cf12c9baa 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -16,7 +16,7 @@ | [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 | Yes | [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 2.0 | No | [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 4.0.0 | Yes -| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi <= 0.90.1 | Yes +| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 | Yes | [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 | Yes | [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 | No | [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0 | No diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml b/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml index 9ab03f3b79..566d1a08a4 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-fastapi/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ [project.optional-dependencies] instruments = [ - "fastapi <= 0.90.1", + "fastapi ~= 0.58", ] test = [ "opentelemetry-instrumentation-fastapi[instruments]", 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 2eccbd609a..8df84fc931 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/package.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/package.py @@ -13,6 +13,6 @@ # limitations under the License. -_instruments = ("fastapi <= 0.90.1",) +_instruments = ("fastapi ~= 0.58",) _supports_metrics = True diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py index c006b5c4fe..261b2e025f 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py @@ -17,6 +17,7 @@ from unittest.mock import patch import fastapi +from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware from fastapi.responses import JSONResponse from fastapi.testclient import TestClient @@ -87,6 +88,7 @@ def setUp(self): self.exclude_patch.start() self._instrumentor = otel_fastapi.FastAPIInstrumentor() self._app = self._create_app() + self._app.add_middleware(HTTPSRedirectMiddleware) self._client = TestClient(self._app) def tearDown(self): @@ -110,12 +112,8 @@ def test_uninstrument_app(self): self._client.get("/foobar") spans = self.memory_exporter.get_finished_spans() self.assertEqual(len(spans), 3) - # pylint: disable=import-outside-toplevel - from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware - self._app.add_middleware(HTTPSRedirectMiddleware) self._instrumentor.uninstrument_app(self._app) - print(self._app.user_middleware[0].cls) self.assertFalse( isinstance( self._app.user_middleware[0].cls, OpenTelemetryMiddleware @@ -212,18 +210,18 @@ def test_basic_metric_success(self): duration = max(round((default_timer() - start) * 1000), 0) expected_duration_attributes = { "http.method": "GET", - "http.host": "testserver", - "http.scheme": "http", + "http.host": "testserver:443", + "http.scheme": "https", "http.flavor": "1.1", "http.server_name": "testserver", - "net.host.port": 80, + "net.host.port": 443, "http.status_code": 200, "http.target": "/foobar", } expected_requests_count_attributes = { "http.method": "GET", - "http.host": "testserver", - "http.scheme": "http", + "http.host": "testserver:443", + "http.scheme": "https", "http.flavor": "1.1", "http.server_name": "testserver", } diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py index cbebc5f203..73b77b262c 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py @@ -69,7 +69,7 @@ "instrumentation": "opentelemetry-instrumentation-falcon==0.38b0.dev", }, "fastapi": { - "library": "fastapi <= 0.90.1", + "library": "fastapi ~= 0.58", "instrumentation": "opentelemetry-instrumentation-fastapi==0.38b0.dev", }, "flask": {