Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
do raven for lambda correctly, fixes #387 (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Bengtsson authored Apr 13, 2018
1 parent 6a60b76 commit 51d2283
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ know is to find out by seeing if ``pip install ...`` fails:

.. code-block:: shell
root@2ec530633121:/app# pip install -r requirements/default.txt -c requirements/constraints.txt
root@2ec530633121:/app/jobs# pip install -r requirements/default.txt -c requirements/constraints.txt
If it fails because an extra constraint package is required add it like this:

Expand Down
11 changes: 3 additions & 8 deletions jobs/buildhub/lambda_s3_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

import aiohttp
import kinto_http
import raven
from raven.handlers.logging import SentryHandler
from raven.contrib.awslambda import LambdaClient

from buildhub import utils
from buildhub.inventory_to_records import (
Expand All @@ -28,7 +27,7 @@

# Optional Sentry with synchronuous client.
SENTRY_DSN = os.getenv('SENTRY_DSN')
sentry = raven.Client(SENTRY_DSN, transport=raven.transport.http.HTTPTransport)
sentry = LambdaClient(SENTRY_DSN)

logger = logging.getLogger() # root logger.
metrics = get_metrics('buildhub')
Expand Down Expand Up @@ -242,16 +241,12 @@ async def main(loop, event):
metrics.incr('s3_event_record_created')


@sentry.capture_exceptions
def lambda_handler(event, context):
# Log everything to stderr.
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
logger.setLevel(logging.DEBUG)

# Add Sentry (no-op if no configured).
handler = SentryHandler(sentry)
handler.setLevel(logging.ERROR)
logger.addHandler(handler)

loop = asyncio.get_event_loop_policy().new_event_loop()

try:
Expand Down
6 changes: 3 additions & 3 deletions jobs/requirements/default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ kinto-http==9.1.1 \
kinto-wizard==2.3.0 \
--hash=sha256:7b9a4f856b50e53079cd728feb87787b3001b0cd3b3c0ff9981a1f196adf6f2d \
--hash=sha256:c83102fcff999b4914a2bd146114566634f34a99b963885054a123b0426612a9
raven==6.5.0 \
--hash=sha256:0adae40e004dfe2181d1f2883aa3d4ca1cf16dbe449ae4b445b011c6eb220a90 \
--hash=sha256:84da75114739191bdf2388f296ffd6177e83567a7fbaf2701e034ad6026e4f3b
raven==6.6.0 \
--hash=sha256:738a52019d01955d5b44b49d67c9f2f4cedb1b4f70d4fb0b493931174d00e044 \
--hash=sha256:92bf4c4819472ed20f1b9905eeeafe1bc6fe5f273d7c14506fdb8fb3a6ab2074
markus==1.1 \
--hash=sha256:813ac8cd0eb68bcf7ee618ac2544ce20de5eb0ba27b12f50973c29742800b058 \
--hash=sha256:821377379e0d225a870996e4dcd1aa5305e4030a8b9b5d8b38dc843cbc30dfa8
Expand Down

0 comments on commit 51d2283

Please sign in to comment.