Skip to content

fix(spans): the consumer span is its own span, parented under the producer (SPEC §13.1.1) - #1

Open
clayroach wants to merge 1 commit into
AgentMesh-Community:mainfrom
clayroach:fix/consumer-span-own-id
Open

clayroach wants to merge 1 commit into
AgentMesh-Community:mainfrom
clayroach:fix/consumer-span-own-id

Conversation

@clayroach

@clayroach clayroach commented Oct 2, 2026 •

Copy link
Copy Markdown

Issue

The receiver closed its consumer span on the inbound env.trace unchanged. That trace is the sender's producer span, so both halves of a hop shared one span_id and parent. The consumer ended up as the producer's sibling, not its child (SPEC §13.1.1: "the consumer's parent_span_id is the producer's span_id"). Calls made from inside the handler then hung off the producer span instead of the consumer span (§13.1: "Set parent_span_id to its own span_id").

before:  producer(A) ── consumer(A, same id) ── handler calls → parent A
after:   producer(A) └─ consumer(B, parent A) └─ handler calls → parent B

Changes

  • src/mesh.ts: request dispatch now creates childSpan(env.trace) and uses it for the consumer span, ctx.traceContext and runWithTrace.
  • __tests__/unit/consumer-span.test.ts: new test through the real dispatch path. It checks the consumer's parent and span_id, ctx.traceContext, and the parent of a delegated call. It fails on main and passes with this change.
  • CHANGELOG.md: Unreleased entry.

npm run lint and npm test pass. fast-nkeys.test.ts › "throws on the same bad input as before" fails now and then in full runs, on main too. It is unrelated to this change.

…ducer

The consumer span carried the inbound envelope trace unchanged, which is
the producer span, so both halves of a hop shared one span_id (SPEC
13.1.1). Use childSpan(env.trace) for the consumer span, ctx.traceContext
and the ambient trace.
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.

1 participant