2024-01-21 18:12:39 +08:00
|
|
|
package metric
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2024-01-21 22:54:16 +08:00
|
|
|
func Count(name string, value int64, tag map[string]string) {
|
2024-01-21 18:12:39 +08:00
|
|
|
if serv == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
serv.add(&metric{
|
2024-01-21 22:54:16 +08:00
|
|
|
Type: TypeCount,
|
2024-01-21 18:12:39 +08:00
|
|
|
Metric: name,
|
|
|
|
Value: value,
|
2024-01-21 22:54:16 +08:00
|
|
|
Count: 1,
|
|
|
|
Tags: tag,
|
|
|
|
Timestamp: time.Now().Unix(),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func Duration(name string, costMs int64, tag map[string]string) {
|
2024-02-03 22:20:38 +08:00
|
|
|
if serv == nil {
|
|
|
|
return
|
|
|
|
}
|
2024-01-21 22:54:16 +08:00
|
|
|
serv.add(&metric{
|
|
|
|
Type: TypeDuration,
|
|
|
|
Metric: name,
|
|
|
|
Value: costMs,
|
|
|
|
Count: 1,
|
2024-01-21 18:12:39 +08:00
|
|
|
Tags: tag,
|
|
|
|
Timestamp: time.Now().Unix(),
|
|
|
|
})
|
|
|
|
}
|