Skip to content

Add archetype metric tag and logical task processing metrics#9377

Merged
awln-temporal merged 15 commits intomainfrom
chasm-archetype-metric-tag
Mar 30, 2026
Merged

Add archetype metric tag and logical task processing metrics#9377
awln-temporal merged 15 commits intomainfrom
chasm-archetype-metric-tag

Conversation

@awln-temporal
Copy link
Copy Markdown
Contributor

@awln-temporal awln-temporal commented Feb 20, 2026

What changed?

Add archetype metric tag and logical task processing metrics, and add chasm_pure_task_requests and chasm_pure_task_errors metrics. Archetype metric tab will be applied for all tasks executed, physical and logical, that get added in Executable.go by default. If the archetype is found, the archetype display name will be used for the tag value. Otherwise, will default to workflow archetype.

For chasm logical pure task metrics, will resolve to __unknown__ if archetype is not found, since this would be unexpected behavior.

Why?

Components and therefore task types can be used across different archetype executions. In the future with more archetypes, there needs to be visibility for which archetype created the task for execution.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

@awln-temporal awln-temporal requested review from a team as code owners February 20, 2026 19:50
}

// Execute all fired pure tasks for a component while holding the workflow lock.
archetypeTag := getArchetypeTagForChasmTask(task.GetArchetypeID(), t.shardContext.ChasmRegistry())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: we can reuse getArchetypeTag defined above?

if err == nil {
processedTimers += 1

metrics.ChasmPureTaskRequests.With(t.metricsHandler).Record(1, archetypeTag)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we need to tag the pure task type as well right?

I was originally think we can do this in chasmTree.ExecutePureTask/ValidatePureTask method where the logic already looked up the registrable task based on the task instance.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved it to the chasm framework, with metrics handler as an arg to ExecutePureTask. Immediate pure tasks will not have physical task type tag, but will still include namespace, pure task type, and archetype tag. Scheduled pure tasks via physical task queues will still have the same tags applied plus the new archetype and pure task type tag.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ah nice. I was originally thinking we need to change every task executor implementation to return the new archetype tag. But make sense since this is called in the executable constructor and we basically a set of base tags there and archetype never changes.

We should probably rename this to baseTaskMetricTags

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

renamed to taskBaseMetricTags since baseTask is a bit different in my head

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not renamed yet?

@@ -89,6 +89,7 @@ var defaultExecutableMetricsTags = []metrics.Tag{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I feel we no longer need this since NewExecutable will always initialize the metricHandler with the necessary tags?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah there's no fallbacks, all the tags will exist, removed this and all references.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm looks like changes for this file is not commited/pushed? I can still see defaultExecutableMetricsTags and estimateTaskMetricTags is not renamed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

pushed now, sorry about that

@awln-temporal awln-temporal force-pushed the chasm-archetype-metric-tag branch from bd29336 to bacead3 Compare February 23, 2026 21:15
chasm/tree.go Outdated

// Only syncStructure on next iteration if task is executed (the first return value).
syncStructure, err = taskNode.ExecutePureTask(context.Background(), task.attributes, task.task)
syncStructure, err = taskNode.ExecutePureTask(context.Background(), handler, task.attributes, task.task)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oh good catch! I already forgot we have this special immediate pure task logic 🤦

return processedTimers, nil
}

func getArchetypeTagForChasmTask(archetypeID chasm.ArchetypeID, chasmRegistry *chasm.Registry) metrics.Tag {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this can be removed?

@@ -89,6 +89,7 @@ var defaultExecutableMetricsTags = []metrics.Tag{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm looks like changes for this file is not commited/pushed? I can still see defaultExecutableMetricsTags and estimateTaskMetricTags is not renamed.

@awln-temporal awln-temporal force-pushed the chasm-archetype-metric-tag branch from ab6b973 to ce8a938 Compare March 11, 2026 22:54
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not renamed yet?

Comment on lines +1050 to +1052
executed, err := executor.ExecutePureTask(ctx, t.metricsHandler, taskAttributes, taskInstance)
if err == nil && executed {
processedTimers++
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

revert?

Also I don't think we can have the executed check. processedTimers is probably not a good name, it's essentially for deciding if we need to do a write operation. If we have any invalid tasks, they won't be executed but we still want to a write op to delete them and create the next pure task (part of the closeTransaction logic).

@awln-temporal awln-temporal force-pushed the chasm-archetype-metric-tag branch from e559a32 to 4176e06 Compare March 12, 2026 17:09
@awln-temporal awln-temporal requested a review from yycptt March 12, 2026 17:09
@awln-temporal awln-temporal requested review from a team as code owners March 25, 2026 19:11
@awln-temporal awln-temporal requested review from a team as code owners March 26, 2026 20:26
@awln-temporal awln-temporal force-pushed the chasm-archetype-metric-tag branch from f494b38 to 5b72162 Compare March 26, 2026 21:43
@awln-temporal awln-temporal force-pushed the chasm-archetype-metric-tag branch from 5b72162 to f4f0bc2 Compare March 26, 2026 23:22
Copy link
Copy Markdown
Contributor

@dandavison dandavison left a comment

Choose a reason for hiding this comment

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

I approve the one line change in chasm/lib/callback/tasks_test.go. I haven't otherwise reviewed the PR.

@awln-temporal awln-temporal merged commit 87f3e35 into main Mar 30, 2026
68 of 70 checks passed
@awln-temporal awln-temporal deleted the chasm-archetype-metric-tag branch March 30, 2026 16:20
chaptersix pushed a commit to chaptersix/temporal that referenced this pull request Apr 2, 2026
…lio#9377)

## What changed?
Add archetype metric tag and logical task processing metrics, and add
`chasm_pure_task_requests` and `chasm_pure_task_errors` metrics.
Archetype metric tab will be applied for all tasks executed, physical
and logical, that get added in Executable.go by default. If the
archetype is found, the archetype display name will be used for the tag
value. Otherwise, will default to `workflow` archetype.

For chasm logical pure task metrics, will resolve to `__unknown__` if
archetype is not found, since this would be unexpected behavior.

## Why?
Components and therefore task types can be used across different
archetype executions. In the future with more archetypes, there needs to
be visibility for which archetype created the task for execution.

## How did you test it?
- [X] built
- [X] run locally and tested manually
- [X] covered by existing tests
- [X] added new unit test(s)
- [ ] added new functional test(s)
chaptersix pushed a commit to chaptersix/temporal that referenced this pull request Apr 2, 2026
…lio#9377)

## What changed?
Add archetype metric tag and logical task processing metrics, and add
`chasm_pure_task_requests` and `chasm_pure_task_errors` metrics.
Archetype metric tab will be applied for all tasks executed, physical
and logical, that get added in Executable.go by default. If the
archetype is found, the archetype display name will be used for the tag
value. Otherwise, will default to `workflow` archetype.

For chasm logical pure task metrics, will resolve to `__unknown__` if
archetype is not found, since this would be unexpected behavior.

## Why?
Components and therefore task types can be used across different
archetype executions. In the future with more archetypes, there needs to
be visibility for which archetype created the task for execution.

## How did you test it?
- [X] built
- [X] run locally and tested manually
- [X] covered by existing tests
- [X] added new unit test(s)
- [ ] added new functional test(s)
chaptersix pushed a commit that referenced this pull request Apr 2, 2026
## What changed?
Add archetype metric tag and logical task processing metrics, and add
`chasm_pure_task_requests` and `chasm_pure_task_errors` metrics.
Archetype metric tab will be applied for all tasks executed, physical
and logical, that get added in Executable.go by default. If the
archetype is found, the archetype display name will be used for the tag
value. Otherwise, will default to `workflow` archetype.

For chasm logical pure task metrics, will resolve to `__unknown__` if
archetype is not found, since this would be unexpected behavior.

## Why?
Components and therefore task types can be used across different
archetype executions. In the future with more archetypes, there needs to
be visibility for which archetype created the task for execution.

## How did you test it?
- [X] built
- [X] run locally and tested manually
- [X] covered by existing tests
- [X] added new unit test(s)
- [ ] added new functional test(s)
chaptersix pushed a commit to chaptersix/temporal that referenced this pull request Apr 2, 2026
…lio#9377)

## What changed?
Add archetype metric tag and logical task processing metrics, and add
`chasm_pure_task_requests` and `chasm_pure_task_errors` metrics.
Archetype metric tab will be applied for all tasks executed, physical
and logical, that get added in Executable.go by default. If the
archetype is found, the archetype display name will be used for the tag
value. Otherwise, will default to `workflow` archetype.

For chasm logical pure task metrics, will resolve to `__unknown__` if
archetype is not found, since this would be unexpected behavior.

## Why?
Components and therefore task types can be used across different
archetype executions. In the future with more archetypes, there needs to
be visibility for which archetype created the task for execution.

## How did you test it?
- [X] built
- [X] run locally and tested manually
- [X] covered by existing tests
- [X] added new unit test(s)
- [ ] added new functional test(s)
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.

3 participants