No EVENT_TYPE_WORKFLOW_TASK_STARTED when Activity was started

I’m observing an unexpected (to me) behaviour. When simulating executing an activity, I do not see EVENT_TYPE_WORKFLOW_TASK_STARTED in the event history after the activity was started.

My activity impl looks like:

    @Override
    public void doStuff(String input) {
        System.out.println("### TestActivity2Impl invoked " + cntr++);
        try {
            for (int i=0;i<10;i++) {
                Activity.getExecutionContext().heartbeat("ping");
                System.out.println("### TestActivity2Impl sleeping");
                Thread.sleep(2000);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

I have a poller implementation that gets the status and history of all executing workflows periodically (in tests executed every 5secs). I’d expect to see EVENT_TYPE_WORKFLOW_TASK_STARTED in the 20s windows the activity execution takes. Instead, once started there’s is only EVENT_TYPE_ACTIVITY_TASK_SCHEDULED (plus some WORKFLOW activity kinds) in the history. Once the activity completes, there are EVENT_TYPE_ACTIVITY_TASK_SCHEDULED, EVENT_TYPE_ACTIVITY_TASK_STARTED, EVENT_TYPE_ACTIVITY_TASK_COMPLETED (plus the WORKFLOW kinds). I can paste complete histories, if needed.

Isn’t the purpose of EVENT_TYPE_ACTIVITY_TASK_STARTED to be present on time in the history when an activity started to be executed? The chapter on error detection clearly distinguished scheduling and execution stages. What I want to do is propagate the execution snapshot to our UI.

I was suspecting this might be a matter of periodically checking the worker, and that during the 20s the state was not yet propagated into the history. This is the reason I added the heart beat calls, thinking that perhaps this message could help refresh the activity status too. But it din’t help.

Any suggestions please?

Thank you.

From the documentation:

For an Activity Execution, the ActivityTaskStarted Event will not show up in the Workflow Execution Event History until the Activity Execution has completed or failed (having exhausted all retries). This is to avoid filling the Event History with noise. Use the Describe API to get a pending Activity Execution’s attempt count.