Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit b28a83f

Browse files
angelinireyang
authored andcommitted
Add details about aggregation pipelines & avoid get(default) parameter (#644)
Add pipeline attribute to Pymongo integration Remove use of get(default=) in Pymongo integration
1 parent fdfd3b1 commit b28a83f

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

contrib/opencensus-ext-pymongo/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
- Include aggregation pipeline in trace attributes
6+
- Fix support command dictionaries
7+
58
## 0.1.2
69
Released 2019-04-24
710

contrib/opencensus-ext-pymongo/opencensus/ext/pymongo/trace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
MODULE_NAME = 'pymongo'
2626

27-
COMMAND_ATTRIBUTES = ['filter', 'sort', 'skip', 'limit']
27+
COMMAND_ATTRIBUTES = ['filter', 'sort', 'skip', 'limit', 'pipeline']
2828

2929

3030
def trace_integration(tracer=None):
@@ -51,7 +51,7 @@ def started(self, event):
5151
span.span_kind = span_module.SpanKind.CLIENT
5252

5353
for attr in COMMAND_ATTRIBUTES:
54-
_attr = event.command.get(attr, default=None)
54+
_attr = event.command.get(attr)
5555
if _attr is not None:
5656
self.tracer.add_attribute_to_current_span(attr, str(_attr))
5757

contrib/opencensus-ext-pymongo/tests/test_pymongo_trace.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ def test_started(self):
4444
'filter': 'filter',
4545
'sort': 'sort',
4646
'limit': 'limit',
47+
'pipeline': 'pipeline',
4748
'command_name': 'find'
4849
}
4950

5051
expected_attrs = {
5152
'filter': 'filter',
5253
'sort': 'sort',
5354
'limit': 'limit',
55+
'pipeline': 'pipeline',
5456
'request_id': 'request_id',
5557
'connection_id': 'connection_id'
5658
}
@@ -101,9 +103,8 @@ class MockCommand(object):
101103
def __init__(self, command_attrs):
102104
self.command_attrs = command_attrs
103105

104-
def get(self, key, default=None):
105-
return self.command_attrs[key] \
106-
if key in self.command_attrs else default
106+
def get(self, key):
107+
return self.command_attrs.get(key)
107108

108109

109110
class MockEvent(object):

0 commit comments

Comments
 (0)