diff --git a/gorequest.go b/gorequest.go index 8edb0fc..f179a54 100644 --- a/gorequest.go +++ b/gorequest.go @@ -19,6 +19,8 @@ import ( "strings" "time" + "github.com/opentracing/opentracing-go" + "github.com/pkg/errors" "mime/multipart" @@ -88,6 +90,7 @@ type SuperAgent struct { Attempt int Enable bool } + SpanContext opentracing.SpanContext //If true prevents clearing Superagent data and makes it possible to reuse it for the next requests DoNotClearSuperAgent bool } @@ -1258,6 +1261,14 @@ func (s *SuperAgent) MakeRequest() (*http.Request, error) { return nil, err } + if s.SpanContext != nil { + // fmt.Println("reject header") + opentracing.GlobalTracer().Inject( + s.SpanContext, + opentracing.HTTPHeaders, + opentracing.HTTPHeadersCarrier(req.Header)) + } + for k, vals := range s.Header { for _, v := range vals { req.Header.Add(k, v)