10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/signalfx/tracing/instrumentation/rails.rb', line 10
def instrument(opts = {})
return if @instrumented
begin
require 'active_support'
require 'rails'
rescue LoadError
return
end
begin
require 'rails/instrumentation'
require 'rack/tracer'
rescue LoadError => e
puts e.message
return
end
if opts.fetch(:rack_tracer, true)
::Rails.configuration.middleware.insert(0, ::Rack::Tracer)
end
exclude_events = opts.fetch(:exclude_events, [])
tracer = opts.fetch(:tracer, OpenTracing.global_tracer)
::Rails::Instrumentation.instrument(tracer: tracer, exclude_events: exclude_events)
@instrumented = true
end
|