Skip to content

Conversation

@SylvainJuge
Copy link
Member

@SylvainJuge SylvainJuge commented Nov 12, 2020

What does this PR do?

Fixes #1503

Checklist

  • This is a bugfix
    • I have updated CHANGELOG.asciidoc
    • I have added tests that would fail without this fix tested locally with async-profiler
@ghost
Copy link

ghost commented Nov 12, 2020

💚 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

Expand to view the summary

Build stats

  • Build Cause: [Pull request #1508 updated]

  • Start Time: 2020-11-24T15:10:26.890+0000

  • Duration: 46 min 11 sec

Test stats 🧪

Test Results
Failed 0
Passed 1616
Skipped 12
Total 1628

Copy link
Contributor

@eyalkoren eyalkoren left a comment

Choose a reason for hiding this comment

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

Leaking a member of a pooled object to another pooled object is very problematic.

I think we should avoid adding the header field to the tracestate list (in TraceState#set()) and adjust the TraceState#toTextHeader() method (as well as the TraceState.TextTracestateAppender#join() method) to append it only when required.
TraceState#copyFrom() already takes care of copying the header value.
This probably means we should change tracestate to be a list of Strings, as opposed to what I previously suggested...

One additional thing to fix is resetting header in TraceState#resetState.

@codecov-io
Copy link

Codecov Report

Merging #1508 (043679b) into master (7233789) will decrease coverage by 0.00%.
The diff coverage is 94.44%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #1508 +/- ## ============================================ - Coverage 58.96% 58.96% -0.01%  Complexity 92 92 ============================================ Files 392 392 Lines 17638 17632 -6 Branches 2447 2446 -1 ============================================ - Hits 10401 10397 -4  + Misses 6520 6517 -3  - Partials 717 718 +1 
Impacted Files Coverage Δ Complexity Δ
...elastic/apm/agent/impl/transaction/TraceState.java 93.68% <88.88%> (-0.44%) 0.00 <0.00> (ø)
...astic/apm/agent/impl/sampling/ConstantSampler.java 100.00% <100.00%> (ø) 0.00 <0.00> (ø)
...ic/apm/agent/impl/sampling/ProbabilitySampler.java 100.00% <100.00%> (ø) 0.00 <0.00> (ø)
...astic/apm/agent/impl/transaction/TraceContext.java 75.00% <100.00%> (ø) 0.00 <0.00> (ø)
...o/elastic/apm/agent/profiler/SamplingProfiler.java 72.72% <0.00%> (-0.24%) 0.00% <0.00%> (ø%)
...ic/apm/agent/profiler/collections/LongHashSet.java 17.06% <0.00%> (+1.19%) 0.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7233789...043679b. Read the comment docs.

Copy link
Contributor

@eyalkoren eyalkoren left a comment

Choose a reason for hiding this comment

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

LGTM.
Few minor comment.

double getSampleRate();

// While header is not related to sampler itself, putting this here allows to reuse the same
// String instance as long as the sample rate does not change to minimize allocation
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Can be added to the javadoc

@elastic elastic deleted a comment from eyalkoren Nov 23, 2020
@SylvainJuge SylvainJuge merged commit 1cbed06 into elastic:master Nov 24, 2020
@SylvainJuge SylvainJuge deleted the fix-tracestate-extra-allocation branch November 24, 2020 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants