Skip to content

trace: Logger helper

Warren Gifford requested to merge k/20220527-withlogger into main

Created by: keegancsmith

Note: I am unsure on this API. Please be brutal/nitpicky in the feedback :)

I don't see many uses of log.WithTrace, but I think this is because it is clunky to use since Span or Context may be nil on a context. This introduces a helper so we can start logging against a span more easily. Here is an example of using it I want:

logger := trace.WithLogger(ctx, s.Log).Scoped("...", "...").With(...

This seems like the best place to add the logger, since we need to use internal functions in the trace pkg (ie won't work in lib/log).

I updated the documentation to include an example of it. Right now the documentation has one other place it calls WithTrace, but it needs to be reworked to be more realistic. I think calling log.Scoped on something that is traced seems surprising to me.

Test Plan: unused, so just that CI is happy.

Merge request reports

Loading