mariusbalcytis/gentle-force-bundle

Get access to RateLimitReachedException

Closed this issue · 1 comments

Hi there!

I am using Sentry for error reporting.

Currently when my application detects a 429, I can see the following in my local log file

[2020-07-10T21:11:08.985046+00:00] app.INFO: Rate limit exceeded {"limits_key":"login_requests","identifier":"{\"ip\":\"172.18.0.1\",\"username_login\":\"x@x.de\"}"} []

I have configured sentry to send errors based on exceptions, not based on log file entries.

The log is coming from the ConfigurationManager as far as I can see.

        try {
            $compositeResult->addResult(
                $this->throttler->checkAndIncrease($configuration->getLimitsKey(), $identifier),
                $configuration
            );
        } catch (RateLimitReachedException $exception) {
            $compositeResult->handleRateLimitReachedException($exception, $configuration);
            $this->logger->info('Rate limit exceeded', [
                'limits_key' => $configuration->getLimitsKey(),
                'identifier' => $identifier,
            ]);
        }

Is there any hook/event/listener, where I can hook into this process to manually send this exception to sentry?

THanks!

I have registered a kernel.response event. This gives me the ability to check whether the response status code is 429 and then send a message to sentry by creating a custom rate limit error. This works fine.