-
Notifications
You must be signed in to change notification settings - Fork 17
/
stats.go
36 lines (32 loc) · 1.09 KB
/
stats.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package machine
import (
"encoding/json"
"fmt"
"time"
)
// Stats holds information about goroutines
type Stats struct {
ID string `json:"id"`
Tags []string `json:"tags"`
TotalRoutines int `json:"totalRoutines"`
ActiveRoutines int `json:"activeRoutines"`
Routines []RoutineStats `json:"routines"`
TotalChildren int `json:"totalChildren"`
HasParent bool `json:"hasParent"`
TotalMiddlewares int `json:"totalMiddlewares"`
Timeout time.Duration `json:"timeout"`
Deadline time.Time `json:"deadline"`
Children []*Stats `json:"children"`
}
// String prints a pretty json string of the stats
func (s Stats) String() string {
bits, _ := json.MarshalIndent(&s, "", " ")
return fmt.Sprintf("%s", string(bits))
}
// RoutineStats holds information about a single goroutine
type RoutineStats struct {
PID string `json:"pid"`
Start time.Time `json:"start"`
Duration time.Duration `json:"duration"`
Tags []string `json:"tags"`
}