stats.v1: gopkg.in/go-playground/stats.v1 Index | Files

package stats

import "gopkg.in/go-playground/stats.v1"

Index

Package Files

client.go http.go server.go stats.go

type CPUInfo Uses

type CPUInfo struct {
    CPU            []cpu.CPUInfoStat  `json:"cpu,omitempty"`
    PerCPUTimes    []cpu.CPUTimesStat `json:"percputimes,omitempty"`
    TotalTimes     []cpu.CPUTimesStat `json:"totaltimes,omitempty"`
    PrevCPUTimes   []cpu.CPUTimesStat `json:"prevpercputimes,omitempty"`
    PrevTotalTimes []cpu.CPUTimesStat `json:"prevtotaltimes,omitempty"`
}

CPUInfo contains CPU information

type CPUPercentages Uses

type CPUPercentages struct {
    CPU       string
    User      float64
    System    float64
    Idle      float64
    Nice      float64
    IOWait    float64
    IRQ       float64
    SoftIRQ   float64
    Steal     float64
    Guest     float64
    GuestNice float64
    Stolen    float64
    Total     float64
}

CPUPercentages contains the CPU percentage information

type ClientConfig Uses

type ClientConfig struct {
    Domain           string
    Port             int
    PollInterval     int
    Debug            bool
    LogHostInfo      bool
    LogCPUInfo       bool
    LogTotalCPUTimes bool
    LogPerCPUTimes   bool
    LogMemory        bool
    LogGoMemory      bool
    CustomBufferSize int
}

ClientConfig is used to initialize a new ClientStats object

type ClientStats Uses

type ClientStats struct {
    // contains filtered or unexported fields
}

ClientStats is the object used to collect and send data to the server for processing

func NewClient Uses

func NewClient(clientConfig *ClientConfig, serverConfig *ServerConfig) (*ClientStats, error)

NewClient create a new client object for use

func (*ClientStats) NewHTTPRequest Uses

func (s *ClientStats) NewHTTPRequest(w http.ResponseWriter, r *http.Request) *HTTPRequest

NewHTTPRequest creates a new HTTPRequest for monitoring which wraps the ResponseWriter in order to collect stats so you need to call the Writer() function from the HTTPRequest created by this call

func (*ClientStats) Run Uses

func (c *ClientStats) Run()

Run starts sending the profiling stats to the server NOTE: the server must be running prior to starting

func (*ClientStats) Stop Uses

func (c *ClientStats) Stop()

Stop halts the client from sending any more data to the server, but may be run again at any time.

type GoInfo Uses

type GoInfo struct {
    Version    string   `json:"gover"`
    Memory     GoMemory `json:"gomem"`
    GoRoutines int      `json:"goroutines"`
}

GoInfo contains go specific metrics and stats

type GoMemory Uses

type GoMemory struct {
    NumGC               uint32 `json:"numgc"`
    LastGC              uint64 `json:"lastgc"`
    LastGCPauseDuration uint64 `json:"lastgcpause"`
    Alloc               uint64 `json:"alloc"`
    HeapAlloc           uint64 `json:"heap"`
    HeapSys             uint64 `json:"sys"`
    // contains filtered or unexported fields
}

GoMemory contains go specific memory metrics

type HTTPRequest Uses

type HTTPRequest struct {
    URL                   string      `json:"url"`
    Method                string      `json:"method"`
    RequestContentLength  int64       `json:"reqContent"`
    Headers               http.Header `json:"headers"`
    Start                 time.Time   `json:"start"`
    End                   time.Time   `json:"end"`
    Duration              int64       `json:"duration"`
    ResponseContentLength int64       `json:"resContent"`
    StatusCode            int         `json:"status"`
    HasErrors             bool        `json:"hasErrs"`
    Error                 string      `json:"err"`
    // contains filtered or unexported fields
}

HTTPRequest contains information about the life of an http request

func (*HTTPRequest) Complete Uses

func (r *HTTPRequest) Complete()

Complete finalizes an HTTPRequest and logs it.

func (*HTTPRequest) Failure Uses

func (r *HTTPRequest) Failure(err string)

Failure records an HTTP failure and automatically completes the request

func (*HTTPRequest) Writer Uses

func (r *HTTPRequest) Writer() http.ResponseWriter

Writer returns a wrapped http.ResponseWriter for logging purposes

type LogResponseWritter Uses

type LogResponseWritter struct {
    http.ResponseWriter
    // contains filtered or unexported fields
}

LogResponseWritter wraps the standard http.ResponseWritter allowing for more verbose logging

func (*LogResponseWritter) Header Uses

func (w *LogResponseWritter) Header() http.Header

Header returns & satisfies the http.ResponseWriter interface

func (*LogResponseWritter) Size Uses

func (w *LogResponseWritter) Size() int

Size provides an easy way to retrieve the response size in bytes

func (*LogResponseWritter) Status Uses

func (w *LogResponseWritter) Status() int

Status provides an easy way to retrieve the status code

func (*LogResponseWritter) Write Uses

func (w *LogResponseWritter) Write(data []byte) (int, error)

Write satisfies the http.ResponseWriter interface and captures data written, in bytes

func (*LogResponseWritter) WriteHeader Uses

func (w *LogResponseWritter) WriteHeader(statusCode int)

WriteHeader satisfies the http.ResponseWriter interface and allows us to cach the status code

type MemInfo Uses

type MemInfo struct {
    Memory *mem.VirtualMemoryStat `json:"mem,omitempty"`
    Swap   *mem.SwapMemoryStat    `json:"swap,omitempty"`
}

MemInfo contains memory info including swap information

type ServerConfig Uses

type ServerConfig struct {
    Domain           string
    Port             int
    Debug            bool
    CustomBufferSize int
}

ServerConfig is used to initialize a new ServerStats object

type ServerStats Uses

type ServerStats struct {
    // contains filtered or unexported fields
}

ServerStats is the object used to receive, store and send data for usage

func NewServer Uses

func NewServer(config *ServerConfig) (*ServerStats, error)

NewServer create a new server object for use

func (*ServerStats) Run Uses

func (s *ServerStats) Run() <-chan *Stats

Run starts receiving the profiling stats for storage and usage

type Stats Uses

type Stats struct {
    HostInfo     *host.HostInfoStat `json:"hostInfo,omitempty"`
    CPUInfo      *CPUInfo           `json:"cpu,omitempty"`
    MemInfo      *MemInfo           `json:"memInfo,omitempty"`
    GoInfo       *GoInfo            `json:"goInfo,omitempty"`
    HTTPRequests []*HTTPRequest     `json:"http"`
}

Stats contains all of the statistics to be passed and Encoded/Decoded on the Client and Server sides

func (*Stats) CalculateCPUTimes Uses

func (s *Stats) CalculateCPUTimes() []CPUPercentages

CalculateCPUTimes calculates the total CPU times percentages per core

func (*Stats) CalculateTotalCPUTimes Uses

func (s *Stats) CalculateTotalCPUTimes() []CPUPercentages

CalculateTotalCPUTimes calculates the total CPU times percentages

func (*Stats) GetAllCPUInfo Uses

func (s *Stats) GetAllCPUInfo()

GetAllCPUInfo populates Stats with hosts CPU information and Timings

func (*Stats) GetCPUInfo Uses

func (s *Stats) GetCPUInfo()

GetCPUInfo populates Stats with hosts CPU information

func (*Stats) GetCPUTimes Uses

func (s *Stats) GetCPUTimes()

GetCPUTimes populates Stats with hosts CPU timing information

func (*Stats) GetHostInfo Uses

func (s *Stats) GetHostInfo()

GetHostInfo populates Stats with host system information

func (*Stats) GetMemoryInfo Uses

func (s *Stats) GetMemoryInfo(logMemory, logGoMemory bool)

GetMemoryInfo populates Stats with host and go process memory information

func (*Stats) GetTotalCPUTimes Uses

func (s *Stats) GetTotalCPUTimes()

GetTotalCPUTimes populates Stats with hosts CPU timing information

Package stats imports 11 packages (graph). Updated 2016-09-12. Refresh now. Tools for package owners.