Method: Datadog::Tracing::Contrib::MongoDB::MongoCommandSubscriber#failed

Defined in:
lib/datadog/tracing/contrib/mongodb/subscribers.rb

#failed(event) ⇒ Object

rubocop:enable Metrics/AbcSize



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/datadog/tracing/contrib/mongodb/subscribers.rb', line 78

def failed(event)
  span = get_span(event)
  return unless span

  # the failure is not a real exception because it's handled by
  # the framework itself, so we set only the error and the message
  span.set_error(event)
rescue StandardError => e
  Datadog.logger.debug("error when handling MongoDB 'failed' event: #{e}")
ensure
  # whatever happens, the Span must be removed from the local storage and
  # it must be finished to prevent any leak
  span.finish unless span.nil?
  clear_span(event)
end