|
6 | 6 | "strings" |
7 | 7 |
|
8 | 8 | enumspb "go.temporal.io/api/enums/v1" |
| 9 | + historypb "go.temporal.io/api/history/v1" |
9 | 10 | enumsspb "go.temporal.io/server/api/enums/v1" |
10 | 11 | "go.temporal.io/server/common/locks" |
11 | 12 | "go.temporal.io/server/common/primitives" |
@@ -38,24 +39,31 @@ const ( |
38 | 39 | // Generic reason tag can be used anywhere a reason is needed. |
39 | 40 | reason = "reason" |
40 | 41 | // See server.api.enums.v1.ReplicationTaskType |
41 | | - replicationTaskType = "replicationTaskType" |
42 | | - replicationTaskPriority = "replicationTaskPriority" |
43 | | - versioningBehavior = "versioning_behavior" |
44 | | - isFirstAttempt = "first-attempt" |
45 | | - workflowStatus = "workflow_status" |
46 | | - workflowBehaviorBeforeOverride = "workflow_behavior_before_override" |
47 | | - workflowBehaviorAfterOverride = "workflow_behavior_after_override" |
48 | | - versioningOverrideOnNewWorkflow = "versioning_override_on_new_workflow" |
49 | | - effectiveDeploymentBeforeTransition = "effective_deployment_before_transition" |
50 | | - effectiveDeploymentAfterTransition = "effective_deployment_after_transition" |
51 | | - queryType = "query_type" |
52 | | - namespaceAllValue = "all" |
53 | | - unknownValue = "_unknown_" |
54 | | - totalMetricSuffix = "_total" |
55 | | - tagExcludedValue = "_tag_excluded_" |
56 | | - falseValue = "false" |
57 | | - trueValue = "true" |
58 | | - errorPrefix = "*" |
| 42 | + replicationTaskType = "replicationTaskType" |
| 43 | + replicationTaskPriority = "replicationTaskPriority" |
| 44 | + versioningBehavior = "versioning_behavior" |
| 45 | + isFirstAttempt = "first-attempt" |
| 46 | + workflowStatus = "workflow_status" |
| 47 | + behaviorBefore = "behavior_before" |
| 48 | + behaviorAfter = "behavior_after" |
| 49 | + runInitiator = "run_initiator" |
| 50 | + fromUnversioned = "from_unversioned" |
| 51 | + toUnversioned = "to_unversioned" |
| 52 | + queryType = "query_type" |
| 53 | + namespaceAllValue = "all" |
| 54 | + unknownValue = "_unknown_" |
| 55 | + totalMetricSuffix = "_total" |
| 56 | + tagExcludedValue = "_tag_excluded_" |
| 57 | + falseValue = "false" |
| 58 | + trueValue = "true" |
| 59 | + errorPrefix = "*" |
| 60 | + |
| 61 | + newRun = "__new" |
| 62 | + existingRun = "__existing" |
| 63 | + childRun = "__child" |
| 64 | + canRun = "__can" |
| 65 | + retryRun = "__retry" |
| 66 | + cronRun = "__cron" |
59 | 67 | ) |
60 | 68 |
|
61 | 69 | // Tag is an interface to define metrics tags |
@@ -394,21 +402,42 @@ func DestinationTag(value string) Tag { |
394 | 402 | } |
395 | 403 |
|
396 | 404 | func VersioningBehaviorBeforeOverrideTag(behavior enumspb.VersioningBehavior) Tag { |
397 | | - return &tagImpl{key: workflowBehaviorBeforeOverride, value: behavior.String()} |
| 405 | + return &tagImpl{key: behaviorBefore, value: behavior.String()} |
398 | 406 | } |
399 | 407 |
|
400 | 408 | func VersioningBehaviorAfterOverrideTag(behavior enumspb.VersioningBehavior) Tag { |
401 | | - return &tagImpl{key: workflowBehaviorAfterOverride, value: behavior.String()} |
| 409 | + return &tagImpl{key: behaviorAfter, value: behavior.String()} |
402 | 410 | } |
403 | 411 |
|
404 | | -func VersioningOverrideOnNewWorkflowTag(isNewWorkflow bool) Tag { |
405 | | - return &tagImpl{key: versioningOverrideOnNewWorkflow, value: strconv.FormatBool(isNewWorkflow)} |
| 412 | +func RunInitiatorTag(prevRunID string, attributes *historypb.WorkflowExecutionStartedEventAttributes) Tag { |
| 413 | + // UpdateWorkflowExecutionOptions API is the caller |
| 414 | + if attributes == nil { |
| 415 | + return &tagImpl{key: runInitiator, value: existingRun} |
| 416 | + } |
| 417 | + |
| 418 | + // StartWorkflowExecution API is the caller |
| 419 | + if prevRunID == "" { |
| 420 | + return &tagImpl{key: runInitiator, value: newRun} |
| 421 | + } else if attributes.GetInitiator() == enumspb.CONTINUE_AS_NEW_INITIATOR_WORKFLOW { |
| 422 | + return &tagImpl{key: runInitiator, value: childRun} |
| 423 | + } else if attributes.GetInitiator() == enumspb.CONTINUE_AS_NEW_INITIATOR_RETRY { |
| 424 | + return &tagImpl{key: runInitiator, value: retryRun} |
| 425 | + } else if attributes.GetInitiator() == enumspb.CONTINUE_AS_NEW_INITIATOR_CRON_SCHEDULE { |
| 426 | + return &tagImpl{key: runInitiator, value: cronRun} |
| 427 | + } |
| 428 | + return &tagImpl{key: runInitiator, value: existingRun} |
406 | 429 | } |
407 | 430 |
|
408 | | -func EffectiveDeploymentBeforeTransitionTag(version string) Tag { |
409 | | - return &tagImpl{key: effectiveDeploymentBeforeTransition, value: version} |
| 431 | +func FromUnversionedTag(version string) Tag { |
| 432 | + if version == "_unversioned_" { |
| 433 | + return &tagImpl{key: fromUnversioned, value: trueValue} |
| 434 | + } |
| 435 | + return &tagImpl{key: fromUnversioned, value: falseValue} |
410 | 436 | } |
411 | 437 |
|
412 | | -func EffectiveDeploymentAfterTransitionTag(version string) Tag { |
413 | | - return &tagImpl{key: effectiveDeploymentAfterTransition, value: version} |
| 438 | +func ToUnversionedTag(version string) Tag { |
| 439 | + if version == "_unversioned_" { |
| 440 | + return &tagImpl{key: toUnversioned, value: trueValue} |
| 441 | + } |
| 442 | + return &tagImpl{key: toUnversioned, value: falseValue} |
414 | 443 | } |
0 commit comments