-
Notifications
You must be signed in to change notification settings - Fork 16
/
stats.go
30 lines (26 loc) · 808 Bytes
/
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
package machine
import (
"encoding/json"
"fmt"
"time"
)
// Stats holds information about goroutines
type Stats struct {
TotalRoutines int `json:"totalRoutines"`
ActiveRoutines int `json:"activeRoutines"`
Routines []RoutineStats `json:"routines"`
TotalChildren int `json:"totalChildren"`
HasParent bool `json:"hasParent"`
}
// 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 int `json:"pid"`
Start time.Time `json:"start"`
Duration time.Duration `json:"duration"`
Tags []string `json:"tags"`
}