Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize setting parameters for transactions #1158

Merged
merged 1 commit into from
Jul 8, 2024
Merged

Conversation

tombruijn
Copy link
Member

@tombruijn tombruijn commented Jul 5, 2024

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

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.
@tombruijn tombruijn changed the base branch from set_params-helper to main July 8, 2024 11:49
@tombruijn tombruijn merged commit 02f3e70 into main Jul 8, 2024
117 checks passed
tombruijn added a commit that referenced this pull request Jul 8, 2024
Use the improvements from PR #1158 to fetch and set parameters with a
block, only when the transaction is sampled.
tombruijn added a commit that referenced this pull request Jul 10, 2024
Use the improvements from PR #1158 to fetch and set parameters with a
block, only when the transaction is sampled.
@tombruijn tombruijn deleted the optimize-set_params branch July 10, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants