Skip to content
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

Log Bridge returning io.Writer #5425

Open
pellared opened this issue Apr 24, 2024 · 6 comments
Open

Log Bridge returning io.Writer #5425

pellared opened this issue Apr 24, 2024 · 6 comments

Comments

@pellared
Copy link
Member

pellared commented Apr 24, 2024

A lot of logging libraries simply accept an io.Writer for configuration. E.g.

We could provide a generic log bridge which returns an io.Writer. That would allow using such libraries with OTel Go Logs.

The biggest challenge would be to determine when a new record starts and ends. By default we could be say that log records are split by EOL.

@pellared
Copy link
Member Author

CC @mx-psi

@shiva1333
Copy link
Member

shiva1333 commented Apr 24, 2024

The biggest challenge would be to determine when a new record starts and ends. By default we could be say that log records are split by EOL

Would this also work for multiline log messages?

@pellared
Copy link
Member Author

pellared commented Apr 24, 2024

The biggest challenge would be to determine when a new record starts and ends. By default we could be say that log records are split by EOL

Would this also work for multiline log messages?

Nope. Do you have any proposal how to handle it?

My only idea it to add an option would would accept a handler with signature more of less like: func([]byte) []log.Record to make the parsing of the data passed to io.Writer configurable. Then the user could even extract the logging levels, timestamp, etc. from the passed data.

@pohly
Copy link

pohly commented Apr 24, 2024

Forget klog.SetOutput. In order to integrate with Kubernetes, you want to write an implementation of a logr.Logger and configure OTel output in https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/component-base/logs/api/v1.

For example, JSON output is a backend which plugs into that package.

@pellared
Copy link
Member Author

@pohly, so #5192 is what you need?

There is already a PR open (#5357), but I had no time to look at it.

@pohly
Copy link

pohly commented Apr 24, 2024

Something like that would be a good first step. But for integration into Kubernetes someone needs to think through all of the consequences (how to activate and configure the feature, how it affects other log output) - probably worth a Kubernetes Enhancement Proposal (KEP).

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

No branches or pull requests

3 participants