Detect failure in workflow

Hi,

I am trying to detect errors in workflow and get alarms, which can be either non-determinism error or activities retry exceed N attempts.

Is there any easy way to achieve this goal in python-sdk?

which can be either non-determinism

worker metric temporal_workflow_task_execution_failed

or activities retry exceed N attempts

worker metrics do have temporal_activity_execution_failed, but for specific requirement (exceed N attempts)
you will need to get attempt count via api in your activity code and if its > X increment custom counter metric