공통 메트릭 추가
This commit is contained in:
@ -106,6 +106,7 @@ func (mc *metricCollection) metricWriter() {
|
||||
}
|
||||
|
||||
var NewMetric func(MetricType, string, string, map[string]string) MetricWriter
|
||||
var ConcurrentUser = MetricWriterNil
|
||||
|
||||
func init() {
|
||||
NewMetric = func(MetricType, string, string, map[string]string) MetricWriter {
|
||||
@ -130,6 +131,7 @@ func init() {
|
||||
logger.Println("metrics are going to be generated for houston")
|
||||
go mc.metricWriter()
|
||||
NewMetric = newMetricImpl
|
||||
ConcurrentUser = NewMetric(MetricGuage, "concurrent_user", "concurrent user count", nil)
|
||||
} else {
|
||||
logger.Println("metrics are NOT going to be generated. parent is not houston :", filename, string(fn))
|
||||
}
|
||||
@ -145,6 +147,15 @@ func newMetricImpl(mt MetricType, name string, help string, constLabels map[stri
|
||||
hash := md5.New()
|
||||
hash.Write([]byte(name))
|
||||
|
||||
if constLabels == nil {
|
||||
constLabels = make(map[string]string)
|
||||
}
|
||||
|
||||
hn, _ := os.Hostname()
|
||||
sn := path.Base(os.Args[0])
|
||||
constLabels["hostname"] = hn
|
||||
constLabels["service"] = sn
|
||||
|
||||
key := hex.EncodeToString(hash.Sum(nil))[:metric_key_size]
|
||||
temp, _ := json.Marshal(MetricDescription{
|
||||
Key: key,
|
||||
|
||||
Reference in New Issue
Block a user