• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

Rake instrumentation

The New Relic Ruby agent has opt-in support for instrumenting Rake tasks. This requires:

  • Rake version 10.0.0 or higher
  • Ruby agent version 3.13.0 or higher

To instrument Rake tasks, specify the tasks by name in your newrelic.yml file.

Enable Rake support

To instrument your app's Rake tasks, add the names of the target tasks to the rake.tasks element in your newrelic.yml file. The Ruby agent matches these names against your active tasks using string regex.

Example: Instrumenting two Rake tasks

For example, to instrument the Rake tasks deploy and deploy:all, add the following to your newrelic.yml file:

rake:
tasks: ["deploy", "deploy:all"]

Since task name matching is with regex, you can instrument all of your app's Rake tasks by using a wildcard regex like [".+"]. However, this will not include Rake tasks that are in your deny list by default from the autostart.denylisted_rake_tasks configuration setting, such as db:migrate.

  • To include any Rake tasks that are in your deny list by default, include them in your customized deny list.
  • To ensure the tasks are instrumented before they run if you are using Rails but your Rake task does not require the Rails environment, add require 'tasks/newrelic' to the top of the Rake tasks.

Capture Rake job arguments

By default Rake job arguments are not captured. To capture Rake job arguments, use:

attributes.include: job.rake.*
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.