class ElasticAPM::Spies::MongoSpy::Subscriber

def push_event(event)

rubocop:disable Metrics/MethodLength
def push_event(event)
  return unless ElasticAPM.current_transaction
  # Some MongoDB commands are not on collections but rather are db
  # admin commands. For these commands, the value at the `command_name`
  # key is the integer 1.
  unless event.command[event.command_name] == 1
    collection = event.command[event.command_name]
  end
  name = [event.database_name,
          collection,
          event.command_name].compact.join('.')
  span =
    ElasticAPM.start_span(
      name,
      TYPE,
      subtype: SUBTYPE,
      action: ACTION,
      context: build_context(event)
    )
  @events[event.operation_id] = span
end