Class: TingYun::Instrumentation::MongoCommandLogSubscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/ting_yun/instrumentation/mongo_command_log_subscriber.rb

Constant Summary collapse

MONGODB =
'MongoDB'.freeze
GET_MORE =
"getMore".freeze
COLLECTION =
"collection".freeze

Instance Method Summary collapse

Instance Method Details

#completed(event) ⇒ Object Also known as: succeeded, failed



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ting_yun/instrumentation/mongo_command_log_subscriber.rb', line 27

def completed(event)
  begin
    state = TingYun::Agent::TransactionState.tl_get
    state.timings.mon_duration = state.timings.mon_duration +  event.duration * 1000
    started_event = operations.delete(event.operation_id)

    klass_name, base, *other_metrics = metrics(started_event)

    TingYun::Agent.instance.stats_engine.tl_record_scoped_and_unscoped_metrics(
        base, other_metrics, event.duration*1000
    )
    notice_nosql_statement(state, started_event, base, event.duration, klass_name)
  rescue Exception => e
    log_notification_error('completed', e)
  end
end

#started(event) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/ting_yun/instrumentation/mongo_command_log_subscriber.rb', line 18

def started(event)
  begin
    operations[event.operation_id] = event
  rescue Exception => e
    log_notification_error('started', e)
  end
end