diff --git a/CHANGELOG.md b/CHANGELOG.md index 075f1c0a57..7c088b4126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#2874](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2874)) - `opentelemetry-instrumentation-confluent-kafka` Fix to allow `topic` to be extracted from `kwargs` in `produce()` ([#2901])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2901) +- `opentelemetry-instrumentation-pymongo` Fix type-related errors in certain usages of the PyMongo span `DB_MONGODB_COLLECTION` attribute and trace error status descriptions + ([#2010](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2010)) ### Breaking changes 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 f55aa2be33..1059a769b6 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py @@ -135,7 +135,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 ) @@ -185,7 +185,7 @@ def failed(self, event: monitoring.CommandFailedEvent): if span is None: return if span.is_recording(): - span.set_status(Status(StatusCode.ERROR, event.failure)) + span.set_status(Status(StatusCode.ERROR, str(event.failure))) try: self.failed_hook(span, event) except (