Skip to content

Conversation

@cretz
Copy link
Member

@cretz cretz commented Nov 17, 2025

What was changed

  • Built new workflowTaskCompletion struct to represent workflow task completion instead of interface{}
  • Added optional applyCompletionMetrics func to be called when the task completion is accepted
  • Set applyCompletionMetrics with the workflow completed metrics to be applied on task completion accepted

Checklist

  1. Closes workflow_completed and workflow_continue_as_new counters should be logged after a successful reporting to the server #2111

@cretz cretz force-pushed the metrics-after-rpc branch from 909b34e to 0b7f8f1 Compare November 17, 2025 22:43
@cretz cretz marked this pull request as ready for review November 17, 2025 23:16
@cretz cretz requested a review from a team as a code owner November 17, 2025 23:16

// WorkflowExecutionContext represents one instance of workflow execution state in memory. Lock must be obtained before
// calling into any methods.
WorkflowExecutionContext interface {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in internal_public but I don't see it referenced in internalbindings or having any side effects of my changing this interface (some methods already accepted parameters that couldn't be instantiated externally anyways).

@Quinn-With-Two-Ns - any concerns with the altering of this interface?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this interface even used? My IDE can't find a us of it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, I doubt it is

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 don't see it being used anywhere

if errors.As(workflowContext.err, &canceledErr) {
// Workflow canceled
metricsHandler.Counter(metrics.WorkflowCanceledCounter).Inc(1)
metricCounterToIncrement = metrics.WorkflowCanceledCounter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you check if the existing test coverage for these completion metrics is sufficient to catch any potential bugs here? (I can check if you haven't just let me know)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not check, only confirmed existing tests pass and added my check w/ unhandled command that wouldn't have passed before. Doing a quick glance, I don't think any of these completion metrics have any coverage. Do you feel that new tests covering these existing metrics should be in this PR? I don't mind doing it if I must, will just add some time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have test coverage to make sure these metrics are still being emitted correctly. Unfortunately we lack test coverage of some basic metrics in the Go SDK so we have to keep an eye out. I don't think it adds a lot of complexity to your test to iterate through the few other ways a workflow can complete.

Copy link
Member Author

@cretz cretz Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do as part of this PR (may not be right away though)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test

Copy link
Contributor

@yuandrew yuandrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, deferring to quinn to approve after the tests he mentioned are added

switch request := completedRequest.(type) {
if taskCompletion == nil {
// should not happen
panic("unknown request type from ProcessWorkflowTask()")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we panic here instead of logging an error? Seems like Core's dbg_panic would be nice here, where we can panic for tests but only log an error when running an real worker

Copy link
Member Author

@cretz cretz Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we panic here instead of logging an error?

Because we always did, see the default case of the type switch below, I just also put it up here to check the situation where taskCompletion could be nil. I have no opinion on whether we should panic though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

workflow_completed and workflow_continue_as_new counters should be logged after a successful reporting to the server

3 participants