Skip to content

QueryHost claims the Context trace id on the outbound request - #774

Merged
ar merged 1 commit into
mainfrom
feature/queryhost-trace-claim
Sep 5, 2026
Merged

ar merged 1 commit into
mainfrom
feature/queryhost-trace-claim

Conversation

@ar

@ar ar commented Sep 5, 2026

Copy link
Copy Markdown
Member

Implements #773. Follow-up to #769.

What

Before handing the request to the MUX, QueryHost sets the Context's TRACE_ID as the message's claim when the message has no claim of its own, the same pattern SendResponse uses for the response. An existing claim is left alone; a Context without a trace id leaves the message untouched.

Why

When QueryHost forwards the inbound request unchanged, the outbound leg already shares the inbound trace id through the content-derived natural id. When an edge component builds a new outbound message (different STAN, TID, MID or format), that message has its own natural id and the leg was a separate trace. With the claim, BaseChannel stamps the outbound send event with the leg's id as trace-id and the inbound id as trace-claimed, which links the two.

The host's response receive event still carries only the leg's id, since the claim cannot reach it before the receive event is emitted. The TM event contains the response and the leg's send event carries trace-claimed, so the join is two hops. Stamping the response itself needs an id on the wire (CMF 113.22 filter, separate).

Custom participants that build their own outbound message should apply the same lines.

Tests

Three cases added to QueryHostTest: claim set from the Context (and carried by the cloned response), existing claim left alone, no trace id in the Context. Full :jpos:test and :jpos:javadoc pass.

When an edge component builds a new outbound message, its natural trace
id differs from the inbound transaction's. QueryHost now sets the
Context's TRACE_ID as the message's claim when it has none, so the
outbound send event carries the inbound id as trace-claimed and the two
legs link. An existing claim is left alone.

Closes #773
@ar
ar merged commit 5fac8d5 into main Sep 5, 2026
1 check passed
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