Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of pymongo command in pymongo instrumentation span name #1247

Merged
merged 5 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ def started(self, event: monitoring.CommandStartedEvent):
):
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def test_pymongo_instrumentor(self):
)
with patch:
PymongoInstrumentor().instrument()

self.assertTrue(mock_register.called)

def test_started(self):
Expand All @@ -59,7 +58,7 @@ def test_started(self):
# 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"
Expand Down Expand Up @@ -189,8 +188,7 @@ def test_int_command(self):

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:
Expand Down