ó ¿öYc@@sœdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z ej dƒZ d„Zd e fd „ƒYZdS( sÐ raven.contrib.awslambda ~~~~~~~~~~~~~~~~~~~~ Raven wrapper for AWS Lambda handlers. :copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. i(tabsolute_importN(t FunctionType(tClient(t HTTPTransportssentry.errors.clientcC@s.idd6dd6dd6dd6d d 6d d 6S( NtAWS_LAMBDA_FUNCTION_NAMEtlambdatAWS_LAMBDA_FUNCTION_VERSIONtversiontAWS_LAMBDA_FUNCTION_MEMORY_SIZEt memory_sizetAWS_LAMBDA_LOG_GROUP_NAMEt log_grouptAWS_LAMBDA_LOG_STREAM_NAMEt log_streamt AWS_REGIONtregion((((sQ/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pytget_default_tagsst LambdaClientcB@seeZdZd„Zd„Zd„Zddd„Zed„ƒZ ed„ƒZ ed„ƒZ RS( s™ Raven decorator for AWS Lambda. By default, the lambda integration will capture unhandled exceptions and instrument logging. Usage: >>> from raven.contrib.awslambda import LambdaClient >>> >>> >>> client = LambdaClient() >>> >>> @client.capture_exceptions >>> def handler(event, context): >>> ... >>> raise Exception('I will be sent to sentry!') cO@s5|jdtƒ}tt|ƒjd|||ŽdS(Nt transport(tgetRtsuperRt__init__(tselftargstkwargsR((sQ/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR8scO@sÍd|kri|d<}n |d}|jddƒ}|jddƒ}|j|ƒ}|rp|j|ƒn|r´|j|ƒ}|r›|j|ƒn|j||ƒ|d>> @client.capture_exceptions >>> def foo(): >>> raise Exception() >>> with client.capture_exceptions(): >>> raise Exception() You can also specify exceptions to be caught specifically >>> @client.capture_exceptions((IOError, LookupError)) >>> def bar(): >>> ... ``kwargs`` are passed through to ``.captureException``. t exceptionsc@sXyˆ||||ŽSWn:ˆk rSˆjd|d||ˆjjƒ‚nXdS(NRR(tcaptureExceptionRtclear(RRRR(R1tfR(sQ/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pytwrappedts   (t isinstanceRt functoolstpartialtcapture_exceptionst Exceptiontwraps(RR4R1R5((R1R4RsQ/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR9Vs $cC@s¼|jdƒr¸|dd}|r¸i|jddƒpG|jddƒd6|jddƒd6|jddƒd6|jd dƒd 6|jd dƒd 6|jd ƒd6}i|d6SndS(NtrequestContexttidentitytcognitoIdentityIdtusertidtusernametsourceIpt ip_addresstcognitoIdentityPoolIdtcognito_identity_pool_idtcognitoAuthenticationTypetcognito_authentication_typet userAgentt user_agent(RR(RR=R?((sQ/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR~s%cC@s|jdƒr{|jdƒr{i|jdƒd6|jdƒd6|jddƒd6|jddƒpigd6}i|d6SdS( Ntpatht httpMethodturltmethodtqueryStringParameterst query_stringtheaderstrequest(RR(RRQ((sQ/opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR scC@s¨i|d6|jd6t|ƒd6}|jr¤i|jjjd6|jjjd6|jjjd6|jjjd6|jjjd6|jj d 6|jj d 6|d s