Skip to content

The Go-Server-Stats package can be used to count statistics for a web service written in Go.

License

Notifications You must be signed in to change notification settings

andrewlader/go-server-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-server-stats

Go Report Card Build Status Coverage Status license

The Go-Server-Stats package can be used to count statistics for a web service written in Go.

┌─┐┌─┐   ┌─┐┌─┐┬─┐┬  ┬┌─┐┬─┐   ┌─┐┌┬┐┌─┐┌┬┐┌─┐
│ ┬│ │───└─┐├┤ ├┬┘└┐┌┘├┤ ├┬┘───└─┐ │ ├─┤ │ └─┐
└─┘└─┘   └─┘└─┘┴└─ └┘ └─┘┴└─   └─┘ ┴ ┴ ┴ ┴ └─┘

Installation

To install the package, use the go command

> go get github.com/andrewlader/go-server-stats

Requirements

Requires Go >= v1.2

Usage

Add stats.Stats to the web service. For example:

// the HTTP handler instance
type httpServer struct {
	stats   *stats.Stats
	mux     map[string]apiHandler
}

Then when an API is called, use the Update() method to increment the counters:

server.stats.Update(wasSuccessful, uint64(request.ContentLength), numberOfBytesWritten)

About

The Go-Server-Stats package can be used to count statistics for a web service written in Go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages