elastic / ecs-logging-java

https://www.elastic.co/guide/en/ecs-logging/java/current/intro.html
Apache License 2.0
139 stars 74 forks source link

Reduce allocations for formatting exception stack traces #178

Closed HaloFour closed 2 years ago

HaloFour commented 2 years ago

Reduces the number of allocations when formatting exception stack traces.

  1. Accepts a CharSequence instead of a String so that an underlying StringBuilder can be passed directly without requiring an intermediate allocation.
  2. Reimplements EcsJsonSerializer#formatStackTraceAsArray to use Matcher to iterate over the CharSequence to avoid allocating the ArrayList<String>, String[] and each individual String element.
apmmachine commented 2 years ago

:green_heart: 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-04-26T14:42:05.193+0000 * Duration: 8 min 40 sec #### Test stats :test_tube: | Test | Results | | ------------ | :-----------------------------: | | Failed | 0 | | Passed | 198 | | Skipped | 0 | | Total | 198 |

:robot: GitHub comments

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

eyalkoren commented 2 years ago

Thanks for this PR! Please see https://github.com/HaloFour/ecs-logging-java/pull/1 which proposes some further allocation reduction.

HaloFour commented 2 years ago

Thanks for the assist! 😃