diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c00715e79..37bdf27574 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#3936](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3936)) - `opentelemetry-instrumentation-aiohttp-client`: Update instrumentor to respect suppressing http instrumentation ([#3957](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3957)) +- `opentelemetry-instrumentation-pymongo` Fix type-related errors in certain usages of the PyMongo span `DB_MONGODB_COLLECTION` attribute + ([#2010](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2010)) ## Version 1.38.0/0.59b0 (2025-10-16) 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 2a9eeed281..f60fc776ae 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py @@ -148,7 +148,7 @@ def started(self, event: monitoring.CommandStartedEvent): ) span.set_attribute(SpanAttributes.DB_NAME, event.database_name) span.set_attribute(SpanAttributes.DB_STATEMENT, statement) - if collection: + if collection and isinstance(collection, str): span.set_attribute( SpanAttributes.DB_MONGODB_COLLECTION, collection )