Skip to content

Commit

Permalink
Fix loki log output exiting before push is finished
Browse files Browse the repository at this point in the history
After #2833 log outputs were stopped but loki didn't wait until it push
was finished to signal it was done.

Which leads to the actual k6 process exiting before loki could flush its messages.
  • Loading branch information
mstoykov committed Jul 13, 2023
1 parent f86938d commit ac448b0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions log/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,13 @@ func (h *lokiHook) Listen(ctx context.Context) {
pushCh = make(chan chan int64)
)

pushDone := make(chan struct{})
defer func() { <-pushDone }()
defer ticker.Stop()
defer close(pushCh)

go func() {
defer close(pushDone)
oldLogs := make([]tmpMsg, 0, h.limit*2)
for ch := range pushCh {
msgsToPush, msgs = msgs, msgsToPush
Expand Down

0 comments on commit ac448b0

Please sign in to comment.