stats

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2016 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package stats implements a means of tracking processing statistics for a BitTorrent tracker.

Index

Constants

View Source
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

func RecordPeerEvent(event int, ipv6 bool)

RecordPeerEvent broadcasts a peer event to the default stats queue.

func RecordTiming

func RecordTiming(event int, duration time.Duration)

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 PeerClassStats struct {
	Current int64  // Current peer count.
	Joined  uint64 // Peers that announced.
	Left    uint64 // Peers that paused or stopped.
	Reaped  uint64 // Peers cleaned up after inactivity.
}

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

func (*Stats) Close

func (s *Stats) Close()

func (*Stats) Flattened

func (s *Stats) Flattened() flatjson.Map

func (*Stats) RecordEvent

func (s *Stats) RecordEvent(event int)

func (*Stats) RecordPeerEvent

func (s *Stats) RecordPeerEvent(event int, ipv6 bool)

func (*Stats) RecordTiming

func (s *Stats) RecordTiming(event int, duration time.Duration)

func (*Stats) Uptime

func (s *Stats) Uptime() time.Duration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL