메트릭 시작 로그 추가

This commit is contained in:
2023-11-20 16:39:39 +09:00
parent a5d9809db7
commit c34cb485bd

View File

@ -8,6 +8,7 @@ import (
"fmt"
"math"
"os"
"path"
"sync/atomic"
"repositories.action2quare.com/ayo/gocommon/logger"
@ -101,22 +102,29 @@ func init() {
return &metric_empty{}
}
if path.Base(os.Args[0]) == "houston" {
logger.Println("metrics are going to be generated for myself(houston)")
go mc.metricWriter()
NewMetric = newMetricImpl
return
}
ppid := os.Getppid()
if parent, _ := os.FindProcess(ppid); parent != nil {
filename := fmt.Sprintf(`/proc/%d/stat`, os.Getppid())
if fn, err := os.ReadFile(filename); err == nil {
if string(fn) == "houston" {
logger.Println("metrics are activated for houston")
if path.Base(string(fn)) == "houston" {
logger.Println("metrics are going to be generated for houston")
go mc.metricWriter()
NewMetric = newMetricImpl
} else {
logger.Println("metrics are NOT activated")
logger.Println("metrics are NOT going to be generated. parent is not houston")
}
} else {
logger.Println("metrics are NOT activated")
logger.Println("metrics are NOT going to be generated. ppid proc is missing :", filename)
}
} else {
logger.Println("metrics are NOT activated")
logger.Println("metrics are NOT going to be generated. parent process is missing. ppid :", ppid)
}
}