lib/mongo/monitoring/publishable.rb in mongo-2.12.4 vs lib/mongo/monitoring/publishable.rb in mongo-2.13.0.beta1
- old
+ new
@@ -1,6 +1,6 @@
-# Copyright (C) 2015-2019 MongoDB, Inc.
+# Copyright (C) 2015-2020 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@@ -43,22 +43,23 @@
end
private
def command_started(address, operation_id, payload,
- socket_object_id: nil, connection_id: nil
+ socket_object_id: nil, connection_id: nil, connection_generation: nil
)
monitoring.started(
Monitoring::COMMAND,
Event::CommandStarted.generate(address, operation_id, payload,
- socket_object_id: socket_object_id, connection_id: connection_id)
+ socket_object_id: socket_object_id, connection_id: connection_id,
+ connection_generation: connection_generation)
)
end
def command_completed(result, address, operation_id, payload, duration)
document = result ? (result.documents || []).first : nil
- if error?(document)
+ if document && (document['ok'] && document['ok'] != 1 || document.key?('$err'))
parser = Error::Parser.new(document)
command_failed(document, address, operation_id, payload, parser.message, duration)
else
command_succeeded(result, address, operation_id, payload, duration)
end
@@ -84,13 +85,9 @@
)
end
def duration(start)
Time.now - start
- end
-
- def error?(document)
- document && (document['ok'] == 0 || document.key?('$err'))
end
def monitoring?
options[:monitoring] != false
end