Add PropagatingInMemory testkit backend#1335
Draft
kubukoz wants to merge 3 commits into
Draft
Conversation
InMemory records a command log but gives every span an empty/inherited kernel and a None spanId, so it cannot model trace context propagation. PropagatingInMemory assigns each span a distinct id, exposes it via spanId and kernel, and resolves an explicit parentKernel over the enclosing span when creating children (exposing the resolved parent as Span.parentId). This makes it possible to assert that a continued span is really a child of the span whose kernel was propagated to it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
a196862 to
5da13ce
Compare
groupMapReduce is 2.13+. Replaced with groupBy(_.name).map(k -> v.head), which keeps the first Recorded per name identically and compiles on 2.12. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Scaladoc rejects a /** */ comment on a constructor parameter (val parentId) as an "unmoored doc comment", failing doc generation under fatal warnings. Made it a regular // comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
Adds
PropagatingInMemory, a testkitEntryPoint/Spanimplementation that models trace context propagation, complementing the existingInMemory.InMemoryrecords a command log but gives every span an empty/inheritedkerneland aNonespanId, so it can't express parentage — you can't assert that a continued span is really a child of the span whose kernel was propagated to it.PropagatingInMemory:Concurrentcounter), exposed idiomatically throughspanIdand itskernel(under theX-Natchez-Span-Idheader);parentKernel(fromSpan.Options.parentKernel) over the enclosing span when creating a child — the semantic real backends implement;Span.parentId, and records each created span (Recorded(name, id, parentId)) queryable viaEntryPoint#spans.Why
Testing that instrumentation propagates trace context across boundaries (e.g. a cache loader that continues a span from a kernel handed to it) currently isn't possible with the shipped testkit — every
InMemoryspan hands out the same kernel and no id. This backend makes those assertions straightforward while leavingInMemorycompletely untouched.Notes / open questions
InMemory— all existingcore-testsfixtures pass unchanged.PropagatingInMemorySuitedemonstrates: distinct ids surfaced viaspanId/kernel, child parented to enclosing span, explicitparentKernelwinning over the enclosing span, and concurrent children each keeping their own parent with no id collision.PropagatingInMemory,Recorded,spans) and whether this belongs as a sibling vs. an extension ofInMemoryare open to feedback.🤖 Generated with Claude Code