diff --git a/fetcher.go b/fetcher.go index 728fd37..f9e3729 100644 --- a/fetcher.go +++ b/fetcher.go @@ -13,6 +13,7 @@ import ( "strings" "time" + "github.com/willscott/go-requestcontext" "go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -60,6 +61,7 @@ func (p *pool) fetchResource(ctx context.Context, from *Node, resource string, m requestId := uuid.NewString() goLogger.Debugw("doing fetch", "from", from, "of", resource, "mime", mime, "requestId", requestId) + contextRequestId := requestcontext.IDFromContext(ctx) start := time.Now() response_success_end := time.Now() @@ -197,6 +199,9 @@ func (p *pool) fetchResource(ctx context.Context, from *Node, resource string, m } req.Header.Add("Accept", mime) + if contextRequestId != "" { + req.Header.Add("X-Request-Id", contextRequestId) + } if p.config.ExtraHeaders != nil { for k, vs := range *p.config.ExtraHeaders {