Optimize setting parameters for transactions #1158
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.
With the recent refactoring of the Rack middleware, I changed how we set the request parameters on the transaction. Previously, we read the parameters from the request object in the transaction when we sampled it. Not always.
Now that we use the currently active transaction when a transaction is already active, I needed to update how we set parameters using the
set_params
/set_params_if_nil
helpers. These helper methods require us to pass in the parsed parameters, potentially making every request slower because it has to fetch and parse the request parameters.Add a block argument to the
set_params
/set_params_if_nil
helpers to fetch and parse the parameters only when we sample the transaction. This change should reduce the AppSignal overhead for non-sampled transactions.I have no specific preference if the argument or block is leading. I chose the argument to be leading.
Based on #1154
To do