Add Rake performance instrumentation #1156
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Rake performance instrumentation
We've had requests from people to instrument Rake tasks for performance over time. I remember giving out a variation of this gist from time to time to make this work for people that wanted it: https://gist.github.com/tombruijn/701a3c5e3f251fb5e3ba8f1f8e908887
Let's add it to AppSignal itself so it can be enabled with a config option, rather than a brittle monkeypatch on top of our existing instrumentation.
It's turned off by default so we don't start collecting a lot more 'requests' that count towards an organization's plan, increasing the cost of AppSignal without notice. We can always decide to enable this in the next major version if we think it's useful to be turned on by default.
Part of #1135
Only call Appsignal.stop once in Rake
In Rake multiple tasks can be executed during the Rake runtime. Either by calling them on the CLI like
rake task1 task2
or in their definition withtask :task1 => :prerequisite_task
.Don't stop AppSignal when every task is done, only the first task will be instrumented. Use the
at_exit
hook to register a block that's executed when the Rake process exits to only callAppsignal.stop
once.