Skip to content

Backend Error Reporting

Tahmid Ahmed edited this page Jan 15, 2026 · 17 revisions

Overview

Codebloom has a hand-rolled error reporter that will report certain logs and errors to Discord channels in our private Discord guild.

Implementation Detail

  • Reporter.java is the abstracted reporter class that exposes the following methods:
    • .log is used for non-errors that need to be reported back to the server. We mainly use this for tracking odd behaviors or suspicious activity that may not be an error.
    • .error is used to report any errors back to the server. We use this to raise an indicator to the dev team that something is wrong when it likely shouldn't be. We have logic that will automatically call .error on any controller exceptions or task scheduler (aka any background services).
  • ReporterController.java allows us to ingest errors from our endpoint. The endpoints have basic CSRF protections via checking the Origin header.
    • /api/reporter/error is the endpoint used to ingest errors from the frontend which will be sent to the server.
    • /api/reporter/log is the endpoint used to ingest logs from the frontend which will be sent to the server.
  • ThrottledReporter.java is a rate-limited version of the Reporter class, which exposes the same functions but limits how often they can be called. Used for randomly-selected high-traffic logging.

Examples

Link to Reporter example

    public synchronized String getCsrf() {
        if (csrf == null && !reported) {
            reported = true;
            reporter.log(Report.builder()
                            .environments(env.getActiveProfiles())
                            .location(Location.BACKEND)
                            .data("CSRF token is missing inside of LeetcodeAuthStealer. This may be something to look into.")
                            .build());
        }

        return csrf;
    }

Link to ThrottledReporter example

            throttledReporter.log(Report.builder()
                                            .data(String.format("""
                                                Score Distribution Report

                                                Leetcode Username: %s
                                                Difficulty: %s (%d pts)
                                                Acceptance Rate: %.2f
                                                Question Multiplier: %.2f
                                                Total: %d
                                                """,
                                                user.getLeetcodeUsername(),
                                                leetcodeQuestion.getDifficulty(),
                                                basePoints,
                                                leetcodeQuestion.getAcceptanceRate(),
                                                multiplier,
                                                points
                                                ))
                                            .build());

Clone this wiki locally