-
Notifications
You must be signed in to change notification settings - Fork 116
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
Conversation
…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.
@@ -172,7 +173,7 @@ void onEnd() { | |||
} | |||
|
|||
void onChildEnd(Span child) { | |||
if (!child.isCompressionEligible()) { | |||
if (ended || !child.isCompressionEligible()) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this 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.
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
sanitize_field_names
)CODEOWNERS
)