Skip to content

propose: contrib/net/http: add conditional propagation logic to roundTripper configuration #2823

Open
@eyasy1217

Description

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.

// https://github.com/DataDog/dd-trace-go/blob/e4985df5f9ef6a5b1f5cc9f72b03ddddcb4af0bc/contrib/net/http/option.go#L138
type roundTripperConfig struct {
	// ...
+	propagationFunc func(*http.Request) bool
	// ...
}


func (rt *roundTripper) RoundTrip(req *http.Request) (res *http.Response, err error) {
	// ...

	// https://github.com/DataDog/dd-trace-go/blob/e4985df5f9ef6a5b1f5cc9f72b03ddddcb4af0bc/contrib/net/http/roundtripper.go#L73
-	if rt.cfg.propagation {
+	if rt.cfg.propagation && rt.cfg.propagationFunc(r2) {

Metadata

Assignees

Labels

apm:ecosystemcontrib/* related feature requests or bugsenhancementquick change/addition that does not need full team approval

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions