appsignal-ruby icon indicating copy to clipboard operation
appsignal-ruby copied to clipboard

Rails runner support

Open adamyeats opened this issue 4 years ago • 3 comments

Add support for error reporting from inside Rails runners: https://guides.rubyonrails.org/command_line.html#rails-runner

adamyeats avatar Jul 10 '20 10:07 adamyeats

@xadamy can you link to the intercom convo that brought this to our attention?

tombruijn avatar Jul 10 '20 11:07 tombruijn

https://app.intercom.com/a/apps/yzor8gyw/inbox/inbox/conversation/16410700002295

adamyeats avatar Jul 10 '20 11:07 adamyeats

As a workaround I add this inside the Application class in config/application.rb:

runner do
  next unless defined?(Appsignal) && Appsignal.active?

  action_name = ARGV.first&.truncate(50) || "unknown"

  Kernel.at_exit do
    next unless $!

    Appsignal.send_error($!) do |transaction|
      transaction.set_action action_name
      transaction.set_namespace "background"
    end
    Appsignal.stop "runner"
  end
end

But this way you only get error reporting, not instrumentation. Official support of rails runner would be great.

raulr avatar Feb 17 '21 07:02 raulr