add x-request-id to proxy root span

This commit is contained in:
A.Unger
2021-08-12 12:13:52 +02:00
parent 778ad717df
commit 8499187315

View File

@@ -11,6 +11,8 @@ import (
"strings"
"time"
"go.opentelemetry.io/otel/attribute"
"github.com/owncloud/ocis/ocis-pkg/log"
pkgtrace "github.com/owncloud/ocis/ocis-pkg/tracing"
"github.com/owncloud/ocis/proxy/pkg/config"
@@ -224,6 +226,12 @@ func (p *MultiHostReverseProxy) ServeHTTP(w http.ResponseWriter, r *http.Request
ctx, span = tracer.Start(ctx, fmt.Sprintf("%s %v", r.Method, r.URL.Path))
defer span.End()
span.SetAttributes(
attribute.KeyValue{
Key: "x-request-id",
Value: attribute.StringValue(r.Header.Get("X-Request-ID")),
})
pkgtrace.Propagator.Inject(ctx, propagation.HeaderCarrier(r.Header))
p.ReverseProxy.ServeHTTP(w, r.WithContext(ctx))