Skip to content

Latest commit

 

History

History
38 lines (31 loc) · 1.58 KB

README.md

File metadata and controls

38 lines (31 loc) · 1.58 KB

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)