feat: add userid to spans (#2536)

This commit is contained in:
Michael Barz
2026-03-30 10:32:24 +02:00
committed by GitHub
parent 3e6a1e69fc
commit f0836c54fb
3 changed files with 8 additions and 0 deletions

View File

@@ -41,6 +41,7 @@ func CollaborationTracingMiddleware(next http.Handler) http.Handler {
if wopiUser, ok := ctxpkg.ContextGetUser(r.Context()); ok {
attrs = append(attrs, []attribute.KeyValue{
attribute.String("enduser.id", wopiUser.GetId().GetOpaqueId()),
attribute.String("cs3.user.idp", wopiUser.GetId().GetIdp()),
attribute.String("cs3.user.opaque", wopiUser.GetId().GetOpaqueId()),
attribute.String("cs3.user.type", wopiUser.GetId().GetType().String()),

View File

@@ -10,6 +10,7 @@ import (
"github.com/opencloud-eu/opencloud/services/proxy/pkg/router"
"github.com/opencloud-eu/opencloud/services/proxy/pkg/user/backend"
"github.com/opencloud-eu/opencloud/services/proxy/pkg/userroles"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
cs3user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
@@ -235,6 +236,8 @@ func (m accountResolver) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
}
span.SetAttributes(attribute.String("enduser.id", user.GetId().GetOpaqueId()))
ri := router.ContextRoutingInfo(ctx)
if ri.RemoteUserHeader() != "" {
req.Header.Set(ri.RemoteUserHeader(), user.GetId().GetOpaqueId())

View File

@@ -8,6 +8,8 @@ import (
"github.com/opencloud-eu/opencloud/pkg/log"
revactx "github.com/opencloud-eu/reva/v2/pkg/ctx"
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
const (
@@ -121,6 +123,8 @@ func (a PublicShareAuthenticator) Authenticate(r *http.Request) (*http.Request,
r.Header.Add(headerRevaAccessToken, authResp.Token)
trace.SpanFromContext(r.Context()).SetAttributes(attribute.String("enduser.id", "public"))
a.Logger.Debug().
Str("authenticator", "public_share").
Str("path", r.URL.Path).