Repository navigation
feat(data_streams): keep DSM pathway context in fiber storage on Ruby 3.2+ - #6558
Draft
ericfirth wants to merge 2 commits into
Conversation
Fiber storage is inherited by child fibers, external enumerators, and new threads, so a pathway follows work started from the fiber that consumed it. Ruby < 3.2 keeps fiber-locals. Inherited storage shares the same object, and threads checkpoint concurrently, so checkpoints now copy the context and install the copy instead of mutating it in place. DSM2-484 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 4670443 | Docs | View more details | Give us feedback! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
After #6532, a Data Streams pathway stops at any thread, fiber, or external enumerator started after a consume, so that work's produces start new pathways. Reviewers suggested fiber storage, which Ruby 3.2+ inherits into exactly that work.
What
On Ruby 3.2+ the pathway context lives in fiber storage, so work started after a consume links to the consumed message. Checkpoints now replace the context instead of mutating it, so inherited copies never write into each other.
Risk
Two-way door, scoped to Data Streams when enabled; revert this PR. Emitted data changes on Ruby 3.2+: a long-lived thread started from inside a consumer links to that message until its next checkpoint.
Details
Notes
masteronce fix(data_streams): scope DSM pathway context per thread instead of per process #6532 merges. Opened as a draft while tracing settles its own storage choice in Add Thread-bound tracing context #5226, so DSM and tracing can end up consistent.Fiber[:x] = obj; Thread.new { Fiber[:x].equal?(obj) }istrueon 3.4), and threads checkpoint concurrently. Mutating in place would let a thread started after a consume rewrite the consumer's pathway, which is the bug fix(data_streams): scope DSM pathway context per thread instead of per process #6532 fixed. Each checkpoint now works on adupof the current context and installs it; the fields are integers, times, and strings, so a shallow copy is enough.Fiber.new(storage: nil)), per the review thread on fix(data_streams): scope DSM pathway context per thread instead of per process #6532.Thread#[]), the behavior from fix(data_streams): scope DSM pathway context per thread instead of per process #6532. The implementation is chosen once, when the file loads.spec/datadog/data_streams/processor_spec.rb: a new thread chains onto the consumed pathway; its checkpoints leave the starting thread's context untouched (fails without thedup); an external enumerator chains onto the consumed pathway; on Ruby < 3.2 a new thread starts a new pathway.bundle exec rake spec:core_with_libdatadog_api.🤖 Generated with Claude Code