Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

Multiprocess rails


I have an unusual rails setup. Some controller actions run out of main process using fork. Apparently, in this case, new relic can’t properly trace such actions. Any suggestions on how to add tracing without custom instrumentation?


Awesome New Relic support provided me with the solution:

def fork_block
  background_job = fork do #child!
    NewRelic::Agent.after_fork(:force_reconnect => true)
    state = NewRelic::Agent::TransactionState.tl_get
    NewRelic::Agent::Transaction.wrap(state, "Controller/#{controller_name}/fork_block", :controller)  do
    Kernel.exit! #prevent at_exit

Unfortunately, this leads to forked process being traced as a separate transaction.


Hey @apollo_dev Thanks for letting us know you got a solution :smiley: