in util/common/metrics.go [232:274]
func SendAppSignalMetrics(duration time.Duration) error {
// The bash script to be executed asynchronously.
dir, err := os.Getwd()
if err != nil {
fmt.Println("Error getting current directory:", err)
return err
}
fmt.Println("Current Directory:", dir)
// Determine the base directory for the files based on the OS
var baseDir string
if runtime.GOOS == "windows" {
baseDir = filepath.Join("C:", "Users", "Administrator", "amazon-cloudwatch-agent-test", "test", "app_signals", "resources", "metrics")
} else { // assuming macOS or Unix-like system
baseDir = filepath.Join("/", "Users", "ec2-user", "amazon-cloudwatch-agent-test", "test", "app_signals", "resources", "metrics")
}
fmt.Println("Base directory:", baseDir)
for i := 0; i < int(duration/SleepDuration); i++ {
if err != nil {
return err
}
//start time to send to process file
startTime := time.Now().UnixNano()
//process files
err = processFile(filepath.Join(baseDir, "server_consumer.json"), startTime)
if err != nil {
return err
}
err = processFile(filepath.Join(baseDir, "client_producer.json"), startTime)
if err != nil {
return err
}
time.Sleep(5 * time.Second)
}
return nil
}