Module: NewRelic::Agent::Instrumentation::Parallel::Instrumentation
- Included in:
- Prepend
- Defined in:
- lib/new_relic/agent/instrumentation/parallel/instrumentation.rb
Instance Method Summary collapse
- #setup_for_txn_metric_merge_at_exit ⇒ Object
-
#worker_with_tracing(channel_id, &block) ⇒ Object
This runs inside of the new process that was forked by Parallel.
Instance Method Details
#setup_for_txn_metric_merge_at_exit ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/new_relic/agent/instrumentation/parallel/instrumentation.rb', line 20 def setup_for_txn_metric_merge_at_exit # Clear out any existing transaction metrics to prevent duplicates # when merging metrics back in at the end of the forked process if (txn = NewRelic::Agent::Tracer.current_transaction) txn.instance_variable_set(:@metrics, NewRelic::Agent::TransactionMetrics.new) end # Install at_exit hook only once per process unless @parallel_at_exit_installed @parallel_at_exit_installed = true at_exit do # Merge all newly recorded metrics back into the parent process # It's a little weird, but needed because the transaction does not # finish in the child processes, so without this the metrics would be lost. if (txn = NewRelic::Agent::Tracer.current_transaction) NewRelic::Agent.agent.stats_engine.merge_transaction_metrics!( txn.metrics, txn.best_name ) end # force data to be sent back to the parent process NewRelic::Agent.agent&.stop_event_loop NewRelic::Agent.agent&.flush_pipe_data end end end |
#worker_with_tracing(channel_id, &block) ⇒ Object
This runs inside of the new process that was forked by Parallel
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/new_relic/agent/instrumentation/parallel/instrumentation.rb', line 9 def worker_with_tracing(channel_id, &block) NewRelic::Agent.after_fork( :report_to_channel => channel_id, :report_instance_busy => false ) setup_for_txn_metric_merge_at_exit yield end |