U 췀g>@s ddlZddlZddlmZddlZddlmZddlmZddl m Z m Z m Z m Z ddlmZerddlmZddlmZdd lmZdd lmZdd lmZed Zed edefdZdZdZdZGdddeZddZddZe eddZddZddZ dS)N)wraps) Integration) ignore_logger)capture_internal_exceptionsensure_integration_enabledevent_from_exceptionreraise) TYPE_CHECKING)Any)Iterator)TypeVar)Callable)ExcInfoTF.)boundz _wrapped_{}_z _inspect_{}Z _sentry_used_c@seZdZdZeddZdS)BeamIntegrationbeamcslddlm}m}tdtdddddgD]}t|t|t||q0|jfd d }||_dS) Nr)DoFnParDorootzbundle_processor.createprocessZ start_bundleZ finish_bundlesetupcst|ddsD]h}t||s qt|}t||}t|t|}t|tdst|tdst|||t||t|qd|_||f||dS)N_sentry_is_patchedFT) getattrhasattr WRAPPED_FUNCformat INSPECT_FUNC USED_FUNCsetattr_wrap_task_callr)selffnargskwargs func_name wrapped_func process_funcZ inspect_funcZfunction_patchesZold_initJ/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/beam.pysentry_init_pardo7s      z5BeamIntegration.setup_once..sentry_init_pardo) apache_beam.transforms.corerrrr rr_wrap_inspect_call__init__)rrr&r,r*r)r+ setup_once%s zBeamIntegration.setup_onceN)__name__ __module__ __qualname__ identifier staticmethodr0r*r*r*r+r"srcs*t|sdSfdd}t|td|S)Ncst}t||r t||}n&t|}t|t|t|||zddlm}||WStk rddl m }||YSXdS)zG Inspect function overrides the way Beam gets argspec. r)get_function_args_defaults)getfullargspecN) rrrrr r!r-r6 ImportErrorZ apache_beam.typehints.decoratorsr7)r"r'r(r6r7r&r*r+_inspectXs        z$_wrap_inspect_call.._inspectT)rr r)clsr&r:r*r9r+r.Rs    r.cs$tfdd}t|td|S)z< Wrap task call with a try catch to get exceptions. csBz||}Wntk r(tYnXt|tjs:|St|S)N) Exceptionraise_exception isinstancetypes GeneratorType_wrap_generator_call)r$r%genfuncr*r+_innerzs  z_wrap_task_call.._innerT)rr r)rDrEr*rCr+r!ts r!cCs4t}t||jdddd\}}tj||ddS)z( Send Beam exception to Sentry. rF)typeZhandled)Zclient_optionsZ mechanism)hintN) sentry_sdkZ get_clientroptionsZ capture_event)exc_infoclienteventrGr*r*r+_capture_exceptions rMc Cs.t}tt|W5QRXt|dS)z Raise an exception. N)sysrJrrMr)rJr*r*r+r=sr=ccsFzt|VWqtk r&YqBYqtk r>tYqXqdS)z4 Wrap the generator to handle any failures. N)next StopIterationr<r=)rBr*r*r+rAs rA)!rNr? functoolsrrHZsentry_sdk.integrationsrZsentry_sdk.integrations.loggingrZsentry_sdk.utilsrrrrtypingr r r r r Zsentry_sdk._typesrrrrrrrr.r!rMr=rAr*r*r*r+s2         0"