diff --git a/polling/test_service.py b/polling/test_service.py index 490f8476..63494572 100644 --- a/polling/test_service.py +++ b/polling/test_service.py @@ -2,6 +2,7 @@ from typing import Counter from temporalio import activity +from temporalio.exceptions import ApplicationError, ApplicationErrorCategory attempts = Counter[str]() ERROR_ATTEMPTS = 5 @@ -20,4 +21,10 @@ async def get_service_result(input): print(f"Attempt {attempts[workflow_id]} of {ERROR_ATTEMPTS} to invoke service") if attempts[workflow_id] == ERROR_ATTEMPTS: return f"{input.greeting}, {input.name}!" - raise Exception("service is down") + raise ApplicationError( + message="service is down", + # Set the error as BENIGN to indicate it is an expected error. + # BENIGN errors have activity failure logs downgraded to DEBUG level + # and do not emit activity failure metrics. + category=ApplicationErrorCategory.BENIGN, + )