Skip to content
Open
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 @@ -49,6 +49,8 @@ to docs, or any other relevant information.
project-scoped custom roles, and caller rate limits.

### Fixed
- Keep Nexus response request counters and latency metrics compatible with Prometheus by including
`nexus_service` and `nexus_operation` on regular gRPC request metrics, where they default to `none`.
- Autoscaling workflow pollers now prioritize meaningful sticky backlog up to the sticky pool's
target and use advertised slot capacity to balance sticky and non-sticky admission. Without an
advertised maximum, additional polls of one queue type wait until the other has an active poll.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,35 @@

import static io.temporal.testUtils.Eventually.assertEventually;
import static junit.framework.TestCase.*;
import static org.junit.Assert.assertThrows;
import static org.junit.Assume.assumeTrue;

import com.uber.m3.tally.RootScopeBuilder;
import com.uber.m3.tally.Scope;
import io.grpc.StatusRuntimeException;
import io.micrometer.core.instrument.*;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityMethod;
import io.temporal.activity.LocalActivityOptions;
import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.api.enums.v1.WorkflowTaskFailedCause;
import io.temporal.api.workflowservice.v1.GetSystemInfoRequest;
import io.temporal.api.workflowservice.v1.RespondNexusTaskCompletedRequest;
import io.temporal.client.*;
import io.temporal.common.reporter.MicrometerClientStatsReporter;
import io.temporal.failure.ApplicationFailure;
import io.temporal.failure.CanceledFailure;
import io.temporal.serviceclient.MetricsTag;
import io.temporal.serviceclient.MetricsType;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.testing.internal.SDKTestWorkflowRule;
import io.temporal.workflow.*;
import java.time.Duration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -149,6 +157,51 @@ public void testAsynchronousStartAndGetResult() throws InterruptedException, Exe
});
}

@Test
public void testNexusResponseMetricsHaveConsistentTagKeys() {
WorkflowServiceStubs service = testWorkflowRule.getWorkflowServiceStubs();
service.blockingStub().getSystemInfo(GetSystemInfoRequest.getDefaultInstance());

Map<String, String> nexusTags = new HashMap<>(MetricsTag.defaultTags(MetricsTag.DEFAULT_VALUE));
nexusTags.put(MetricsTag.NEXUS_SERVICE, "TestNexusService");
nexusTags.put(MetricsTag.NEXUS_OPERATION, "testOperation");
Scope nexusScope = service.getOptions().getMetricsScope().tagged(nexusTags);
// The test server rejects the empty task token, and the interceptor records the RPC.
assertThrows(
StatusRuntimeException.class,
() ->
service
.blockingStub()
.withOption(MetricsTag.METRICS_TAGS_CALL_OPTIONS_KEY, nexusScope)
.respondNexusTaskCompleted(RespondNexusTaskCompletedRequest.getDefaultInstance()));

assertEventually(
Duration.ofSeconds(2),
() -> {
for (String metric :
new String[] {MetricsType.TEMPORAL_REQUEST, MetricsType.TEMPORAL_REQUEST_LATENCY}) {
Meter ordinary =
registry.find(metric).tag(MetricsTag.OPERATION_NAME, "GetSystemInfo").meter();
Meter nexus =
registry
.find(metric)
.tag(MetricsTag.OPERATION_NAME, "RespondNexusTaskCompleted")
.meter();
assertNotNull(ordinary);
assertNotNull(nexus);
assertEquals(
ordinary.getId().getTags().stream().map(Tag::getKey).collect(Collectors.toSet()),
nexus.getId().getTags().stream().map(Tag::getKey).collect(Collectors.toSet()));
assertEquals(
MetricsTag.DEFAULT_VALUE, ordinary.getId().getTag(MetricsTag.NEXUS_SERVICE));
assertEquals(
MetricsTag.DEFAULT_VALUE, ordinary.getId().getTag(MetricsTag.NEXUS_OPERATION));
assertEquals("TestNexusService", nexus.getId().getTag(MetricsTag.NEXUS_SERVICE));
assertEquals("testOperation", nexus.getId().getTag(MetricsTag.NEXUS_OPERATION));
}
});
}

@Test
public void testStandaloneActivityStartRequestTags() {
// SAA is not supported by in-mem test server yet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ private static Map<String, String> tags(String namespace) {
.put(SIGNAL_NAME, DEFAULT_VALUE)
.put(QUERY_TYPE, DEFAULT_VALUE)
.put(UPDATE_NAME, DEFAULT_VALUE)
.put(NEXUS_SERVICE, DEFAULT_VALUE)
.put(NEXUS_OPERATION, DEFAULT_VALUE)
.put(TASK_QUEUE, DEFAULT_VALUE)
.put(STATUS_CODE, DEFAULT_VALUE)
.put(EXCEPTION, DEFAULT_VALUE)
Expand Down