Class: AlacrityRails::Probe::Excon

Inherits:
Object
  • Object
show all
Defined in:
lib/alacrity-rails/probe/excon.rb

Class Method Summary collapse

Class Method Details

.activateObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/alacrity-rails/probe/excon.rb', line 4

def self.activate
  if defined?(::Excon)
    ::Excon.defaults[:instrumentor] = ActiveSupport::Notifications

    ActiveSupport::Notifications.subscribe 'excon.request' do |name, started, finished, unique_id, data|
      AlacrityRails::Client.store_timeline_event(
        name: 'Excon Request',
        event_type: 'http',
        engine: 'Excon',
        started_at: started,
        finished_at: finished,
        detail: "#{data[:scheme]}://#{data[:host]}#{data[:path]}"
      )
    end
  end
end