Module: MonitoredFiber::Chain

Defined in:
lib/new_relic/agent/instrumentation/fiber/chain.rb

Class Method Summary collapse

Class Method Details

.instrument!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/new_relic/agent/instrumentation/fiber/chain.rb', line 7

def self.instrument!
  ::Fiber.class_eval do
    include NewRelic::Agent::Instrumentation::MonitoredFiber

    alias_method(:initialize_without_new_relic, :initialize)

    if NewRelic::Helper.version_satisfied?(RUBY_VERSION, '<', '2.7.0')
      def initialize(*_args, &block)
        traced_block = add_thread_tracing(&block)
        initialize_with_newrelic_tracing { initialize_without_new_relic(&traced_block) }
      end
    else
      def initialize(**kwargs, &block)
        traced_block = add_thread_tracing(&block)
        initialize_with_newrelic_tracing { initialize_without_new_relic(**kwargs, &traced_block) }
      end
    end
  end
end