@@ -5236,6 +5236,7 @@ func TestLoggerAndMetricsForPartition_InternalTaskQueue(t *testing.T) {
52365236 tests := []struct {
52375237 name string
52385238 tqName string
5239+ sticky bool
52395240 expectTQValue string
52405241 }{
52415242 {
@@ -5248,12 +5249,23 @@ func TestLoggerAndMetricsForPartition_InternalTaskQueue(t *testing.T) {
52485249 tqName : "/temporal-sys/worker-commands/ns/key" ,
52495250 expectTQValue : "__temporal_sys__" ,
52505251 },
5252+ {
5253+ name : "sticky task queue uses base queue name" ,
5254+ tqName : "my-task-queue" ,
5255+ sticky : true ,
5256+ expectTQValue : "my-task-queue" ,
5257+ },
52515258 }
52525259
52535260 for _ , tc := range tests {
52545261 t .Run (tc .name , func (t * testing.T ) {
52555262 capture := captureHandler .StartCapture ()
5256- prtn := newRootPartition (ns .ID ().String (), tc .tqName , enumspb .TASK_QUEUE_TYPE_NEXUS )
5263+ var prtn tqid.Partition
5264+ if tc .sticky {
5265+ prtn = newTestTaskQueue (ns .ID ().String (), tc .tqName , enumspb .TASK_QUEUE_TYPE_WORKFLOW ).StickyPartition (uuid .NewString ())
5266+ } else {
5267+ prtn = newRootPartition (ns .ID ().String (), tc .tqName , enumspb .TASK_QUEUE_TYPE_NEXUS )
5268+ }
52575269 tqConfig := newTaskQueueConfig (prtn .TaskQueue (), config , matchingTestNamespace )
52585270 _ , _ , handler := e .loggerAndMetricsForPartition (ns , prtn , tqConfig )
52595271 // Emit a test metric through the handler and verify the taskqueue tag value.
@@ -5273,6 +5285,59 @@ func TestLoggerAndMetricsForPartition_InternalTaskQueue(t *testing.T) {
52735285 }
52745286}
52755287
5288+ func TestLoggerAndMetricsForPartition_BreakdownDisabled (t * testing.T ) {
5289+ t .Parallel ()
5290+
5291+ controller := gomock .NewController (t )
5292+ ns , mockNamespaceCache := createMockNamespaceCache (controller , matchingTestNamespace )
5293+ dc := dynamicconfig.StaticClient {
5294+ dynamicconfig .MetricsBreakdownByTaskQueue .Key (): false ,
5295+ }
5296+ config := NewConfig (dynamicconfig .NewCollection (dc , log .NewNoopLogger ()))
5297+ config .LongPollExpirationInterval = dynamicconfig .GetDurationPropertyFnFilteredByTaskQueue (100 * time .Millisecond )
5298+ e := createTestMatchingEngine (log .NewTestLogger (), controller , config , nil , mockNamespaceCache )
5299+ captureHandler := metricstest .NewCaptureHandler ()
5300+ e .metricsHandler = captureHandler
5301+
5302+ tests := []struct {
5303+ name string
5304+ tqName string
5305+ expectTQValue string
5306+ }{
5307+ {
5308+ name : "normal task queue is omitted when breakdown disabled" ,
5309+ tqName : "my-task-queue" ,
5310+ expectTQValue : "__omitted__" ,
5311+ },
5312+ {
5313+ name : "internal task queue still gets __temporal_sys__ when breakdown disabled" ,
5314+ tqName : "/temporal-sys/worker-commands/ns/key" ,
5315+ expectTQValue : "__temporal_sys__" ,
5316+ },
5317+ }
5318+
5319+ for _ , tc := range tests {
5320+ t .Run (tc .name , func (t * testing.T ) {
5321+ capture := captureHandler .StartCapture ()
5322+ prtn := newRootPartition (ns .ID ().String (), tc .tqName , enumspb .TASK_QUEUE_TYPE_NEXUS )
5323+ tqConfig := newTaskQueueConfig (prtn .TaskQueue (), config , matchingTestNamespace )
5324+ _ , _ , handler := e .loggerAndMetricsForPartition (ns , prtn , tqConfig )
5325+ metrics .PollSuccessPerTaskQueueCounter .With (handler ).Record (1 )
5326+ snap := capture .Snapshot ()
5327+ captureHandler .StopCapture (capture )
5328+ recordings := snap ["poll_success" ]
5329+ require .NotEmpty (t , recordings , "expected poll_success metric to be recorded" )
5330+ found := false
5331+ for _ , rec := range recordings {
5332+ if rec .Tags ["taskqueue" ] == tc .expectTQValue {
5333+ found = true
5334+ }
5335+ }
5336+ assert .True (t , found , "expected taskqueue tag value %q" , tc .expectTQValue )
5337+ })
5338+ }
5339+ }
5340+
52765341func TestConvertPollWorkflowTaskQueueResponse (t * testing.T ) {
52775342 t .Parallel ()
52785343
0 commit comments