Skip to content

add multivalue headers#216

Merged
ojproductions merged 2 commits into
mainfrom
onzia/multivalue-headers
Oct 6, 2025
Merged

add multivalue headers#216
ojproductions merged 2 commits into
mainfrom
onzia/multivalue-headers

Conversation

@ojproductions
Copy link
Copy Markdown
Contributor

@ojproductions ojproductions commented Sep 23, 2025

What does this PR do?

TLDR: This enables pulling trace context headers from multivalue headers (rather than just regular "headers"). Single value headers still take precedence

Some services pass headers through multivalue headers. Here's a sample request from an AWS Application Load Balancer (ALB):
Screenshot 2025-10-03 at 3 16 46 PM

Prior to this change, when extracting headers using the default extractor, we ignore multiValueheaders resulting in empty or sparse headers:
image

With the changes made, we now do not lose any headers:
image

and can create a valid trace context:
image

note that in the case that trace context values are passed via go context instead of event headers, we are still able to create a traceContext without use of multivalue headers

also, if both headers and multivalueHeaders are provided, regular headers will take precedence in the case of key conflicts

Motivation

Issue #189
APMSVLS-1

Testing Guidelines

I created some unit tests and updated existing ones. Also ran lamba functions to see if expected header was present

Additional Notes

Types of changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Checklist

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog

@ojproductions ojproductions requested a review from a team as a code owner September 23, 2025 15:34
@joeyzhao2018
Copy link
Copy Markdown
Contributor

joeyzhao2018 commented Sep 26, 2025

The code in this PR sees all reasonable. But I believe your plan is to split them into multiple PRs? The struggle from code reviewer's perspective is that it's hard to see how all these changes are effective in the end when combined.
In short, can you clarify how those header values eventually get used? thx

@ojproductions
Copy link
Copy Markdown
Contributor Author

@joeyzhao2018 For sure! Some AWS services use multivalue headers instead of regular headers. Currently, when extracting context from headers using the default extractor, we only extract from the regular headers and dont check multivalue headers. This change essentially fixes that.

Copy link
Copy Markdown
Contributor

@joeyzhao2018 joeyzhao2018 left a comment

Choose a reason for hiding this comment

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

LGTM. Can you por this change to https://github.com/DataDog/dd-trace-go/tree/main/contrib/aws/datadog-lambda-go too? Thank you. 🙇‍♂️

@ojproductions ojproductions merged commit db0c56c into main Oct 6, 2025
9 checks passed
@ojproductions ojproductions deleted the onzia/multivalue-headers branch October 6, 2025 16:51
@ojproductions ojproductions changed the title add multivalue headers, resolves #189 add multivalue headers Oct 9, 2025
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.

2 participants