Skip to content

Commit

Permalink
Update sentry documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
  • Loading branch information
yolile committed May 29, 2020
1 parent 9975b29 commit 8732878
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions kingfisher_scrapy/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ def _request(self, item, spider, method, *args, name='API'):
# https://stackoverflow.com/questions/25262765/handle-all-exception-in-scrapy-with-sentry
class SentryLogging:
"""
Send exceptions and errors to Sentry.
Sends exceptions and log records to Sentry. Log records with a level of ``ERROR`` or higher are captured as events.
https://docs.sentry.io/platforms/python/logging/
"""

@classmethod
Expand All @@ -172,6 +174,5 @@ def from_crawler(cls, crawler):
if sentry_dsn is None:
raise NotConfigured
extension = cls()
# by default only the errors are sent you sentry https://docs.sentry.io/platforms/python/logging/
sentry_sdk.init(sentry_dsn)
return extension
7 changes: 3 additions & 4 deletions kingfisher_scrapy/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@
# 'scrapy.extensions.telnet.TelnetConsole': None,
#}
EXTENSIONS = {
'kingfisher_scrapy.extensions.SentryLogging': -1,
# `KingfisherFilesStore` must run before `KingfisherProcessAPI`, because the file needs to be written before the
# request is sent to Kingfisher Process.
'kingfisher_scrapy.extensions.KingfisherFilesStore': 100,
'kingfisher_scrapy.extensions.KingfisherProcessAPI': 500,
# before any other extension
'kingfisher_scrapy.extensions.SentryLogging': -1,
}

# Configure item pipelines
Expand All @@ -81,9 +80,9 @@
# 'kingfisher_scrapy.pipelines.KingfisherScrapyPipeline': 300,
#}

# To send the logs to sentry
# To send exceptions and log records to Sentry.
SENTRY_DSN = os.getenv('SENTRY_DSN')
# To send items to Kingfishet Process, set this to, for example, "http://kingfisher.example.com" (no trailing slash).
# To send items to Kingfisher Process, set this to, for example, "http://kingfisher.example.com" (no trailing slash).
KINGFISHER_API_URI = os.getenv('KINGFISHER_API_URI')
# Set this to the same value as Kingfisher Process' `API_KEYS` setting.
# See https://kingfisher-process.readthedocs.io/en/latest/config.html#web-api
Expand Down

0 comments on commit 8732878

Please sign in to comment.