stats

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2016 License: MIT Imports: 4 Imported by: 0

README

Stats

Build Status GoDoc

Stats is a statistics collection library for your Go applications. It collects data on a regular, configurable interval and sends it to a configurable collections client.

Supported statistics

  • Memory usage
  • Goroutines
  • Garbage Collection
  • CGO Calls

Supported collector clients

  • statsd

Example

package main

import (
    "github.com/jelmersnoeck/stats"
    "github.com/jelmersnoeck/stats/clients/statsd"
)

func main() {
    cl, err := statsd.New()
    if err != nil {
        // error connecting to statsd
    }

    s := stats.New(stats.Client(cl))
    go s.Collect()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectCgo

func CollectCgo(c bool) collectionOption

CollectCgo is the option to enable or disable collection of the number of Cgo calls made by the application. This is enabled by default.

func CollectGC

func CollectGC(c bool) collectionOption

CollectGC is the option to enable or disable collection of Garbage Collection information. This includes number of GC runs and the GC run times. This is enabled by default.

func CollectGoroutines

func CollectGoroutines(c bool) collectionOption

CollectGoroutines is the option to enable or disable goroutine collection. This is enabled by default.

func CollectMemory

func CollectMemory(c bool) collectionOption

CollectMemory is the option to enable or disable memory collection. This is enabled by default.

func CollectionClient

func CollectionClient(c Client) collectionOption

CollectionClient represents the collection client we'll be using to send our collected data to. This can be an HTTP Client, a Statsd client, etc. as long as it conforms to the Client interface. The default client is the nil client, this client disregards any input that is passed through.

func CollectionInterval

func CollectionInterval(d time.Duration) collectionOption

CollectionInterval sets the duration between collection runs. The default is 60 seconds.

func New

func New(opts ...collectionOption) *collector

New creates a new client that is set up to collect application statistics.

Types

type AppStat

type AppStat struct {
	Memory     uint64
	Goroutines int
	NumGC      int64
	GCPauses   []time.Duration
	NumCgo     int64
}

type Client

type Client interface {
	Collect(AppStat)
}

Client is used to send data to a storage.

type NilClient

type NilClient struct{}

NilClient is a collector that gets data and disregards it immediately. It is the default collector. This collector should not be used for production as it will not collect any data.

func (*NilClient) Collect

func (c *NilClient) Collect(AppStat)

Directories

Path Synopsis
clients

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL