Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IServerStats ¶
type IServerStats interface { GetAverageResponseTimeGraph(precision ResponseTimePrecision) ResponseTimeGraphCollection Handler(ctx echo.Context) error Middleware(next echo.HandlerFunc) echo.HandlerFunc }
IServerStats defines an interface for capturing and retrieving server statistics
type ResponseTime ¶
ResponseTime is used to track how much time a request took to execute, and what time (of day) it happened
type ResponseTimeGraph ¶
type ResponseTimeGraph struct { AverageResponseTimeInNanoseconds int64 `json:"averageResponseTimeInNanoseconds"` AverageResponseTimeInMicroseconds int64 `json:"averageResponseTimeInMicroseconds"` AverageExecutionTimeMilliseconds int64 `json:"averageExecutionTimeMilliseconds"` Time string `json:"time"` }
ResponseTimeGraph reports average response times for a given date/time
type ResponseTimeGraphCollection ¶
type ResponseTimeGraphCollection []*ResponseTimeGraph
ResponseTimeGraphCollection is a collection of ResponseTimeGraph structs
type ResponseTimePrecision ¶
type ResponseTimePrecision int
ResponseTimePrecision describes how granular to report response times
const ( // PrecisionHour reports responses times averaged by hour PrecisionHour ResponseTimePrecision = 1 // PrecisionDay reports respose times averaged by day PrecisionDay ResponseTimePrecision = 2 // PrecisionMonth reports response times averaged by month PrecisionMonth ResponseTimePrecision = 3 )
type ServerStats ¶
type ServerStats struct { AverageFreeSystemMemory *ring.Ring AverageMemoryUsage *ring.Ring CustomStats map[string]interface{} `json:"customStats"` Uptime time.Time `json:"uptime"` RequestCount uint64 `json:"requestCount"` ResponseTimes *ring.Ring Statuses map[string]int `json:"statuses"` sync.RWMutex // contains filtered or unexported fields }
ServerStats tracks general server statistics. This includes information about uptime, response times and counts, and requests counts broken down by HTTP status code. ServerStats is thread-safe due to a write lock on requests, and a read lock on reads
func NewServerStats ¶
func NewServerStats(customMiddleware func(ctx echo.Context, serverStats *ServerStats)) *ServerStats
NewServerStats creates a new ServerStats object
func (*ServerStats) GetAverageResponseTimeGraph ¶
func (s *ServerStats) GetAverageResponseTimeGraph(precision ResponseTimePrecision) ResponseTimeGraphCollection
GetAverageResponseTimeGraph returns an array of response time objects. The precision specifies at what interval you wish to get data for. For example, passing Hour gets you response times averaged by hour. Passing Day gets you response times averaged by day
func (*ServerStats) Handler ¶
func (s *ServerStats) Handler(ctx echo.Context) error
Handler is an endpoint handler you can plug into your application to return stat data
func (*ServerStats) Middleware ¶
func (s *ServerStats) Middleware(next echo.HandlerFunc) echo.HandlerFunc
Middleware is used to capture request and response stats. This is designed to be used with the Echo framework