Sometimes it's useful to run arbitrary code inside the agent. The ScoutApm::Debug class lets us install callbacks.
ScoutApm::Debug
For instance, to log a message each time the background worker runs, you could insert this into unicorn.rb:
after_fork do |server, worker| if defined?(ScoutApm::Agent) && defined?(ScoutApm::Debug) ScoutApm::Debug.instance.register_periodic_hook do ScoutApm::Agent.instance.logger.debug("Background worker ran") end end end
There was an error while loading. Please reload this page.