mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-13 12:48:56 -04:00
create span regardless of a context or not
This commit is contained in:
@@ -14,10 +14,15 @@ func Trace(next http.Handler) http.Handler {
|
||||
var span *trace.Span
|
||||
|
||||
tc := tracecontext.HTTPFormat{}
|
||||
sc, ok := tc.SpanContextFromRequest(r)
|
||||
if ok {
|
||||
// reconstruct span context from request
|
||||
if sc, ok := tc.SpanContextFromRequest(r); ok {
|
||||
// if there is one, add it to the new span
|
||||
ctx, span = trace.StartSpanWithRemoteParent(r.Context(), r.URL.String(), sc)
|
||||
defer span.End()
|
||||
} else {
|
||||
// create a new span if there is no context
|
||||
ctx, span = trace.StartSpan(r.Context(), r.URL.String())
|
||||
defer span.End()
|
||||
}
|
||||
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
|
||||
Reference in New Issue
Block a user