mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-28 12:43:39 +08:00
Pymongo capture collection name (#1555)
This commit is contained in:
@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `opentelemetry-instrumentation-aws-lambda` Adds an option to configure `disable_aws_context_propagation` by
|
||||
environment variable: `OTEL_LAMBDA_DISABLE_AWS_CONTEXT_PROPAGATION`
|
||||
([#1507](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1507))
|
||||
|
||||
- Fix pymongo to collect the property DB_MONGODB_COLLECTION
|
||||
([#1555](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1555))
|
||||
|
||||
## Version 1.15.0/0.36b0 (2022-12-10)
|
||||
|
||||
|
@ -126,6 +126,7 @@ class CommandTracer(monitoring.CommandListener):
|
||||
statement = event.command_name
|
||||
if command:
|
||||
statement += " " + str(command)
|
||||
collection = event.command.get(event.command_name)
|
||||
|
||||
try:
|
||||
span = self._tracer.start_span(name, kind=SpanKind.CLIENT)
|
||||
@ -135,6 +136,10 @@ class CommandTracer(monitoring.CommandListener):
|
||||
)
|
||||
span.set_attribute(SpanAttributes.DB_NAME, event.database_name)
|
||||
span.set_attribute(SpanAttributes.DB_STATEMENT, statement)
|
||||
if collection:
|
||||
span.set_attribute(
|
||||
SpanAttributes.DB_MONGODB_COLLECTION, collection
|
||||
)
|
||||
if event.connection_id is not None:
|
||||
span.set_attribute(
|
||||
SpanAttributes.NET_PEER_NAME, event.connection_id[0]
|
||||
|
@ -68,6 +68,10 @@ class TestFunctionalPymongo(TestBase):
|
||||
self.assertEqual(
|
||||
pymongo_span.attributes[SpanAttributes.NET_PEER_PORT], MONGODB_PORT
|
||||
)
|
||||
self.assertEqual(
|
||||
pymongo_span.attributes[SpanAttributes.DB_MONGODB_COLLECTION],
|
||||
MONGODB_COLLECTION_NAME,
|
||||
)
|
||||
|
||||
def test_insert(self):
|
||||
"""Should create a child span for insert"""
|
||||
|
Reference in New Issue
Block a user