Преглед изворни кода

rate limit on sentry reporting

Brian Gough пре 9 година
родитељ
комит
6e3f102fb2
1 измењених фајлова са 7 додато и 1 уклоњено
  1. 7 1
      libraries/logger/logging-manager.coffee

+ 7 - 1
libraries/logger/logging-manager.coffee

@@ -54,7 +54,13 @@ module.exports = Logger =
 		@logger.info.apply(@logger, arguments)
 	error: (attributes, message, args...)->
 		@logger.error(attributes, message, args...)
-		@captureException(attributes, message, "error") if @raven?
+		if @raven?
+			now = new Date()
+			rateLimited = (now - @lastErrorTimeStamp) < 30 * 1000
+			# only report one error every thirty seconds to avoid overload
+			if not rateLimited
+				@captureException(attributes, message, "error")
+				@lastErrorTimeStamp = now
 	err: () ->
 		@error.apply(this, arguments)
 	warn: ()->