From c8b06539c0105006faf8c591b5104ee636723087 Mon Sep 17 00:00:00 2001 From: RJ Duffner Date: Fri, 28 Apr 2023 08:40:10 -0700 Subject: [PATCH 1/2] Add support for pymemcache version > 4.0.0 (#1764) --- CHANGELOG.md | 2 ++ instrumentation/README.md | 2 +- .../pyproject.toml | 2 +- .../opentelemetry/instrumentation/pymemcache/package.py | 2 +- .../src/opentelemetry/instrumentation/bootstrap_gen.py | 2 +- tox.ini | 9 +++++---- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85bb0e5a65..cb9d7ae22a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `opentelemetry-instrumentation-system-metrics` Add `process.` prefix to `runtime.memory`, `runtime.cpu.time`, and `runtime.gc_count`. Change `runtime.memory` from count to UpDownCounter. ([#1735](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1735)) - Add request and response hooks for GRPC instrumentation (client only) ([#1706](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1706)) +- `opentelemetry-instrumentation-pymemcache` Update instrumentation to support pymemcache >4 + ([#1764](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1764)) ### Added diff --git a/instrumentation/README.md b/instrumentation/README.md index 0cf12c9baa..e69dd6adbd 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -26,7 +26,7 @@ | [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python ~= 8.0 | No | [opentelemetry-instrumentation-pika](./opentelemetry-instrumentation-pika) | pika >= 0.12.0 | No | [opentelemetry-instrumentation-psycopg2](./opentelemetry-instrumentation-psycopg2) | psycopg2 >= 2.7.3.1 | No -| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache >= 1.3.5, < 4 | No +| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache >= 1.3.5, < 5 | No | [opentelemetry-instrumentation-pymongo](./opentelemetry-instrumentation-pymongo) | pymongo >= 3.1, < 5.0 | No | [opentelemetry-instrumentation-pymysql](./opentelemetry-instrumentation-pymysql) | PyMySQL < 2 | No | [opentelemetry-instrumentation-pyramid](./opentelemetry-instrumentation-pyramid) | pyramid >= 1.7 | Yes diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/pyproject.toml b/instrumentation/opentelemetry-instrumentation-pymemcache/pyproject.toml index 7e896a07b6..55a2ef077d 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ [project.optional-dependencies] instruments = [ - "pymemcache >= 1.3.5, < 4", + "pymemcache >= 1.3.5, < 5", ] test = [ "opentelemetry-instrumentation-pymemcache[instruments]", diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/package.py b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/package.py index 7229a3ba47..a75a6670ba 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/package.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/package.py @@ -13,4 +13,4 @@ # limitations under the License. -_instruments = ("pymemcache >= 1.3.5, < 4",) +_instruments = ("pymemcache >= 1.3.5, < 5",) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py index b3f5c10e9a..05c77b9fea 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py @@ -105,7 +105,7 @@ "instrumentation": "opentelemetry-instrumentation-psycopg2==0.39b0.dev", }, "pymemcache": { - "library": "pymemcache >= 1.3.5, < 4", + "library": "pymemcache >= 1.3.5, < 5", "instrumentation": "opentelemetry-instrumentation-pymemcache==0.39b0.dev", }, "pymongo": { diff --git a/tox.ini b/tox.ini index ec5589744d..1603dfb745 100644 --- a/tox.ini +++ b/tox.ini @@ -122,8 +122,8 @@ envlist = ; ext-psycopg2 intentionally excluded from pypy3 ; opentelemetry-instrumentation-pymemcache - py3{7,8,9,10,11}-test-instrumentation-pymemcache{135,200,300,342} - pypy3-test-instrumentation-pymemcache{135,200,300,342} + py3{7,8,9,10,11}-test-instrumentation-pymemcache{135,200,300,342,400} + pypy3-test-instrumentation-pymemcache{135,200,300,342,400} ; opentelemetry-instrumentation-pymongo py3{7,8,9,10,11}-test-instrumentation-pymongo @@ -267,6 +267,7 @@ deps = pymemcache200: pymemcache >2.0.0,<3.0.0 pymemcache300: pymemcache >3.0.0,<3.4.2 pymemcache342: pymemcache ==3.4.2 + pymemcache400: pymemcache ==4.0.0 httpx18: httpx>=0.18.0,<0.19.0 httpx18: respx~=0.17.0 httpx21: httpx>=0.19.0 @@ -311,7 +312,7 @@ changedir = test-instrumentation-pika{0,1}: instrumentation/opentelemetry-instrumentation-pika/tests test-instrumentation-aio-pika{7,8,9}: instrumentation/opentelemetry-instrumentation-aio-pika/tests test-instrumentation-psycopg2: instrumentation/opentelemetry-instrumentation-psycopg2/tests - test-instrumentation-pymemcache{135,200,300,342}: instrumentation/opentelemetry-instrumentation-pymemcache/tests + test-instrumentation-pymemcache{135,200,300,342,400}: instrumentation/opentelemetry-instrumentation-pymemcache/tests test-instrumentation-pymongo: instrumentation/opentelemetry-instrumentation-pymongo/tests test-instrumentation-pymysql: instrumentation/opentelemetry-instrumentation-pymysql/tests test-instrumentation-pyramid: instrumentation/opentelemetry-instrumentation-pyramid/tests @@ -390,7 +391,7 @@ commands_pre = mysql: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-dbapi {toxinidir}/instrumentation/opentelemetry-instrumentation-mysql[test] - pymemcache{135,200,300,342}: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-pymemcache[test] + pymemcache{135,200,300,342,400}: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-pymemcache[test] pymongo: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-pymongo[test] From f46a6e1c0e8df6bb384a64bd75e345a21a52f9c3 Mon Sep 17 00:00:00 2001 From: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> Date: Fri, 28 Apr 2023 09:47:51 -0700 Subject: [PATCH 2/2] Request ASGI attributes passed to Sampler (#1762) * Request ASGI attributes passed to Sampler * Update changelog * aiohttp-client test http.url --------- Co-authored-by: Srikanth Chekuri Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com> --- CHANGELOG.md | 2 ++ .../src/opentelemetry/instrumentation/asgi/__init__.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb9d7ae22a..4470050941 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1733](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1733)) - Make Django request span attributes available for `start_span`. ([#1730](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1730)) +- Make ASGI request span attributes available for `start_span`. + ([#1762](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1762)) ### Fixed 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 d4653ac50b..6fc88d3eeb 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -531,15 +531,16 @@ async def __call__(self, scope, receive, send): span_name, additional_attributes = self.default_span_details(scope) + attributes = collect_request_attributes(scope) + attributes.update(additional_attributes) span, token = _start_internal_or_server_span( tracer=self.tracer, span_name=span_name, start_time=None, context_carrier=scope, context_getter=asgi_getter, + attributes=attributes, ) - attributes = collect_request_attributes(scope) - attributes.update(additional_attributes) active_requests_count_attrs = _parse_active_request_count_attrs( attributes )