Skip to content

Alternative Logger option#12289

Closed
bogdandrutu wants to merge 1 commit into
open-telemetry:mainfrom
bogdandrutu:logger-alternative
Closed

Alternative Logger option#12289
bogdandrutu wants to merge 1 commit into
open-telemetry:mainfrom
bogdandrutu:logger-alternative

Conversation

@bogdandrutu
Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Comment thread component/telemetry.go
Comment thread component/telemetry.go
Resource pcommon.Resource
}

func (ts *TelemetrySettings) LoggerWithout(fields ...string) *zap.Logger {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this method does make usage cleaner for component authors, which is very nice.

That said, I think it is necessary to expose the interface in this package as well in order to allow reasonable type assertions elsewhere, such as testing the actual implementation of the logger.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, I think it is necessary to expose the interface in this package as well in order to allow reasonable type assertions elsewhere, such as testing the actual implementation of the logger.

Not sure about that, you can have the interface in other place if needed. Example in golang "errors", the Unwrap is not an interface, see

https://cs.opensource.google/go/go/+/refs/tags/go1.23.5:src/errors/wrap.go;l=17

I do believe that if we don't expose an interface, we need to have this as "optional", meaning we need to check if it implements what we want to implement, otherwise return the same logger probably...

@bogdandrutu
Copy link
Copy Markdown
Member Author

This POC achieved its target. Closing.

@bogdandrutu bogdandrutu closed this Feb 6, 2025
@bogdandrutu bogdandrutu deleted the logger-alternative branch February 6, 2025 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants