Repository navigation
Forward logs to Discord - #579
Merged
Merged
Conversation
Zabuzard
marked this pull request as draft
September 21, 2022 14:26
Zabuzard
marked this pull request as ready for review
September 26, 2022 08:21
Mom0aut
reviewed
Sep 26, 2022
Mom0aut
reviewed
Sep 27, 2022
Tais993
reviewed
Sep 29, 2022
Zabuzard
force-pushed
the
feature/logs_to_discord
branch
from
September 30, 2022 13:08
927f820 to
9f0fc4b
Compare
Member
Author
|
a week old, a semi approval. merging this |
Zabuzard
force-pushed
the
feature/logs_to_discord
branch
from
October 4, 2022 08:56
9f0fc4b to
d395ad0
Compare
|
Kudos, SonarCloud Quality Gate passed! |
Tais993
reviewed
Oct 4, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








Overview
This is a convenience replacement for the (broken/deactivated) Logviewer project.
It forwards all logs to a Discord channel, via webhooks.
Info/Error channel
The day to day routine will be that we want to be notified when an error/warning happened, but not for info logs. Therefore, we set up 2 channels with separate webhooks. One for errors, one for infos:
Now, users can mute one channel and keep notifications on for the other.
Security
Note that logs can contain sensitive information (for example when banning an user). Therefore, a new log marker
LogMarkers.SENSITIVEhas been added. Logs with that marker are not forwarded to Discord. All existing logs have been checked and adjusted. Looks something like this:Details
Queue
The implementation is relatively straightforward, but has some non trivial complexity. In a nutshell, it buffers all incoming logs in a
PriorityQueue(ordered on the timestamp to ensure correct log order). The queue has a max size of10_000logs and ideally is never hit in practice (this is to protect RAM, in case).The queue is then processed each 5 seconds with a
ScheduledExecutorService. The service then polls and sends a maximum of 10 logs in a batch request to Discord.Failures
If the request fails, the logs are put back into the queue. If a batch fails 3 times, it is discarded to not entirely block the whole mechanism forever.
Rate limitting
When we send too much, Discord hits us with rate limits (
429http status). When this happens, we extract the end of the limitation from theretry-afterheader and skip theScheduledExecutorServicecalls untilInstant.now()is after that time.Logging the logger
The whole system also has logging/error reporting itself. Its logs all have a
LogMarkers.NO_DISCORDthough, to prevent that it forwards its own logs - which could lead to a potential infinite loop of spawning logs in an erroneous scenario.Config
The config has been changed, add:
Checklist