class ElasticAPM::Spies::MongoSpy::Subscriber
@api private
Constants
- TYPE
Public Class Methods
new()
click to toggle source
# File lib/elastic_apm/spies/mongo.rb, line 18 def initialize @events = {} end
Public Instance Methods
failed(event)
click to toggle source
# File lib/elastic_apm/spies/mongo.rb, line 26 def failed(event) pop_event(event) end
started(event)
click to toggle source
# File lib/elastic_apm/spies/mongo.rb, line 22 def started(event) push_event(event) end
succeeded(event)
click to toggle source
# File lib/elastic_apm/spies/mongo.rb, line 30 def succeeded(event) pop_event(event) end
Private Instance Methods
build_context(event)
click to toggle source
# File lib/elastic_apm/spies/mongo.rb, line 56 def build_context(event) Span::Context.new( db: { instance: event.database_name, statement: nil, type: 'mongodb', user: nil } ) end
pop_event(event)
click to toggle source
# File lib/elastic_apm/spies/mongo.rb, line 49 def pop_event(event) return unless (curr = ElasticAPM.current_span) span = @events.delete(event.operation_id) curr == span && ElasticAPM.end_span end
push_event(event)
click to toggle source
# File lib/elastic_apm/spies/mongo.rb, line 36 def push_event(event) return unless ElasticAPM.current_transaction span = ElasticAPM.start_span( event.command_name.to_s, TYPE, context: build_context(event) ) @events[event.operation_id] = span end