Do not remove client span if incoming request has "uber-trace-id" header#341
Open
rafis wants to merge 1 commit intoopentracing-contrib:masterfrom
Open
Do not remove client span if incoming request has "uber-trace-id" header#341rafis wants to merge 1 commit intoopentracing-contrib:masterfrom
rafis wants to merge 1 commit intoopentracing-contrib:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that the client span is preserved when an incoming request contains the "uber-trace-id" header by modifying how headers are merged.
- Replace addAll with a loop that adds headers only if absent using the first value in each header.
- Change header insertion in the builder to use putIfAbsent, preventing overwriting of existing headers.
Comments suppressed due to low confidence (1)
instrument-starters/opentracing-spring-cloud-gateway-starter/src/main/java/io/opentracing/contrib/spring/cloud/gateway/TraceRequestHttpHeadersFilter.java:91
- Using putIfAbsent here prevents overwriting of existing headers, but may also bypass merging where multiple values are expected. Confirm that this logic is consistent with how header values should be combined during propagation.
headersWithInput.putIfAbsent(key, value);
| } | ||
| headersWithInput.addAll(input); | ||
| for (Map.Entry<String, List<String>> entry : input.entrySet()) { | ||
| headersWithInput.addIfAbsent(entry.getKey(), entry.getValue().get(0)); |
There was a problem hiding this comment.
Only the first value of each header is preserved here, which may drop additional header values that might be required for some cases. Consider a solution that combines all values if preserving the full header list is necessary.
Suggested change
| headersWithInput.addIfAbsent(entry.getKey(), entry.getValue().get(0)); | |
| headersWithInput.addAll(entry.getKey(), entry.getValue()); |
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.
Closes #340