Documentation
¶
Overview ¶
Package stats implements a means of tracking processing statistics for a BitTorrent tracker.
Index ¶
Constants ¶
const ( Announce = iota Scrape Completed NewLeech DeletedLeech ReapedLeech NewSeed DeletedSeed ReapedSeed NewTorrent DeletedTorrent ReapedTorrent AcceptedConnection ClosedConnection HandledRequest ErroredRequest ClientError ResponseTime )
Variables ¶
This section is empty.
Functions ¶
func RecordEvent ¶
func RecordEvent(event int)
RecordEvent broadcasts an event to the default stats queue.
func RecordPeerEvent ¶
RecordPeerEvent broadcasts a peer event to the default stats queue.
func RecordTiming ¶
RecordTiming broadcasts a timing event to the default stats queue.
Types ¶
type BasicMemStats ¶
type BasicMemStats struct {
// General statistics.
Alloc uint64 // bytes allocated and still in use
TotalAlloc uint64 // bytes allocated (even if freed)
Sys uint64 // bytes obtained from system (sum of XxxSys in runtime)
Lookups uint64 // number of pointer lookups
Mallocs uint64 // number of mallocs
Frees uint64 // number of frees
// Main allocation heap statistics.
HeapAlloc uint64 // bytes allocated and still in use
HeapSys uint64 // bytes obtained from system
HeapIdle uint64 // bytes in idle spans
HeapInuse uint64 // bytes in non-idle span
HeapReleased uint64 // bytes released to the OS
HeapObjects uint64 // total number of allocated objects
// Garbage collector statistics.
PauseTotalNs uint64
LatestPauseNs uint64
}
BasicMemStats includes a few of the fields from runtime.MemStats suitable for general logging.
type MemStatsWrapper ¶
type MemStatsWrapper struct {
// contains filtered or unexported fields
}
MemStatsWrapper wraps runtime.MemStats with an optionally less verbose JSON representation. The JSON field names correspond exactly to the runtime field names to avoid reimplementing the entire struct.
func NewMemStatsWrapper ¶
func NewMemStatsWrapper(verbose bool) *MemStatsWrapper
func (*MemStatsWrapper) Update ¶
func (s *MemStatsWrapper) Update()
Update fetches the current memstats from runtime and resets the cache.
type PeerClassStats ¶
type PeerStats ¶
type PeerStats struct {
PeerClassStats `json:"Peers"` // Stats for all peers.
Seeds PeerClassStats // Stats for seeds only.
Completed uint64 // Number of transitions from leech to seed.
}
type PercentileTimes ¶
type PercentileTimes struct {
P50 *faststats.Percentile
P90 *faststats.Percentile
P95 *faststats.Percentile
}
type Stats ¶
type Stats struct {
Started time.Time // Time at which Chihaya was booted.
OpenConnections int64 `json:"connectionsOpen"`
ConnectionsAccepted uint64 `json:"connectionsAccepted"`
BytesTransmitted uint64 `json:"bytesTransmitted"`
GoRoutines int `json:"runtimeGoRoutines"`
RequestsHandled uint64 `json:"requestsHandled"`
RequestsErrored uint64 `json:"requestsErrored"`
ClientErrors uint64 `json:"requestsBad"`
ResponseTime PercentileTimes
Announces uint64 `json:"trackerAnnounces"`
Scrapes uint64 `json:"trackerScrapes"`
TorrentsSize uint64 `json:"torrentsSize"`
TorrentsAdded uint64 `json:"torrentsAdded"`
TorrentsRemoved uint64 `json:"torrentsRemoved"`
TorrentsReaped uint64 `json:"torrentsReaped"`
IPv4Peers PeerStats `json:"peersIPv4"`
IPv6Peers PeerStats `json:"peersIPv6"`
*MemStatsWrapper `json:",omitempty"`
// contains filtered or unexported fields
}
var DefaultStats *Stats
DefaultStats is a default instance of stats tracking that uses an unbuffered channel for broadcasting events unless specified otherwise via a command line flag.
func New ¶
func New(cfg config.StatsConfig) *Stats