newrelic-ruby-agent icon indicating copy to clipboard operation
newrelic-ruby-agent copied to clipboard

Default behaviour of rake instrumentation is not clear

Open robotfelix opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe.

It has recently come to my attention that none of our rake tasks are being instrumented. Trying to understand the expected default behavior is difficult from newrelic.yml.

Between a clean newrelic.yml and looking at the defaults you get:

  • autostart.denylisted_rake_tasks: (a whole load of common tasks specified by AUTOSTART_DENYLISTED_RAKE_TASKS)
  • instrumentation.rake: auto
  • rake.tasks: [] (this bit of config is furthest down the file!)
  • disable_rake: false (not in newrelic.yml)

I'd expected leaving instrumentation.rake: auto and customising autostart.denylisted_rake_tasks to automatically instrument rake tasks that were not on the deny-list, but this isn't the case.

Looking in the code, it looks like you are supposed to manually specify a list of rake tasks to instrument "automatically", which is surprising in two ways:

  1. Manually specifying a list of tasks isn't really what I'd call "automatic" instrumentation. Certainly not in the same way as, say, the ActiveRecord instrumentation (where I don't need to list out all the models explicitly)
  2. It's quite common to either deny by default and have a defined allow-list, or to allow (instrument) by default and have a defined deny-list. However having an allow-list and then applying a deny-list against the allow-list is both unusual and unintuitive. If you have to list out the tasks in rake.tasks, it's not clear why you would then deny a task via autostart.denylisted_rake_tasks rather than just removing it from rake.tasks.

Feature Description

Some possible actions I'd like to see at least one of:

  • Updating the clean newrelic.yml comments to make it clear that no rake tasks will be instrumented without them being added to rake.tasks first
  • Updating the clean newrelic.yml comments to include the "allow all" regex from this documentation
  • Updating the clean newrelic.yml comments to include a link to the rake setup documentation if it's not intuitive without reading it.
  • Changing the default behaviour of "auto" to be to instrument all rake tasks except those on the deny-list. (I appreciate this is probably a step too far)

Describe Alternatives

I think this is covered above

Additional context

I think the above is clear enough

Priority

Nice to Have

robotfelix avatar Apr 14 '22 11:04 robotfelix

Hello @robotfelix!

Thank you for reaching out and bringing this to our attention. I think these are excellent recommendations. I've taken immediate action on your documentation points. I've integrated them into PR #1095. Would you be willing to take a look to see if this makes the configuration's behavior more clear?

For your final point, "Changing the default behaviour of 'auto' to be to instrument all rake tasks except those on the deny-list.", I think it's best to bring to our product manager, @elucus, to review. I'll transition this issue to his review state.

kaylareopelle avatar Apr 16 '22 00:04 kaylareopelle

https://issues.newrelic.com/browse/NEWRELIC-3460

Resolved with #1095

fallwith avatar Jun 05 '23 23:06 fallwith