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

Clarify that a compression-eligible span must not be buffered on an already ended parent #632

Merged
merged 1 commit into from
Apr 20, 2022

Conversation

trentm
Copy link
Member

@trentm trentm commented Apr 5, 2022

Otherwise, if a compression-eligible span ends after its parent has
ended, then buffering it on the parent will result in it (or its later
sibling) not being reported.

elastic/apm-agent-nodejs#2623 (review) shows and discusses a Node.js example where a compression-eligible span ends after its parent has ended. (This isn't a far-fetched scenario in Node.js.)

Checklist

  • May the instrumentation collect sensitive information, such as secrets or PII (ex. in headers)?
    • Yes
      • Add a section to the spec how agents should apply sanitization (such as sanitize_field_names)
    • No
      • Why?
    • n/a
  • Create PR as draft
  • Approval by at least one other agent
  • Mark as Ready for Review (automatically requests reviews from all agents and PM via CODEOWNERS)
    • Remove PM from reviewers if impact on product is negligible
    • Remove agents from reviewers if the change is not relevant for them
  • Approved by at least 2 agents + PM (if relevant)
  • Merge after 7 days passed without objections
  • Create implementation issues through the meta issue template (this will automate issue creation for individual agents)

…lready ended parent

Otherwise, if a compression-eligible span ends after its parent has
ended, then buffering it on the parent will result in it (or its later
sibling) not being reported.
@trentm trentm requested review from astorm and felixbarny April 5, 2022 21:26
@trentm trentm self-assigned this Apr 5, 2022
@apmmachine
Copy link

apmmachine commented Apr 5, 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-04-18T05:24:00.836+0000

  • Duration: 3 min 0 sec

@felixbarny felixbarny requested a review from jackshirazi April 6, 2022 05:23
@@ -172,7 +173,7 @@ void onEnd() {
}

void onChildEnd(Span child) {
if (!child.isCompressionEligible()) {
if (ended || !child.isCompressionEligible()) {
Copy link
Member

Choose a reason for hiding this comment

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

This could be subject to a race condition (check-then-act). What if the parent is ended in a different thread concurrently to this method executing? We could then end up adding the child on a buffer of an already ended span. The child would then never get reported.

Is there a way to avoid this scenario, without having to use locks in onChildEnd?

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like it's acceptable to drop those spans. My thinking is that the scenario where you have this race condition is one of load and in that state there are a lot of spans being reported and any one span missed doesn't significantly affect what gets reported

Copy link
Member

@felixbarny felixbarny left a comment

Choose a reason for hiding this comment

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

Even though there may be a race condition, this is better than before.

@trentm trentm marked this pull request as ready for review April 7, 2022 16:00
@trentm trentm requested review from a team as code owners April 7, 2022 16:00
@trentm trentm removed request for a team April 7, 2022 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants