package
6.8.0
Repository: https://github.com/app-nerds/kit.git
Documentation: pkg.go.dev

# README

Server Stats

Server Stats provides a structure and Echo handler for tracking server statistics, such as when the server started, number of requests, and the count of various status codes. Here is an example of using this in an Echo application.

httpServer = echo.New()

/*
 * Server stats middleware
 */
serverStats := serverstats.NewServerStats(nil)
httpServer.Use(serverStats.Middleware)

httpServer.GET("/serverstats", serverStats.Handler)

The ServerStats object satifies the IServerStats interface, allowing developers to implement their own statistics. It also provides the ability to provide a callback method to add custom stats per application. This is done by passing a method to the NewServerStats constructor method. Inside this method you can work with a map called CustomStats. This is a map of string keys with interfaces for values.

httpServer = echo.New()

/*
 * Server stats middleware
 */
serverStats := serverstats.NewServerStats(func(ctx echo.Context, serverStats *ServerStats) {
	var ok bool
	var value int

	if _, ok = serverStats.CustomStats["someCounter"]; !ok {
		serverStats.CustomStats["someCounter"] = 0;
	}

	value = serverStats.CustomStats["someCounter"].(int)
	value++

	serverStats.CustomStats["someCounter"] = value
})
httpServer.Use(serverStats.Middleware)

httpServer.GET("/serverstats", serverStats.Handler)

# Functions

NewServerStats creates a new ServerStats object */.
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

PrecisionDay reports respose times averaged by day.
PrecisionHour reports responses times averaged by hour.
PrecisionMonth reports response times averaged by month.

# Structs

ResponseTime is used to track how much time a request took to execute, and what time (of day) it happened */.
ResponseTimeGraph reports average response times for a given date/time */.
ServerStats tracks general server statistics.
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

IServerStats defines an interface for capturing and retrieving server statistics */.

# Type aliases

ResponseTimeGraphCollection is a collection of ResponseTimeGraph structs.
ResponseTimePrecision describes how granular to report response times.
No description provided by the author
No description provided by the author