-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(contrib/opentelemetry): add TraceID and SpanID fields to the logger #1232
Conversation
} | ||
|
||
logger = log.With(logger, | ||
"TraceID", span.SpanContext().TraceID(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if I should call HasTraceID/HasSpanID first
I'm not sure when they would be empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add an IsValid()
check If this is a concern. I don't believe this function will get called if ref
is not valid
Signed-off-by: Maxime Le Conte des Floris <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave open for a couple days before merging if @cretz has any comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I would originally be hesitant to add log multiple tags to all existing logs, but this is a good case for doing it and I can't see a good enough reason to provide an opt-out at this time.
When may I expect a new release of the sdk? |
No exact time, but hopefully soon. In the meantime, you can depend on this commit (or |
Hello :)
What was changed
This PR adds the TraceID and the SpanID to the logger fields.
Why?
From the opentelemetry spec:
Checklist
I added a test to make sure the fields are indeed present.
To test this, I needed a logger that could fill the
log.Logger
and I didn't wanted to add an extra dependency or roll out my own. So I relied on the newslog
package (that's why I had to create new file and add the build annotation). Let me know if it's ok for you.I'm not sure.