Skip to content

Commit

Permalink
Merge pull request #4306 from sul-dlss/throttle-notice-flag
Browse files Browse the repository at this point in the history
Add a flag for throttle notices so we can exclude them from the bot boxes
  • Loading branch information
cbeer authored Jul 8, 2024
2 parents 223a19e + f9f8da0 commit e937cd4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion config/initializers/rack_attack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
match_data = request.env['rack.attack.match_data']
now = match_data[:epoch_time]

Honeybadger.notify("Throttling request", context: { ip: request.ip, path: request.path }.merge(match_data)) if match_data[:count] < 15 || (match_data[:count] % 10).zero?
if (Settings.SEND_THROTTLE_NOTIFICATIONS_TO_HONEYBADGER && match_data[:count] < 15) || (match_data[:count] % 10).zero?
Honeybadger.notify("Throttling request", context: { ip: request.ip, path: request.path }.merge(match_data))
end

headers = {
'RateLimit-Limit' => match_data[:limit].to_s,
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ GENERATE_SITEMAP: true
DEVISE_SECRET_KEY: <%= Rails.application.secret_key_base %>
DISABLE_SESSIONS: false
THROTTLE_TRAFFIC: false
SEND_THROTTLE_NOTIFICATIONS_TO_HONEYBADGER: true
OCLC:
API_KEY: the-oclc-api-key
BASE_URL: http://www.worldcat.org/webservices/catalog/content/citations
Expand Down

0 comments on commit e937cd4

Please sign in to comment.