Class: Instana::Mongo

Inherits:
Object
  • Object
show all
Defined in:
lib/instana/instrumentation/mongo.rb

Constant Summary collapse

REMOVED_COMMAND_ELEMENTS =
%w[lsid $db documents].freeze

Instance Method Summary collapse

Constructor Details

#initializeMongo

Returns a new instance of Mongo.



8
9
10
# File 'lib/instana/instrumentation/mongo.rb', line 8

def initialize
  @requests = {}
end

Instance Method Details

#failed(event) ⇒ Object



26
27
28
29
30
31
# File 'lib/instana/instrumentation/mongo.rb', line 26

def failed(event)
  span = @requests.delete(event.request_id)
  span.record_exception(Exception.new(event.message))

  span.finish
end

#started(event) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/instana/instrumentation/mongo.rb', line 12

def started(event)
  tags = {
    namespace: event.database_name,
    command: event.command_name,
    peer: {
      hostname: event.address.host,
      port: event.address.port
    },
    json: filter_statement(event.command)
  }

  @requests[event.request_id] = ::Instana.tracer.start_span(:mongo, attributes: {mongo: tags})
end

#succeeded(event) ⇒ Object



33
34
35
36
# File 'lib/instana/instrumentation/mongo.rb', line 33

def succeeded(event)
  span = @requests.delete(event.request_id)
  span.finish
end