in internal/daemon/redis/redis.go [63:119]
func (s *Service) Start(ctx context.Context, a any) {
if s.Config.GetRedisConfiguration() != nil && !s.Config.GetRedisConfiguration().GetEnabled() {
// If Redis workload agent service is explicitly disabled in the configuration, then return.
log.CtxLogger(ctx).Info("Redis workload agent service is disabled in the configuration")
return
}
go (func() {
for {
s.checkServiceCommunication(ctx)
}
})()
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
enabled := s.Config.GetRedisConfiguration().GetEnabled()
EnableCheck:
for {
select {
case <-ctx.Done():
log.CtxLogger(ctx).Info("Redis workload agent service cancellation requested")
return
case <-ticker.C:
// Once DW is enabled and the workload is present/enabled, start discovery and metric collection.
if s.dwActivated && (s.isWorkloadPresent() || enabled) {
log.CtxLogger(ctx).Info("Redis workload agent service is enabled and DW is activated. Starting discovery and metric collection")
break EnableCheck
}
}
}
// Start Redis Discovery
dCtx := log.SetCtx(ctx, "context", "RedisDiscovery")
discoveryRoutine := &recovery.RecoverableRoutine{
Routine: runDiscovery,
RoutineArg: runDiscoveryArgs{s},
ErrorCode: usagemetrics.RedisDiscoveryFailure,
UsageLogger: *usagemetrics.UsageLogger,
ExpectedMinDuration: 0,
}
discoveryRoutine.StartRoutine(dCtx)
// Start Redis Metric Collection
mcCtx := log.SetCtx(ctx, "context", "RedisMetricCollection")
metricCollectionRoutine := &recovery.RecoverableRoutine{
Routine: runMetricCollection,
RoutineArg: runMetricCollectionArgs{s},
ErrorCode: usagemetrics.RedisMetricCollectionFailure,
UsageLogger: *usagemetrics.UsageLogger,
ExpectedMinDuration: 0,
}
metricCollectionRoutine.StartRoutine(mcCtx)
select {
case <-ctx.Done():
log.CtxLogger(ctx).Info("Redis workload agent service cancellation requested")
return
}
}