feat(tracing): add userID to lookup traces

This commit adds `user_id` as a tag for traces. It helps to lookup and
filter traces we need by userID.

OrgID is harder to get right, so I will open an issue, but it will be
nice to have it in as well.

Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
Co-authored-by: George MacRorie <gmacrorie@influxdata.com>
pull/17667/head
Gianluca Arbezzano 2020-04-08 14:17:55 +02:00
parent 0b6f8eada9
commit 0a363b2ba7
1 changed files with 5 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import (
platform "github.com/influxdata/influxdb/v2"
platcontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/jsonweb"
"github.com/opentracing/opentracing-go"
"go.uber.org/zap"
)
@ -117,6 +118,10 @@ func (h *AuthenticationHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
ctx = platcontext.SetAuthorizer(ctx, auth)
if span := opentracing.SpanFromContext(ctx); span != nil {
span.SetTag("user_id", auth.GetUserID().String())
}
h.Handler.ServeHTTP(w, r.WithContext(ctx))
}