Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
tracing: add TraceID to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
vascoguita committed Sep 21, 2022
1 parent 964c21f commit 2c5f8b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/grpc/interceptors/appctx/appctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewUnary(log zerolog.Logger) grpc.UnaryServerInterceptor {
ctx, span := tracing.SpanStartFromContext(ctx, tracerName, "appctx UnaryServerInterceptor")
defer span.End()

sub := log.With().Logger()
sub := log.With().Str("TraceID", span.SpanContext().TraceID().String()).Logger()
ctx = appctx.WithLogger(ctx, &sub)
res, err := handler(ctx, req)
return res, err
Expand All @@ -51,7 +51,7 @@ func NewStream(log zerolog.Logger) grpc.StreamServerInterceptor {
ctx, span := tracing.SpanStartFromContext(ctx, tracerName, "appctx StreamServerInterceptor")
defer span.End()

sub := log.With().Logger()
sub := log.With().Str("TraceID", span.SpanContext().TraceID().String()).Logger()
ctx = appctx.WithLogger(ctx, &sub)

wrapped := newWrappedServerStream(ctx, ss)
Expand Down
2 changes: 1 addition & 1 deletion internal/http/interceptors/appctx/appctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func handler(log zerolog.Logger, h http.Handler) http.Handler {
defer span.End()

ctx := r.Context()
sub := log.With().Logger()
sub := log.With().Str("TraceID", span.SpanContext().TraceID().String()).Logger()
ctx = appctx.WithLogger(ctx, &sub)
r = r.WithContext(ctx)
h.ServeHTTP(w, r)
Expand Down

0 comments on commit 2c5f8b6

Please sign in to comment.