You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered the following problem: When using slog-loki, if the Loki server is not reachable when sending the first message, the process may halt. This only seems to occur if there is a significant (>= 1 second?) delay between the first two messages. Consider the following code:
When running this code without an available Loki instance, I'd expect the application to output the three "Message x logged" info logs to stdout, as well as a lot of "error sending batch, will retry" messages to stderr. However, the application halts for about seven minutes and then continues to run as expected:
$ go run main.go
2024/07/22 22:33:45 INFO Message 1 logged
2024/07/22 22:33:45 INFO Message 2 logged
2024/07/22 22:33:45 INFO Message 3 logged
level=warn component=client host=localhost:3100 msg="error sending batch, will retry" status=-1 error="Post \"http://localhost:3100/loki/api/v1/push\": dial tcp 127.0.0.1:3100: connect: connection refused"
level=warn component=client host=localhost:3100 msg="error sending batch, will retry" status=-1 error="Post \"http://localhost:3100/loki/api/v1/push\": dial tcp 127.0.0.1:3100: connect: connection refused"
2024/07/22 22:33:48 INFO Post sleep
level=warn component=client host=localhost:3100 msg="error sending batch, will retry" status=-1 error="Post \"http://localhost:3100/loki/api/v1/push\": dial tcp 127.0.0.1:3100: connect: connection refused"
[...]
I haven't yet had time to investigate further edge cases or to look into how grafana/loki-client-go handles message batching, which I think could be related to this issue.
Any ideas on what the cause of this issue may be and how to solve it?
Best regards,
Daniel
The text was updated successfully, but these errors were encountered:
danteu
added a commit
to danteu/slog-loki
that referenced
this issue
Jul 27, 2024
- When calling Client.Handle, the log entry is written to an unbuffered
channel. This write blocks when the Loki client is trying to send a
log batch to the Loki server. When the Loki server is unreachable,
this can block for multiple minutes.
- This change fixes the issue by running Client.Handle in a separate
goroutine.
Fixessamber#18
Hi,
I've encountered the following problem: When using
slog-loki
, if the Loki server is not reachable when sending the first message, the process may halt. This only seems to occur if there is a significant (>= 1 second?) delay between the first two messages. Consider the following code:When running this code without an available Loki instance, I'd expect the application to output the three "Message x logged" info logs to stdout, as well as a lot of "error sending batch, will retry" messages to stderr. However, the application halts for about seven minutes and then continues to run as expected:
This error only occurs if there is a significant delay between the first two messages. When I remove the first sleep, the expected behaviour occurs.
Output:
I haven't yet had time to investigate further edge cases or to look into how
grafana/loki-client-go
handles message batching, which I think could be related to this issue.Any ideas on what the cause of this issue may be and how to solve it?
Best regards,
Daniel
The text was updated successfully, but these errors were encountered: