-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Wait for file log to drain before k6 exits #2414
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -44,15 +44,19 @@ type fileHook struct { | |||
w io.WriteCloser | ||||
bw *bufio.Writer | ||||
levels []logrus.Level | ||||
done chan struct{} | ||||
} | ||||
|
||||
// FileHookFromConfigLine returns new fileHook hook. | ||||
func FileHookFromConfigLine( | ||||
ctx context.Context, fallbackLogger logrus.FieldLogger, line string, | ||||
ctx context.Context, fallbackLogger logrus.FieldLogger, line string, done chan struct{}, | ||||
) (logrus.Hook, error) { | ||||
// TODO: fix this so it works correctly with relative paths from the CWD | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you mean by this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noticed that we don't explicitly check if we got a relative path here and instead just open exactly what we were given: Line 108 in 1e28a3e
This works, for now, since we're directly using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you expand this comment there with that info :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need, I plan to fix it with a small commit in #2412 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, this is the fix and the test to verify it: 7574bd2 |
||||
|
||||
hook := &fileHook{ | ||||
fallbackLogger: fallbackLogger, | ||||
levels: logrus.AllLevels, | ||||
done: done, | ||||
} | ||||
|
||||
parts := strings.SplitN(line, "=", 2) | ||||
|
@@ -120,6 +124,7 @@ func (h *fileHook) loop(ctx context.Context) chan []byte { | |||
loglines := make(chan []byte, fileHookBufferSize) | ||||
|
||||
go func() { | ||||
defer close(h.done) | ||||
for { | ||||
select { | ||||
case entry := <-loglines: | ||||
|
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.
This done channel looks more like the internal state. Do you think we should accept it as input?
Can a signature be like?
Wdyt?
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.
Ideally, even with the doneCh
<-chan sruct{},
but I guess it is outside of the scope of this PRThere 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.
hmm yeah, that is slightly better 👍
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.
actually, I think I'll refactor both this and
LokiFromConfigLine
in a separate PR, so I'll leave it as it is for now