servicename

This commit is contained in:
jiangyong 2026-11-13 18:16:09 +08:00
parent a2129ac5ca
commit 24ddf2fe42
1 changed files with 12 additions and 4 deletions

View File

@ -45,14 +45,22 @@ type service struct {
}
func newService(c *Config) *service {
hostname, _ := os.Hostname()
hostname := os.Getenv("_POD_NAME")
hostip := os.Getenv("_HOST_IP")
podip := os.Getenv("_POD_IP")
serviceName := os.Getenv("_SERVICE_NAME")
if hostname == "" {
hostname, _ = os.Hostname()
}
return &service{
metrics: make(chan *metric, 100000),
hostname: hostname,
serviceName: os.Getenv("SERVICE_NAME"),
podIp: os.Getenv("POD_IP"),
hostIp: os.Getenv("HOST_IP"),
serviceName: serviceName,
podIp: podip,
hostIp: hostip,
config: c,
}
}