fluent-logger-python icon indicating copy to clipboard operation
fluent-logger-python copied to clipboard

add discard_logs_on_reconnect_error in asyncsender

Open enjoy-binbin opened this issue 3 years ago • 7 comments

issue: https://github.com/fluent/fluent-logger-python/issues/175

When using asyncsender, there is a queue holds the logs to be send:

  • when except socket.gaierror, i clear the queue and print log
  • this avoids the back of the log blocked when sent
  • but the first one will inevitably have this problem
  • i'm thinking about other methods, maybe just simply print some logs

This is my solution, it doesn’t look particularly good. so feel free to close this if un-needed

enjoy-binbin avatar Apr 24 '21 06:04 enjoy-binbin

Coverage Status

Coverage remained the same at 100.0% when pulling 6995dbb606e22a16f926e882ef0a5d573b250f43 on enjoy-binbin:connect-hang into ace80f4c2bd0020fc16891440243663c612dd01e on fluent:master.

coveralls avatar Apr 24 '21 06:04 coveralls

Coverage Status

Coverage decreased (-1.07%) to 98.928% when pulling bb8efb8930c5ed8ece8dbad69ae978f7a51c642d on enjoy-binbin:connect-hang into ace80f4c2bd0020fc16891440243663c612dd01e on fluent:master.

coveralls avatar Apr 24 '21 06:04 coveralls

I'll review it at depth when I have time, but I'm inclined not to accept this change.

Unless I'm missing something the error should lead to a reconnect and resending of the logs. Clearing the queue will cause the loss of perfectly good logs due to a simple reconnect issue, which would not be acceptable.

arcivanov avatar Apr 24 '21 10:04 arcivanov

Yep Not problem. I understand it is risky

Or maybe we should just print some logs to help the user for debug

enjoy-binbin avatar Apr 24 '21 13:04 enjoy-binbin

We can consider a tunable setting which would "discard logs on reconnect" and defaults to False. Reconnects are a part of life and discarding logs isn't useful in most cases IMO.

I tend to make decisions against arbitrary loss of data.

arcivanov avatar Apr 24 '21 13:04 arcivanov

Right. I can give a try. Thanks @arcivanov

enjoy-binbin avatar Apr 24 '21 13:04 enjoy-binbin

@arcivanov I add a discard_logs_on_reconnect_error setting default false. Maybe not good enough

enjoy-binbin avatar Apr 24 '21 14:04 enjoy-binbin