-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
propose: contrib/net/http: add conditional propagation logic to roundTripper configuration #2823
Comments
Hello @eyasy1217, thanks for reaching out. We'll review this during our next gardening session. |
@eyasy1217 What would be the use case? We found it interesting and we are willing to implement it, but we would like to understand the use case. For instance, is it to avoid sending propagation headers to a third party API that isn't able to handle correctly unknown headers? |
It's not such a big use case. |
we have encountered third party api's that limit the # of headers we can send in our requests, being able to disable the propagation headers for that specific request would be useful addition |
@davekerr-orum and/or @eyasy1217 , are you able to share the third party API(s) enforcing this limit? An example would be useful for us to better understand the scope of this problem. |
For anyone interested, you can achieve the desired behavior by chaining your our custom transport with the Datadog one. Example: type removeDDHeadersTransport struct {
base http.RoundTripper
}
func (i *removeDDHeadersTransport) RoundTrip(req *http.Request) (*http.Response, error) {
for name, _ := range req.Header {
if strings.HasPrefix(name, "X-Datadog") {
fmt.Printf("removing Datadog header: %s\n", name)
req.Header.Del(name)
}
}
return i.base.RoundTrip(req)
}
func main() {
// ... initialize the tracer etc.
rt := httptrace.WrapRoundTripper(&removeDDHeadersTransport{base: http.DefaultTransport})
client := &http.Client{Transport: rt}
// do stuff with client
} |
I want to determine whether to propagate or not for each api I call.
For example, when calling a external api, no propagation is performed.
I assume the following code.
The text was updated successfully, but these errors were encountered: