2019-12-04 13:53:20 +02:00
|
|
|
// Package stats provides runtime stats
|
|
|
|
package stats
|
|
|
|
|
2022-09-30 16:27:07 +02:00
|
|
|
// Stats provides stats interface.
|
2019-12-04 13:53:20 +02:00
|
|
|
type Stats interface {
|
2019-12-05 01:51:07 +02:00
|
|
|
// Read stat snapshot
|
|
|
|
Read() ([]*Stat, error)
|
2019-12-04 13:53:20 +02:00
|
|
|
// Write a stat snapshot
|
|
|
|
Write(*Stat) error
|
2019-12-18 20:36:42 +02:00
|
|
|
// Record a request
|
|
|
|
Record(error) error
|
2019-12-04 13:53:20 +02:00
|
|
|
}
|
|
|
|
|
2022-09-30 16:27:07 +02:00
|
|
|
// A runtime stat.
|
2019-12-04 13:53:20 +02:00
|
|
|
type Stat struct {
|
2019-12-05 01:51:07 +02:00
|
|
|
// Timestamp of recording
|
|
|
|
Timestamp int64
|
2019-12-04 13:53:20 +02:00
|
|
|
// Start time as unix timestamp
|
|
|
|
Started int64
|
2019-12-05 01:51:07 +02:00
|
|
|
// Uptime in seconds
|
2019-12-04 13:53:20 +02:00
|
|
|
Uptime int64
|
|
|
|
// Memory usage in bytes
|
|
|
|
Memory uint64
|
|
|
|
// Threads aka go routines
|
|
|
|
Threads uint64
|
|
|
|
// Garbage collection in nanoseconds
|
|
|
|
GC uint64
|
2019-12-18 20:36:42 +02:00
|
|
|
// Total requests
|
|
|
|
Requests uint64
|
|
|
|
// Total errors
|
|
|
|
Errors uint64
|
2019-12-04 13:53:20 +02:00
|
|
|
}
|
2019-12-18 20:36:42 +02:00
|
|
|
|
|
|
|
var (
|
|
|
|
DefaultStats = NewStats()
|
|
|
|
)
|