rate limit on sentry reporting

This commit is contained in:
Brian Gough 2017-02-22 15:53:52 +00:00
parent cf0e106153
commit 6e3f102fb2

View file

@ -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: ()->