Created
July 5, 2021 02:19
-
-
Save garystafford/9792131de51cddca766fb0aea443270e to your computer and use it in GitHub Desktop.
This file contains 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
func injectHeadersIntoMetadata(ctx context.Context, req *http.Request) metadata.MD { | |
headers := []string{ | |
"x-request-id", | |
"x-b3-traceid", | |
"x-b3-spanid", | |
"x-b3-parentspanid", | |
"x-b3-sampled", | |
"x-b3-flags", | |
"x-ot-span-context"} | |
var pairs []string | |
for _, h := range headers { | |
if v := req.Header.Get(h); len(v) > 0 { | |
pairs = append(pairs, h, v) | |
} | |
} | |
return metadata.Pairs(pairs...) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment