Skip to content

fix(triple): preserve otel traceparent in TripleInvoker#3285

Open
nanjiek wants to merge 12 commits intoapache:developfrom
nanjiek:last_version
Open

fix(triple): preserve otel traceparent in TripleInvoker#3285
nanjiek wants to merge 12 commits intoapache:developfrom
nanjiek:last_version

Conversation

@nanjiek
Copy link
Copy Markdown
Contributor

@nanjiek nanjiek commented Apr 7, 2026

Description

Fixes #3240

This change fixes the traceparent corruption in Triple client calls.

Although OtelClientTrace correctly creates a client span and injects a fresh traceparent, the old TripleInvoker logic could overwrite it with the upstream traceparent from context attachments, and then append that value into the outgoing header. This caused downstream spans to attach to the wrong parent and also leaked trace headers across repeated Triple calls on the same base context.

The fix removes user attachment backfill from context during Triple invocation, rebuilds outgoing headers from a cloned copy and overwrites keys instead of appending, and deep-copies outgoing context metadata to avoid cross-call header mutation. With this change, each downstream Triple call carries the traceparent of the current client span, and sibling calls no longer interfere with each other.

Checklist

  • I confirm the target branch is develop
  • Code has passed local testing
  • I have added tests that prove my fix is effective or that my feature works

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

@Alanxtl Alanxtl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment on lines -207 to -215
// retrieve users passed-in attachment
attaRaw := ctx.Value(constant.AttachmentKey)
if attaRaw != nil {
if userAtta, ok := attaRaw.(map[string]any); ok {
for key, val := range userAtta {
invocation.SetAttachment(key, val)
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为啥删了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] OtelClientTrace filter 的 traceparent 被 triple_invoker 破坏,导致链路追踪 parent 错乱

2 participants