Skip to content

Commit

Permalink
fix: #2 wrong tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
aschenmaker committed Sep 17, 2021
1 parent 74ccef7 commit f99b204
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func New(config Config) fiber.Handler {
}
var span opentracing.Span

tracsacationName := cfg.TransacationName(c)
TransacationName := cfg.TransacationName(c)
tracer := cfg.Tracer
header := make(http.Header)

Expand All @@ -31,12 +31,11 @@ func New(config Config) fiber.Handler {
})

// Extract trace-id from header
spop := HeaderExtractor(header)

if spop != nil {
span = tracer.StartSpan(tracsacationName, spop)
sc, err := tracer.Extract(opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(header))
if err == nil {
span = tracer.StartSpan(TransacationName, opentracing.ChildOf(sc))
} else {
span = tracer.StartSpan(tracsacationName)
span = tracer.StartSpan(TransacationName)
}

cfg.Modify(c, span)
Expand All @@ -52,11 +51,3 @@ func New(config Config) fiber.Handler {
return c.Next()
}
}

func HeaderExtractor(hdr http.Header) opentracing.StartSpanOption {
sc, err := opentracing.GlobalTracer().Extract(opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(hdr))
if err != nil {
return nil
}
return opentracing.ChildOf(sc)
}

0 comments on commit f99b204

Please sign in to comment.