@@ -5223,6 +5223,9 @@ func (*testTaskManager) CountTaskQueuesByBuildId(context.Context, *persistence.C
52235223 return 0 , nil
52245224}
52255225
5226+ // TestLoggerAndMetricsForPartition_InternalTaskQueue verifies that /temporal-sys/ queues get
5227+ // the __temporal_sys__ taskqueue tag while normal and sticky queues use their actual names
5228+ // (with the default BreakdownMetricsByTaskQueue=true).
52265229func TestLoggerAndMetricsForPartition_InternalTaskQueue (t * testing.T ) {
52275230 t .Parallel ()
52285231
@@ -5236,6 +5239,7 @@ func TestLoggerAndMetricsForPartition_InternalTaskQueue(t *testing.T) {
52365239 tests := []struct {
52375240 name string
52385241 tqName string
5242+ sticky bool
52395243 expectTQValue string
52405244 }{
52415245 {
@@ -5248,12 +5252,23 @@ func TestLoggerAndMetricsForPartition_InternalTaskQueue(t *testing.T) {
52485252 tqName : "/temporal-sys/worker-commands/ns/key" ,
52495253 expectTQValue : "__temporal_sys__" ,
52505254 },
5255+ {
5256+ name : "sticky task queue uses base queue name" ,
5257+ tqName : "my-task-queue" ,
5258+ sticky : true ,
5259+ expectTQValue : "my-task-queue" ,
5260+ },
52515261 }
52525262
52535263 for _ , tc := range tests {
52545264 t .Run (tc .name , func (t * testing.T ) {
52555265 capture := captureHandler .StartCapture ()
5256- prtn := newRootPartition (ns .ID ().String (), tc .tqName , enumspb .TASK_QUEUE_TYPE_NEXUS )
5266+ var prtn tqid.Partition
5267+ if tc .sticky {
5268+ prtn = newTestTaskQueue (ns .ID ().String (), tc .tqName , enumspb .TASK_QUEUE_TYPE_WORKFLOW ).StickyPartition (uuid .NewString ())
5269+ } else {
5270+ prtn = newRootPartition (ns .ID ().String (), tc .tqName , enumspb .TASK_QUEUE_TYPE_NEXUS )
5271+ }
52575272 tqConfig := newTaskQueueConfig (prtn .TaskQueue (), config , matchingTestNamespace )
52585273 _ , _ , handler := e .loggerAndMetricsForPartition (ns , prtn , tqConfig )
52595274 // Emit a test metric through the handler and verify the taskqueue tag value.
@@ -5273,6 +5288,73 @@ func TestLoggerAndMetricsForPartition_InternalTaskQueue(t *testing.T) {
52735288 }
52745289}
52755290
5291+ // TestLoggerAndMetricsForPartition_BreakdownDisabled verifies behavior with BreakdownMetricsByTaskQueue=false:
5292+ // normal and sticky queues get __omitted__, but /temporal-sys/ queues still get __temporal_sys__.
5293+ func TestLoggerAndMetricsForPartition_BreakdownDisabled (t * testing.T ) {
5294+ t .Parallel ()
5295+
5296+ controller := gomock .NewController (t )
5297+ ns , mockNamespaceCache := createMockNamespaceCache (controller , matchingTestNamespace )
5298+ dc := dynamicconfig.StaticClient {
5299+ dynamicconfig .MetricsBreakdownByTaskQueue .Key (): false ,
5300+ }
5301+ config := NewConfig (dynamicconfig .NewCollection (dc , log .NewNoopLogger ()))
5302+ config .LongPollExpirationInterval = dynamicconfig .GetDurationPropertyFnFilteredByTaskQueue (100 * time .Millisecond )
5303+ e := createTestMatchingEngine (log .NewTestLogger (), controller , config , nil , mockNamespaceCache )
5304+ captureHandler := metricstest .NewCaptureHandler ()
5305+ e .metricsHandler = captureHandler
5306+
5307+ tests := []struct {
5308+ name string
5309+ tqName string
5310+ sticky bool
5311+ expectTQValue string
5312+ }{
5313+ {
5314+ name : "normal task queue is omitted when breakdown disabled" ,
5315+ tqName : "my-task-queue" ,
5316+ expectTQValue : "__omitted__" ,
5317+ },
5318+ {
5319+ name : "internal task queue still gets __temporal_sys__ when breakdown disabled" ,
5320+ tqName : "/temporal-sys/worker-commands/ns/key" ,
5321+ expectTQValue : "__temporal_sys__" ,
5322+ },
5323+ {
5324+ name : "sticky task queue is omitted when breakdown disabled" ,
5325+ tqName : "my-task-queue" ,
5326+ sticky : true ,
5327+ expectTQValue : "__omitted__" ,
5328+ },
5329+ }
5330+
5331+ for _ , tc := range tests {
5332+ t .Run (tc .name , func (t * testing.T ) {
5333+ capture := captureHandler .StartCapture ()
5334+ var prtn tqid.Partition
5335+ if tc .sticky {
5336+ prtn = newTestTaskQueue (ns .ID ().String (), tc .tqName , enumspb .TASK_QUEUE_TYPE_WORKFLOW ).StickyPartition (uuid .NewString ())
5337+ } else {
5338+ prtn = newRootPartition (ns .ID ().String (), tc .tqName , enumspb .TASK_QUEUE_TYPE_NEXUS )
5339+ }
5340+ tqConfig := newTaskQueueConfig (prtn .TaskQueue (), config , matchingTestNamespace )
5341+ _ , _ , handler := e .loggerAndMetricsForPartition (ns , prtn , tqConfig )
5342+ metrics .PollSuccessPerTaskQueueCounter .With (handler ).Record (1 )
5343+ snap := capture .Snapshot ()
5344+ captureHandler .StopCapture (capture )
5345+ recordings := snap ["poll_success" ]
5346+ require .NotEmpty (t , recordings , "expected poll_success metric to be recorded" )
5347+ found := false
5348+ for _ , rec := range recordings {
5349+ if rec .Tags ["taskqueue" ] == tc .expectTQValue {
5350+ found = true
5351+ }
5352+ }
5353+ assert .True (t , found , "expected taskqueue tag value %q" , tc .expectTQValue )
5354+ })
5355+ }
5356+ }
5357+
52765358func TestConvertPollWorkflowTaskQueueResponse (t * testing.T ) {
52775359 t .Parallel ()
52785360
0 commit comments