So I have a workflow which may crash on 50000 history events, is there some kind of metric or whatever that I can use to see if workflow history exceeded X amount of events?
Hello @Nicholas_Neutron
History service emits history_count metric, which is histogram and measures history count distribution, but I don’t think this is what you are looking for.
For a specific execution, you can use tctl wf desc -w <wfid> -r <runid>
and find workflowExecutionInfo.historyLength
or via code using [DescribeWorkflowExecutionResponse]
DescribeWorkflowExecutionResponse resp =
...
resp.getWorkflowExecutionInfo().getHistoryLength()
With the next SDK release, you will be able to access the history length from your workflow code
- Provide WorkflowInfo#getHistoryLength() · Issue #1300 · temporalio/sdk-java · GitHub
-
Add WorkflowInfo#getHistoryLength by Spikhalskiy · Pull Request #1498 · temporalio/sdk-java · GitHub
which will make it easier to decide when it is time to invokecontinueAsNew