Skip to content

Commit

Permalink
Merge pull request #367 from askuy/feature/http_traceid
Browse files Browse the repository at this point in the history
fix resty http trace id bug
  • Loading branch information
askuy authored Dec 29, 2023
2 parents 68b343b + da05004 commit 9c0144e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client/ehttp/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/go-resty/resty/v2"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
"go.opentelemetry.io/otel/trace"

Expand Down Expand Up @@ -169,7 +170,9 @@ func traceInterceptor(name string, config *Config, logger *elog.Component, build
semconv.RPCSystemKey.String("http"),
}
beforeFn := func(cli *resty.Client, req *resty.Request) error {
ctx, span := tracer.Start(req.Context(), req.Method, nil, trace.WithAttributes(attrs...))
// 需要拿到header,才能将链路穿起来
carrier := propagation.HeaderCarrier(req.Header)
ctx, span := tracer.Start(req.Context(), req.Method, carrier, trace.WithAttributes(attrs...))
span.SetAttributes(
semconv.PeerServiceKey.String(name),
semconv.HTTPMethodKey.String(req.Method),
Expand Down

0 comments on commit 9c0144e

Please sign in to comment.