Documentation ¶
Index ¶
- type CPUInfo
- type CPUPercentages
- type ClientConfig
- type ClientStats
- type GoInfo
- type GoMemory
- type HTTPRequest
- type LogResponseWritter
- type MemInfo
- type ServerConfig
- type ServerStats
- type Stats
- func (s *Stats) CalculateCPUTimes() []CPUPercentages
- func (s *Stats) CalculateTotalCPUTimes() []CPUPercentages
- func (s *Stats) GetAllCPUInfo()
- func (s *Stats) GetCPUInfo()
- func (s *Stats) GetCPUTimes()
- func (s *Stats) GetHostInfo()
- func (s *Stats) GetMemoryInfo(logMemory, logGoMemory bool)
- func (s *Stats) GetTotalCPUTimes()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CPUInfo ¶
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 ¶
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 ¶
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 ¶
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 ¶
func NewClient(clientConfig *ClientConfig, serverConfig *ServerConfig) (*ClientStats, error)
NewClient create a new client object for use
func (*ClientStats) NewHTTPRequest ¶
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 ¶
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 ¶
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 ¶
type GoInfo struct { Version string `json:"gover"` Memory GoMemory `json:"gomem"` GoRoutines int `json:"goroutines"` }
GoInfo contains go specific metrics and stats
type GoMemory ¶
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 ¶
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 ¶
func (r *HTTPRequest) Complete()
Complete finalizes an HTTPRequest and logs it.
func (*HTTPRequest) Failure ¶
func (r *HTTPRequest) Failure(err string)
Failure records an HTTP failure and automatically completes the request
func (*HTTPRequest) Writer ¶
func (r *HTTPRequest) Writer() http.ResponseWriter
Writer returns a wrapped http.ResponseWriter for logging purposes
type LogResponseWritter ¶
type LogResponseWritter struct { http.ResponseWriter // contains filtered or unexported fields }
LogResponseWritter wraps the standard http.ResponseWritter allowing for more verbose logging
func (*LogResponseWritter) Header ¶
func (w *LogResponseWritter) Header() http.Header
Header returns & satisfies the http.ResponseWriter interface
func (*LogResponseWritter) Size ¶
func (w *LogResponseWritter) Size() int
Size provides an easy way to retrieve the response size in bytes
func (*LogResponseWritter) Status ¶
func (w *LogResponseWritter) Status() int
Status provides an easy way to retrieve the status code
func (*LogResponseWritter) Write ¶
func (w *LogResponseWritter) Write(data []byte) (int, error)
Write satisfies the http.ResponseWriter interface and captures data written, in bytes
func (*LogResponseWritter) WriteHeader ¶
func (w *LogResponseWritter) WriteHeader(statusCode int)
WriteHeader satisfies the http.ResponseWriter interface and allows us to cach the status code
type MemInfo ¶
type MemInfo struct { Memory *mem.VirtualMemoryStat `json:"mem,omitempty"` Swap *mem.SwapMemoryStat `json:"swap,omitempty"` }
MemInfo contains memory info including swap information
type ServerConfig ¶
ServerConfig is used to initialize a new ServerStats object
type ServerStats ¶
type ServerStats struct {
// contains filtered or unexported fields
}
ServerStats is the object used to receive, store and send data for usage
func NewServer ¶
func NewServer(config *ServerConfig) (*ServerStats, error)
NewServer create a new server object for use
func (*ServerStats) Run ¶
func (s *ServerStats) Run() <-chan *Stats
Run starts receiving the profiling stats for storage and usage
type Stats ¶
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 ¶
func (s *Stats) CalculateCPUTimes() []CPUPercentages
CalculateCPUTimes calculates the total CPU times percentages per core
func (*Stats) CalculateTotalCPUTimes ¶
func (s *Stats) CalculateTotalCPUTimes() []CPUPercentages
CalculateTotalCPUTimes calculates the total CPU times percentages
func (*Stats) GetAllCPUInfo ¶
func (s *Stats) GetAllCPUInfo()
GetAllCPUInfo populates Stats with hosts CPU information and Timings
func (*Stats) GetCPUInfo ¶
func (s *Stats) GetCPUInfo()
GetCPUInfo populates Stats with hosts CPU information
func (*Stats) GetCPUTimes ¶
func (s *Stats) GetCPUTimes()
GetCPUTimes populates Stats with hosts CPU timing information
func (*Stats) GetHostInfo ¶
func (s *Stats) GetHostInfo()
GetHostInfo populates Stats with host system information
func (*Stats) GetMemoryInfo ¶
GetMemoryInfo populates Stats with host and go process memory information
func (*Stats) GetTotalCPUTimes ¶
func (s *Stats) GetTotalCPUTimes()
GetTotalCPUTimes populates Stats with hosts CPU timing information