Skip to content

Commit 178e17a

Browse files
committed
reformat, fix tests
1 parent 841fe21 commit 178e17a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,12 @@ def failed(self, event: monitoring.CommandFailedEvent):
198198
if span is None:
199199
return
200200
if span.is_recording():
201-
span.set_status(Status(StatusCode.ERROR, event.failure.get("errmsg", "Unknown error")))
201+
span.set_status(
202+
Status(
203+
StatusCode.ERROR,
204+
event.failure.get("errmsg", "Unknown error"),
205+
)
206+
)
202207
try:
203208
self.failed_hook(span, event)
204209
except (

instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ def __init__(self, command_attrs, connection_id=None, request_id=""):
293293
self.command_name = self.command.get("command_name")
294294
self.connection_id = connection_id
295295
self.request_id = request_id
296+
self.failure = None
296297

297298
def mark_as_failed(self):
298299
# CommandFailedEvent.failure is type _DocumentOut, which pymongo defines as:
@@ -301,9 +302,7 @@ def mark_as_failed(self):
301302
# ```
302303
# we go with the former, but both provide a `.get(key, default)` method.
303304
#
304-
self.failure = {
305-
"errmsg": "operation failed"
306-
}
305+
self.failure = {"errmsg": "operation failed"}
307306

308307
def __getattr__(self, item):
309308
return item

0 commit comments

Comments
 (0)