Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #156 from filecoin-saturn/request-id
Browse files Browse the repository at this point in the history
forward context request id to L1s
  • Loading branch information
guanzo authored Sep 6, 2023
2 parents 8b78688 + 1f29aa2 commit fa48718
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"time"

"github.com/filecoin-saturn/caboose/tieredhashing"
"github.com/willscott/go-requestcontext"
"go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -105,6 +106,7 @@ func (p *pool) fetchResource(ctx context.Context, from string, resource string,

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()
Expand Down Expand Up @@ -254,6 +256,9 @@ func (p *pool) fetchResource(ctx context.Context, from string, resource string,
}

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 {
Expand Down

0 comments on commit fa48718

Please sign in to comment.