diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c9c67be4b..c37dca777b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- `opentelemetry-instrumentation-django`: Remove duplicate query logging in SQLCommenter middleware that broke Django's `assertNumQueries` + ([#4367](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4367)) - `opentelemetry-docker-tests`: Replace deprecated `SpanAttributes` from `opentelemetry.semconv.trace` with `opentelemetry.semconv._incubating.attributes` ([#4339](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4339)) - `opentelemetry-instrumentation-confluent-kafka`: Skip `recv` span creation when `poll()` returns no message or `consume()` returns an empty list, avoiding empty spans on idle polls diff --git a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py index 8167724564..0e845279a3 100644 --- a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py @@ -18,7 +18,6 @@ # pylint: disable=no-name-in-module from django import conf, get_version from django.db import connections -from django.db.backends.utils import CursorDebugWrapper from opentelemetry.instrumentation.sqlcommenter_utils import _add_sql_comment from opentelemetry.instrumentation.utils import _get_opentelemetry_values @@ -116,14 +115,4 @@ def __call__(self, execute: Type[T], sql, params, many, context) -> T: **_get_opentelemetry_values() if with_opentelemetry else {}, ) - # TODO: MySQL truncates logs > 1024B so prepend comments - # instead of statements, if the engine is MySQL. - # See: - # * https://github.com/basecamp/marginalia/issues/61 - # * https://github.com/basecamp/marginalia/pull/80 - - # Add the query to the query log if debugging. - if isinstance(context["cursor"], CursorDebugWrapper): - context["connection"].queries_log.append(sql) - return execute(sql, params, many, context)