Fix varmap to apply func before recursion #1593
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.
What does this pull request do?
We use
varmap()
to applyshorten()
recursively across a data structure.varmap()
was recursing into the data structures, and then applying thefunc()
(in this case,shorten()
) on the way back out of recursion. This meant that when shortening local variables where just recursing over the data structure was a performance issue, settingELASTIC_APM_LOCAL_VAR_LIST_MAX_LENGTH
wouldn't actually affect the runtime, just the output.With this change, dictionaries and lists will be shortened and then we'll iterate over their contents. Shouldn't affect
_sanitize()
at all, but will speed upshorten()
considerably.I think the test surface on this function is sufficient without adding tests for this fix.
Related issues
Closes #1592