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 }
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:"Connections.Open"` ConnectionsAccepted uint64 `json:"Connections.Accepted"` BytesTransmitted uint64 `json:"BytesTransmitted"` GoRoutines int `json:"Runtime.GoRoutines"` RequestsHandled uint64 `json:"Requests.Handled"` RequestsErrored uint64 `json:"Requests.Errored"` ClientErrors uint64 `json:"Requests.Bad"` ResponseTime PercentileTimes Announces uint64 `json:"Tracker.Announces"` Scrapes uint64 `json:"Tracker.Scrapes"` TorrentsSize uint64 `json:"Torrents.Size"` TorrentsAdded uint64 `json:"Torrents.Added"` TorrentsRemoved uint64 `json:"Torrents.Removed"` TorrentsReaped uint64 `json:"Torrents.Reaped"` IPv4Peers PeerStats `json:"Peers.IPv4"` IPv6Peers PeerStats `json:"Peers.IPv6"` *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