How to gather errors from activities to the workflow?

Hey! I have a workflow with a series of activities and I want to store errors catched during attempts from activities in the workflow. What is the proper way of doing this?

Store them from the activity code. You can create an activity interceptor to make this functionality generic.

Thanks for the answer. Do you mean in external storage?
Is it a good idea to send them via signals?

What is the use case for storing every activity error?

The SDK records activity failed attempts with WARN level sdk-typescript/packages/worker/src/activity.ts at df72bfb51970c4517709f49a933d5495541eab6f · temporalio/sdk-typescript · GitHub along with all the activity metadata. Are logs good enough for what you’re trying to achieve?

Analytics. Each activity can generate different errors, so I want to keep them for analytics. I have in mind to return errors with workflow result. Any ideas?

Logs are not really an option, because it will require too much infra changes.

For analytics, you can emit an event into your analytics system from an activity interceptor. Temporal cannot store every activity retry as it would severely limit the number of possible retries. The current design allows practically unlimited retries.

Thanks for the suggestion, my intention is to only collect uniq errors, so it will not grow after a lot of retries

That makes sense; in the future, we might add separate analytics features to answer such requests.

1 Like