idEdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z ej dZ dZGd d e ZdS) z 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. )absolute_importN) FunctionType)Client) HTTPTransportzsentry.errors.clientcdddddddS)NAWS_LAMBDA_FUNCTION_NAMEAWS_LAMBDA_FUNCTION_VERSIONAWS_LAMBDA_FUNCTION_MEMORY_SIZEAWS_LAMBDA_LOG_GROUP_NAMEAWS_LAMBDA_LOG_STREAM_NAME AWS_REGION)lambdaversion memory_size log_group log_streamregionrU/opt/cloudlinux/venv/lib/python3.11/site-packages/raven/contrib/awslambda/__init__.pyget_default_tagsrs#,0802   rceZdZdZfdZfdZfdZd dZedZ edZ ed Z xZ S) LambdaClienta 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!') c|dt}tt|j|d|i|dS)N transport)poprsuperr__init__)selfargskwargsr __class__s rrzLambdaClient.__init__8sCJJ{M:: *lD!!*DPIPPPPPPrcd|vrix|d<}n|d}|dd}|dd}|rX||}||}|r|||r|||r|r||||d<t t |j|i|S)Ndataeventcontextextra)get_get_http_interface_get_user_interfaceupdate_get_extra_datarrcapture) rr r!r$r%r& http_info user_infor"s rr-zLambdaClient.capture<s   $& &F6NTT&>D 7D))**Y--  '0077I0077I ' I&&& ' I&&&  AW A 00@@DM0u\4((0$A&AAArctt|j|i|}tD]>\}}|d|t j|?|dt jd|dt jd|S)NtagsreleaseSENTRY_RELEASE environmentSENTRY_ENVIRONMENT) rr build_msgritems setdefaultosenvironr()rr r!r$optiondefaultr"s rr6zLambdaClient.build_msgQs2u\4((2DCFCC/117799 E EOFG L # #FBJNN7,C,C D D D D  2:>>2B#C#CDDD  rz~~6J'K'KLLL rNcttstjjSpt ftjfd}|S)a Wrap a function or code block in try/except and automatically call ``.captureException`` if it raises an exception, then the exception is reraised. By default, it will capture ``Exception`` >>> @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``. ) exceptionsc ||g|Ri|S#$r+jd||d|jwxYw)N)r%r&r)captureExceptionr&clear)r%r&r r!r>frs rwrappedz0LambdaClient.capture_exceptions..wrappedxs| q9$999&999   %%ME7MMfMMM ""$$$ s 0A) isinstancer functoolspartialcapture_exceptions Exceptionwraps)rrBr>rCs``` rrGzLambdaClient.capture_exceptionsZs.!\** L$T%<KKK K/I<            rc|dr|dd}|r|ddp|dd|dd|dd|dd|dd|dd }d|iSdSdS) NrequestContextidentitycognitoIdentityIdusersourceIpcognitoIdentityPoolIdcognitoAuthenticationType userAgent)idusername ip_addresscognito_identity_pool_idcognito_authentication_type user_agentr()r%rLrNs rr*z LambdaClient._get_user_interfaces 99% & & &-.z:H &",,':DAA_X\\RXZ^E_E_ ( VT : :"*,,z4"@"@08 =TVZ0[0[3;<<@[]a3b3b"*,,{";"; ~% & & & &rc|drp|dr]|d|d|dd|ddpgd}d|iSdSdS)Npath httpMethodqueryStringParametersheaders)urlmethod query_stringr^requestrY)r%rbs rr)z LambdaClient._get_http_interfaces 99V   (r}s'&&&&& ......  1 2 2JJJJJ6JJJJJr