Skip to content

Fix varmap to apply func before recursion #1593

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

Merged
merged 2 commits into from
Jul 22, 2022
Merged

Conversation

basepi
Copy link
Contributor

@basepi basepi commented Jul 21, 2022

What does this pull request do?

We use varmap() to apply shorten() recursively across a data structure. varmap() was recursing into the data structures, and then applying the func() (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, setting ELASTIC_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 up shorten() considerably.

I think the test surface on this function is sufficient without adding tests for this fix.

Related issues

Closes #1592

@apmmachine
Copy link
Contributor

apmmachine commented Jul 21, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-07-21T23:16:47.661+0000

  • Duration: 26 min 44 sec

Test stats 🧪

Test Results
Failed 0
Passed 4922
Skipped 3455
Total 8377

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /test linters : Run the Python linters only.

  • /test full : Run the full matrix of tests.

  • /test benchmark : Run the APM Agent Python benchmarks tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@apmmachine
Copy link
Contributor

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (68/68) 💚
Files 100.0% (227/227) 💚
Classes 100.0% (227/227) 💚
Lines 89.642% (17257/19251) 👍 0.022
Conditionals 76.869% (3147/4094) 👍 0.098
Copy link
Contributor

@beniwohli beniwohli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! LGTM

@basepi basepi merged commit 79b58ce into elastic:main Jul 22, 2022
@basepi basepi mentioned this pull request Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
close