Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ to docs, or any other relevant information.
credentials set through `setHeaders` no longer appear in logs.
- The JavaDoc of `WorkflowClient.startUpdate` and `WorkflowClient.startUpdateWithStart` no longer describes these calls
as asynchronous.
- Client request metrics (`temporal_long_request_latency` etc.) now always carry the `update_name` tag (default
`none`), fixing Prometheus tag-key conflicts when Workflow Updates are used (#3210).

## [1.41.1] - 2026-11-16

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import io.temporal.testing.internal.SDKTestWorkflowRule;
import io.temporal.workflow.*;
import java.time.Duration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
Expand All @@ -42,7 +44,10 @@ public class MetricsTest {
@Rule
public final SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setWorkflowTypes(QuicklyCompletingWorkflowImpl.class, MultiScenarioWorkflowImpl.class)
.setWorkflowTypes(
QuicklyCompletingWorkflowImpl.class,
MultiScenarioWorkflowImpl.class,
UpdatableWorkflowImpl.class)
.setActivityImplementations(runCallbackActivity, new StandaloneMetricsActivityImpl())
.setMetricsScope(
new RootScopeBuilder()
Expand Down Expand Up @@ -294,6 +299,43 @@ public void testUnhandledCommand() throws Exception {
io.temporal.worker.MetricsType.WORKFLOW_COMPLETED_COUNTER);
}

@Test
public void testLongRequestMetricsHaveConsistentTagKeysForUpdates() throws Exception {
UpdatableWorkflow workflow =
testWorkflowRule
.getWorkflowClient()
.newWorkflowStub(
UpdatableWorkflow.class,
WorkflowOptions.newBuilder()
.setTaskQueue(testWorkflowRule.getTaskQueue())
.validateBuildWithDefaults());
WorkflowClient.start(workflow::execute);
assertEquals("updated", workflow.finish());
assertEquals("done", WorkflowStub.fromTyped(workflow).getResult(String.class));

assertEventually(
Duration.ofSeconds(2),
() -> {
Set<Set<String>> tagKeySets = new HashSet<>();
boolean sawUpdate = false;
for (Meter meter : registry.getMeters()) {
if (MetricsType.TEMPORAL_LONG_REQUEST_LATENCY.equals(meter.getId().getName())) {
tagKeySets.add(
meter.getId().getTags().stream().map(Tag::getKey).collect(Collectors.toSet()));
sawUpdate |=
"finish".equals(meter.getId().getTag(MetricsTag.UPDATE_NAME))
&& "UpdateWorkflowExecution"
.equals(meter.getId().getTag(MetricsTag.OPERATION_NAME));
}
}
assertTrue("no long request latency for the update was reported", sawUpdate);
assertEquals(
"all temporal_long_request_latency series must share the same tag keys",
1,
tagKeySets.size());
});
}

private void assertSingleMeterCountForMultiScenario(String metric) {
assertEventually(
Duration.ofSeconds(2),
Expand Down Expand Up @@ -346,6 +388,31 @@ public String execute() {
}
}

@WorkflowInterface
public interface UpdatableWorkflow {
@WorkflowMethod
String execute();

@UpdateMethod
String finish();
}

public static class UpdatableWorkflowImpl implements UpdatableWorkflow {
private boolean finished;

@Override
public String execute() {
Workflow.await(() -> finished);
return "done";
}

@Override
public String finish() {
finished = true;
return "updated";
}
}

@WorkflowInterface
public interface MultiScenarioWorkflow {
enum Scenario {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ public static Map<String, String> defaultTags(String namespace) {
}

private static Map<String, String> tags(String namespace) {
return new ImmutableMap.Builder<String, String>(9)
return new ImmutableMap.Builder<String, String>(11)
.put(NAMESPACE, namespace)
.put(ACTIVITY_TYPE, DEFAULT_VALUE)
.put(OPERATION_NAME, DEFAULT_VALUE)
.put(SIGNAL_NAME, DEFAULT_VALUE)
.put(QUERY_TYPE, DEFAULT_VALUE)
.put(UPDATE_NAME, DEFAULT_VALUE)
.put(TASK_QUEUE, DEFAULT_VALUE)
.put(STATUS_CODE, DEFAULT_VALUE)
.put(EXCEPTION, DEFAULT_VALUE)
Expand Down
Loading