diff --git a/CHANGELOG.md b/CHANGELOG.md index 13ebb67d7..595da827b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - `opentelemetry-instrumentation-boto3sqs` Make propagation compatible with other SQS instrumentations, add 'messaging.url' span attribute, and fix missing package dependencies. - ([#1234](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1234)) + ([#1234](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1234)) +- `opentelemetry-instrumentation-pymongo` Change span names to not contain queries but only database name and command name + ([#1247](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1247)) - restoring metrics in django framework ([#1208](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1208)) - `opentelemetry-instrumentation-aiohttp-client` Fix producing additional spans with each newly created ClientSession 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 ba3afae11..91cd81aab 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py @@ -121,10 +121,10 @@ class CommandTracer(monitoring.CommandListener): ): return command = event.command.get(event.command_name, "") - name = event.command_name + name = event.database_name + name += "." + event.command_name statement = event.command_name if command: - name += "." + str(command) statement += " " + str(command) try: diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py b/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py index ef3734c59..15a5a0be0 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py @@ -40,7 +40,6 @@ class TestPymongo(TestBase): ) with patch: PymongoInstrumentor().instrument() - self.assertTrue(mock_register.called) def test_started(self): @@ -59,7 +58,7 @@ class TestPymongo(TestBase): # pylint: disable=protected-access span = command_tracer._pop_span(mock_event) self.assertIs(span.kind, trace_api.SpanKind.CLIENT) - self.assertEqual(span.name, "command_name.find") + self.assertEqual(span.name, "database_name.command_name") self.assertEqual(span.attributes[SpanAttributes.DB_SYSTEM], "mongodb") self.assertEqual( span.attributes[SpanAttributes.DB_NAME], "database_name" @@ -189,8 +188,7 @@ class TestPymongo(TestBase): self.assertEqual(len(spans_list), 1) span = spans_list[0] - - self.assertEqual(span.name, "command_name.123") + self.assertEqual(span.name, "database_name.command_name") class MockCommand: