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
otelzap logger ignore WithOptions invocation #32
Comments
Yes, But I guess As a workaround, we could add an otelzap specific option so we have access to the fields: l := otelzap.Ctx(ctx).WithFields(zap.String("FOO", "BAR")) And then use |
Hey @vmihailenco . I don't think that introducing one more function to zap API would be a nice idea. Why you wouldn't use otelzap WithOptions to collect extra fields? It is type-safe, has no reflection, and is transparent for the end-user. Please check https://github.com/ezh/opentelemetry-go-extra/commit/717c3dbeaca0b191e62cb6ff9352278f3cc6421c
printf console output
If there will be other options, fieldExtractorCore will silently ignore them. |
Sorcery 😮 Indeed, with that trick we don't need a separate API. Very nice. Could you open a PR with https://github.com/ezh/opentelemetry-go-extra/commit/717c3dbeaca0b191e62cb6ff9352278f3cc6421c? I can cleanup it if needed. |
Will do |
@ezh gentle ping if you are still interested... |
Example
I expect that there will be
FOO:BAR
field.The field is added to the zap encoder, but only for
*zap.Logger
.skipCaller
is ignored:https://github.com/uptrace/opentelemetry-go-extra/blob/main/otelzap/otelzap.go#L31
After that code is using
skipCaller
for log output (https://github.com/uptrace/opentelemetry-go-extra/blob/main/otelzap/otelzap.go#L262).IMO someone forgot to add to
func (l *Logger) WithOptions(opts ...zap.Option) *Logger
https://github.com/uptrace/opentelemetry-go-extra/blob/main/otelzap/otelzap.go#L63
The text was updated successfully, but these errors were encountered: