-
Notifications
You must be signed in to change notification settings - Fork 57
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
Stream agent logs remotely #1774
base: main
Are you sure you want to change the base?
Conversation
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.
Added two questions about writing plugin loggers to log files. Once those are resolved, this PR is ready for review
plugins/metrics/pkg/agent/drivers/opni_manager_otel/otel_driver.go
Outdated
Show resolved
Hide resolved
82e1abf
to
b5c314a
Compare
When running the Tried searching here and couldn't find it: https://github.com/search?q=repo%3Aopen-telemetry%2Fopentelemetry-go-contrib+%22Tracer+created%22&type=code
|
@jan-law that message is generated by the go-plugin library when writing to a logger that isn't set up to forward its log messages to the host process. |
Update - it seems that go-plugin expects logs to be sent to stderr instead of stdout. This issue affects the slog branch too. Making a fix for it now. |
7079f5d
to
eca919f
Compare
DefaultTimeFormat = "2006 Jan 02 15:04:05" | ||
errKey = "err" | ||
) | ||
|
||
var logSampler = &sampler{} | ||
|
||
func init() { | ||
logFs = afero.NewMemMapFs() |
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.
The plugin logs do not appear in the debug agent-logs
output. Do the plugins share the same logFs
here if they are different processes?
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.
No, they will be separate. The plugins should be sending their logs to the host process though, maybe that needs some refactoring.
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.
Although I wasn't able to stream the logs over SyncStderr
, the Logger
in the ClientConfig
can forward the log messages to a writer, where I can log them with a logger on the host side.
Logger: hclog.New(&hclog.LoggerOptions{
Level: hclog.Debug,
Output: logger.PluginFileWriter,
}),
Go-plugin can't directly forward protobuf message bytes unfortunately, as it's hardcoded to cast all non-hclog output to a string
: https://github.com/hashicorp/go-plugin/blob/017b758bf4d495212a55db3de61b2d95ab104e53/client.go#L1155
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.
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.
Log streaming is working with the forked go-plugin patch in my k3s cluster. I replaced the hclog forwarding logger with io.Copy(c.config.Stderr, r)
. I'm working on fixing the test env output because the plugins are logging the gprc bytes to stderr
7b9df91
to
61e4eb7
Compare
Depends on alexandreLamarre/go-plugin#2 |
22a45f0
to
79f58fb
Compare
Setting this PR back to draft mode while I work on the plugin loggers for the standalone test env |
60922f0
to
bf3716e
Compare
b2397dd
to
9b25384
Compare
silence non-opni logs share plugin file lock with agent logger
fix plugin log interleaving prevent duplicate file writing in subprocesses create plugin logger without storing writer in context
pass mode to real plugin loader
pass agent id to real cluster plugin loggers
fixup error handling fix lint fixup after rebase
run linter remove unused file desciptors
Fixes #1655
Depends on #1642
Example usage:
opni debug agent-logs --level=debug --follow <cluster-id>