Metric for stats elapsed time
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
68121fda15
commit
02ebfb8eea
2 changed files with 10 additions and 0 deletions
|
@ -430,6 +430,10 @@ func metricsHandler(c echo.Context) error {
|
|||
metrics += fmt.Sprintf("rosti_node_memory_index{hostname=\"%s\"} %f\n", hostname, node.MemoryIndex)
|
||||
metrics += fmt.Sprintf("rosti_node_sold_memory{hostname=\"%s\"} %d\n", hostname, node.SoldMemory)
|
||||
|
||||
if elapsedMetric != -1 {
|
||||
metrics += fmt.Sprintf("rosti_node_stats_time_elapsed{hostname=\"%s\"} %d\n", hostname, elapsedMetric)
|
||||
}
|
||||
|
||||
apps, err := processor.List(true)
|
||||
if err != nil {
|
||||
return c.JSONPretty(http.StatusInternalServerError, Message{Message: err.Error()}, JSONIndent)
|
||||
|
|
6
main.go
6
main.go
|
@ -22,6 +22,8 @@ var nc *nats.Conn
|
|||
var snapshotProcessor apps.SnapshotProcessor
|
||||
var nodeProcessor node.Processor
|
||||
|
||||
var elapsedMetric int // time elapsed while loading stats about apps
|
||||
|
||||
func _init() {
|
||||
var err error
|
||||
|
||||
|
@ -58,6 +60,9 @@ func _init() {
|
|||
nodeProcessor = node.Processor{
|
||||
DB: common.GetDBConnection(),
|
||||
}
|
||||
|
||||
// Reset elapsed stats
|
||||
elapsedMetric = -1
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -89,6 +94,7 @@ func main() {
|
|||
log.Println("LOOP ERROR:", err.Error())
|
||||
}
|
||||
elapsed := time.Since(start)
|
||||
elapsedMetric = int(elapsed)
|
||||
log.Printf("Stats gathering elapsed time: %.2fs\n", elapsed.Seconds())
|
||||
time.Sleep(300 * time.Second)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue