Integrations
Rails applications
For Rails applications make sure you depend on the:environment task. This loads the Rails application into memory and starts AppSignal as part of the application.
Rakefile
Your Rails application’sRakefile should look something like the example below. This should already be the case, no need to change it.
< 1, you will need to require the Rake integration manually. It is automatically loaded for version 1.x and higher.)
Ruby applications
For pure Ruby applications some extra steps are required to load AppSignal. AppSignal needs to be required, configured and loaded. See also our integration guide.Monitoring Rake task performance
To monitor Rake task performance and all events that occur in the task, configure AppSignal with theenable_rake_performance_instrumentation config option set to true.
With this feature enabled, all Rake tasks will instrumented and counted towards your plan.
Stop requirement
For Rake tasks running on short-lived hosts, it is required to stop the AppSignal Ruby gem before the Rake process exits. This will ensure it reports the data from the Rake tasks to AppSignal before the host shuts down. This behavior is only needed in such scenarios like:- When a scheduled Rake task (a cron job) is run by a hosting service.
- When a Rake task is run on a container that starts to run this Rake task and shuts down when the Rake task exits.
- When a Rake task is run on a Heroku runner, or similar hosting providers.
enable_at_exit_hook option.
Ensure this option is set to true for scripts that require AppSignal to be stopped, if it’s not automatically detected.
It may be needed to add an additional sleep call of a couple seconds to ensure there’s enough time to send all the data. Use the at_exit usage example from the code below if needed.
Stop requirement legacy
When running a single Rake task on a short-lived host (e.g. with Docker containers, Kubernetes or Heroku schedulers) there are three requirements. This guarantees that the app’s AppSignal extension has time to flush the data to the agent and the agent has time to send the data to our API before shutting (the container) down. The requirements are:Appsignal.stopmust be called in the Rake task.- When Rake task performance monitoring is enabled, this is done automatically for all tasks.
running_in_containermust be set to true in the config.- For most containers types
running_in_containeris automatically set to true when detected, for others manual configuration is required.
- For most containers types
- A sleep of e.g. 10 seconds to give AppSignal agent time to sent the data
Appsignal.stop is called in the Rakefile:
Appsignal.stop call flushes all the transaction data currently in the AppSignal extension to our agent.
It then sleeps for 10 seconds to allow the agent to send the data before shutting down.