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


#1

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?


#2

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
    state.reset
    NewRelic::Agent::Transaction.wrap(state, "Controller/#{controller_name}/fork_block", :controller)  do
      yield
    end
    NewRelic::Agent.shutdown
    Kernel.exit! #prevent at_exit
  end
...
end

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


#3

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