-
Notifications
You must be signed in to change notification settings - Fork 297
Populate resource_id fields for request header routing #2226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
eece8ea
3004fce
9d199d8
89129e9
2dfe1a4
636af76
746f006
a146692
613448b
c79cc72
c213166
16e0b56
f8bdc0f
26f71c0
7a7413d
68f7164
3b10ab8
7df41ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1834,8 +1834,9 @@ func (wth *workflowTaskHandlerImpl) completeWorkflow( | |
| // for query task | ||
| if task.Query != nil { | ||
| queryCompletedRequest := &workflowservice.RespondQueryTaskCompletedRequest{ | ||
| TaskToken: task.TaskToken, | ||
| Namespace: wth.namespace, | ||
| TaskToken: task.TaskToken, | ||
| Namespace: wth.namespace, | ||
| ResourceId: task.WorkflowExecution.WorkflowId, | ||
| } | ||
| var panicErr *PanicError | ||
| if errors.As(workflowContext.err, &panicErr) { | ||
|
|
@@ -1961,6 +1962,7 @@ func (wth *workflowTaskHandlerImpl) completeWorkflow( | |
| BinaryChecksum: wth.workerBuildID, | ||
| QueryResults: queryResults, | ||
| Namespace: wth.namespace, | ||
| ResourceId: task.WorkflowExecution.WorkflowId, | ||
| MeteringMetadata: &commonpb.MeteringMetadata{NonfirstLocalActivityExecutionAttempts: nonfirstLAAttempts}, | ||
| SdkMetadata: &sdk.WorkflowTaskCompletedMetadata{ | ||
| LangUsedFlags: langUsedFlags, | ||
|
|
@@ -2300,7 +2302,8 @@ func (ath *activityTaskHandlerImpl) Execute(taskQueue string, t *workflowservice | |
| metricsHandler.Counter(metrics.UnregisteredActivityInvocationCounter).Inc(1) | ||
| return convertActivityResultToRespondRequest(ath.identity, t.TaskToken, nil, | ||
| NewActivityNotRegisteredError(activityType, ath.getRegisteredActivityNames()), | ||
| ath.dataConverter, ath.failureConverter, ath.namespace, false, ath.versionStamp, ath.deployment, ath.workerDeploymentOptions), nil | ||
| ath.dataConverter, ath.failureConverter, ath.namespace, false, ath.versionStamp, ath.deployment, ath.workerDeploymentOptions, | ||
| t.WorkflowExecution.GetWorkflowId(), t.ActivityId), nil | ||
| } | ||
|
|
||
| // panic handler | ||
|
|
@@ -2318,7 +2321,8 @@ func (ath *activityTaskHandlerImpl) Execute(taskQueue string, t *workflowservice | |
| metricsHandler.Counter(metrics.ActivityTaskErrorCounter).Inc(1) | ||
| panicErr := newPanicError(p, st) | ||
| result = convertActivityResultToRespondRequest(ath.identity, t.TaskToken, nil, panicErr, | ||
| ath.dataConverter, ath.failureConverter, ath.namespace, false, ath.versionStamp, ath.deployment, ath.workerDeploymentOptions) | ||
| ath.dataConverter, ath.failureConverter, ath.namespace, false, ath.versionStamp, ath.deployment, ath.workerDeploymentOptions, | ||
| t.WorkflowExecution.GetWorkflowId(), t.ActivityId) | ||
| } | ||
| }() | ||
|
|
||
|
|
@@ -2365,7 +2369,8 @@ func (ath *activityTaskHandlerImpl) Execute(taskQueue string, t *workflowservice | |
| ) | ||
| } | ||
| return convertActivityResultToRespondRequest(ath.identity, t.TaskToken, output, err, | ||
| ath.dataConverter, ath.failureConverter, ath.namespace, isActivityCanceled, ath.versionStamp, ath.deployment, ath.workerDeploymentOptions), nil | ||
| ath.dataConverter, ath.failureConverter, ath.namespace, isActivityCanceled, ath.versionStamp, ath.deployment, ath.workerDeploymentOptions, | ||
| t.WorkflowExecution.GetWorkflowId(), t.ActivityId), nil | ||
| } | ||
|
|
||
| func (ath *activityTaskHandlerImpl) getActivity(name string) activity { | ||
|
|
@@ -2425,15 +2430,28 @@ func createNewCommandWithMetadata(commandType enumspb.CommandType, metadata *sdk | |
| } | ||
| } | ||
|
|
||
| func getActivityResourceIdFromCtx(ctx context.Context) string { | ||
| env := getActivityEnvironmentFromCtx(ctx) | ||
| if env == nil { | ||
| return "" | ||
| } | ||
| // Check if this is a workflow activity or standalone activity | ||
| if env.workflowExecution.ID != "" { | ||
| return env.workflowExecution.ID | ||
| } | ||
| return env.activityID | ||
| } | ||
|
|
||
| func recordActivityHeartbeat(ctx context.Context, service workflowservice.WorkflowServiceClient, metricsHandler metrics.Handler, | ||
| identity string, taskToken []byte, details *commonpb.Payloads, | ||
| ) error { | ||
| namespace := getNamespaceFromActivityCtx(ctx) | ||
| request := &workflowservice.RecordActivityTaskHeartbeatRequest{ | ||
| TaskToken: taskToken, | ||
| Details: details, | ||
| Identity: identity, | ||
| Namespace: namespace, | ||
| TaskToken: taskToken, | ||
| Details: details, | ||
| Identity: identity, | ||
| Namespace: namespace, | ||
| ResourceId: getActivityResourceIdFromCtx(ctx), | ||
| } | ||
|
Comment on lines
2461
to
2471
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Extended reasoning...Bug:
|
||
|
|
||
| var heartbeatResponse *workflowservice.RecordActivityTaskHeartbeatResponse | ||
|
|
@@ -2465,6 +2483,7 @@ func recordActivityHeartbeatByID(ctx context.Context, service workflowservice.Wo | |
| ActivityId: activityID, | ||
| Details: details, | ||
| Identity: identity, | ||
| ResourceId: getActivityResourceId(workflowID, activityID), | ||
| } | ||
|
|
||
| var heartbeatResponse *workflowservice.RecordActivityTaskHeartbeatByIdResponse | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want test coverage for when env == nil?