Skip to content

Commit ab15330

Browse files
Revert "Enrich logs with traces for product catalog. (#47)"
This reverts commit 2011b9d.
1 parent 21cbf43 commit ab15330

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/product-catalog/main.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,17 @@ func initPostgresConnectionPool() *pgxpool.Pool {
151151
return pool
152152
}
153153

154+
// Helper function to enrich logs with trace/span IDs
154155
func logWithTrace(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr) {
155156
span := trace.SpanFromContext(ctx)
156157
sc := span.SpanContext()
157-
158-
// Add trace_id and span_id as top-level attributes
159-
attrs = append(attrs,
158+
traceAttrs := []slog.Attr{
160159
slog.String("trace_id", sc.TraceID().String()),
161160
slog.String("span_id", sc.SpanID().String()),
162-
)
163-
164-
logger.LogAttrs(ctx, level, msg, attrs...)
161+
}
162+
logger.LogAttrs(ctx, level, msg, append(attrs, traceAttrs...)...)
165163
}
166164

167-
168165
func main() {
169166
lp := initLoggerProvider()
170167
defer func() {

0 commit comments

Comments
 (0)