mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-14 21:33:34 -04:00
ignore not okay context decoding
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"go.opencensus.io/plugin/ochttp/propagation/tracecontext"
|
||||
@@ -20,11 +21,14 @@ type tracing struct {
|
||||
|
||||
// ServeHTTP implements the Service interface.
|
||||
func (t tracing) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
var ctx context.Context
|
||||
var span *trace.Span
|
||||
tp := tracecontext.HTTPFormat{}
|
||||
sc, _ := tp.SpanContextFromRequest(r)
|
||||
|
||||
ctx, span := trace.StartSpanWithRemoteParent(r.Context(), r.URL.String(), sc)
|
||||
defer span.End()
|
||||
sc, ok := tp.SpanContextFromRequest(r)
|
||||
if ok {
|
||||
ctx, span = trace.StartSpanWithRemoteParent(r.Context(), r.URL.String(), sc)
|
||||
defer span.End()
|
||||
}
|
||||
|
||||
t.next.ServeHTTP(w, r.WithContext(ctx))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user