@@ -461,6 +461,9 @@ func (engine *DockerStatsEngine) StartMetricsPublish() {
461
461
select {
462
462
case <- engine .publishMetricsTicker .C :
463
463
seelog .Debugf ("publishMetricsTicker triggered. Sending telemetry messages to tcsClient through channel" )
464
+ if includeServiceConnectStats {
465
+ seelog .Debugf ("service connect metrics included" )
466
+ }
464
467
go engine .publishMetrics (includeServiceConnectStats )
465
468
go engine .publishHealth ()
466
469
case <- engine .ctx .Done ():
@@ -543,16 +546,22 @@ func (engine *DockerStatsEngine) GetInstanceMetrics(includeServiceConnectStats b
543
546
containerMetrics , err := engine .taskContainerMetricsUnsafe (taskArn )
544
547
if err != nil {
545
548
seelog .Debugf ("Error getting container metrics for task: %s, err: %v" , taskArn , err )
546
- // skip collecting service connect related metrics, if task is not service connect enabled
547
- if ! isServiceConnectTask {
549
+ // skip collecting service connect related metrics, if task is not service connect enabled.
550
+ // when task metrics and health metrics are both disabled and there is a service connect task,
551
+ // and we should not include service connect this time, we also need to skip following execution
552
+ // to avoid invalid metrics sent to TCS
553
+ if ! isServiceConnectTask || ! includeServiceConnectStats {
548
554
continue
549
555
}
550
556
}
551
557
552
558
if len (containerMetrics ) == 0 {
553
559
seelog .Debugf ("Empty containerMetrics for task, ignoring, task: %s" , taskArn )
554
- // skip collecting service connect related metrics, if task is not service connect enabled
555
- if ! isServiceConnectTask {
560
+ // skip collecting service connect related metrics, if task is not service connect enabled.
561
+ // when task metrics and health metrics are both disabled and there is a service connect task,
562
+ // and we should not include service connect this time, we also need to skip following execution
563
+ // to avoid invalid metrics sent to TCS
564
+ if ! isServiceConnectTask || ! includeServiceConnectStats {
556
565
continue
557
566
}
558
567
}
@@ -575,6 +584,7 @@ func (engine *DockerStatsEngine) GetInstanceMetrics(includeServiceConnectStats b
575
584
if serviceConnectStats , ok := engine .taskToServiceConnectStats [taskArn ]; ok {
576
585
if ! serviceConnectStats .HasStatsBeenSent () {
577
586
taskMetric .ServiceConnectMetricsWrapper = serviceConnectStats .GetStats ()
587
+ seelog .Debugf ("Adding service connect stats for task : %s" , taskArn )
578
588
serviceConnectStats .SetStatsSent (true )
579
589
}
580
590
}
@@ -584,6 +594,7 @@ func (engine *DockerStatsEngine) GetInstanceMetrics(includeServiceConnectStats b
584
594
585
595
if len (taskMetrics ) == 0 {
586
596
// Not idle. Expect taskMetrics to be there.
597
+ seelog .Debugf ("Return empty metrics error" )
587
598
return nil , nil , EmptyMetricsError
588
599
}
589
600
0 commit comments