Skip to content
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

A full buffer should not log any errors #742

Open
frosiere opened this issue Oct 24, 2023 · 3 comments
Open

A full buffer should not log any errors #742

frosiere opened this issue Oct 24, 2023 · 3 comments

Comments

@frosiere
Copy link
Contributor

frosiere commented Oct 24, 2023

Fluency currently logs an error if the buffer is full.

See Fluency.Emitter#emit

This can lead to a large number of errors (not to say an infinite loop) if Fluency can't recover quickly.

So, shouldn't we move this log to the debug level or simply abandon it?

We'd still be able to detect this type of problem because an exception is triggered after we've deleted the error log.

Any feedback on this subject is most welcome.

If we agree on the proposal, I can contribute with a PR.

@komamitsu
Copy link
Owner

@frosiere I got your point. But, whether to move the log to DEBUG level or remove it depends on the use case. Also introducing a configuration to change the log level would be like whack-a-mole for other logs.

How about handling the issue on logging configuration side like this?

build.gradle

    implementation 'ch.qos.logback:logback-classic:1.4.11'
    implementation 'org.slf4j:slf4j-api:2.0.9'
    implementation 'org.codehaus.janino:janino:3.1.10'

logback.xml

        <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
            <evaluator>
                <expression>return message.startsWith("emit() failed due to buffer full");</expression>
            </evaluator>
            <OnMismatch>NEUTRAL</OnMismatch>
            <OnMatch>DENY</OnMatch>
        </filter>

This isn't so robust, but very flexible so you can customize it if needed.

@frosiere
Copy link
Contributor Author

frosiere commented Nov 6, 2023

Thanks for the reply. Logging an error can only lead to an infinite loop until we recover. This seems a weird behavior. I may use the proposal but we have multiple applications handled by multiple teams so, it would avoid it.
So, moving this log entry to the debug level seems the only viable solution to me.

@komamitsu
Copy link
Owner

How to handle BufferFullException is up to the application. For instance, the application can avoid calling Fluency.emit() for a while after catching BufferFullException thrown from Fluency.emit(). This option makes sense since Fluency can't buffer log data anymore and what the application can do is only waiting forever or dropping new log data. It may result in some log lost, but I think it's a trade-off needs to be weighed.

I need to consider the balance between various use cases and the simplicity of the design and implementation of Fluency. So, unfortunately, I won't move forward on the option you suggested to change the log level, which some organizations have already depended on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants