metrics

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	M_Instance_Start = NewComboCounterRef("instance.start")

	M_Page_Status_200 = NewComboCounterRef("page.status.200")
	M_Page_Status_500 = NewComboCounterRef("page.status.500")
	M_Page_Status_404 = NewComboCounterRef("page.status.404")

	M_Api_Status_500 = NewComboCounterRef("api.status.500")
	M_Api_Status_404 = NewComboCounterRef("api.status.404")

	M_Api_User_SignUp       = NewComboCounterRef("api.user.signup")
	M_Api_Dashboard_Get     = NewComboCounterRef("api.dashboard.get")
	M_Api_Dashboard_Post    = NewComboCounterRef("api.dashboard.post")
	M_Api_Admin_User_Create = NewComboCounterRef("api.admin.user_create")
	M_Api_Login_Post        = NewComboCounterRef("api.login.post")
	M_Api_Login_OAuth       = NewComboCounterRef("api.login.oauth")
	M_Api_Org_Create        = NewComboCounterRef("api.org.create")

	M_Api_Dashboard_Snapshot_Create   = NewComboCounterRef("api.dashboard_snapshot.create")
	M_Api_Dashboard_Snapshot_External = NewComboCounterRef("api.dashboard_snapshot.external")
	M_Api_Dashboard_Snapshot_Get      = NewComboCounterRef("api.dashboard_snapshot.get")

	M_Models_Dashboard_Insert = NewComboCounterRef("models.dashboard.insert")
)
View Source
var MetricStats = NewRegistry()
View Source
var UsageStats = NewRegistry()

Functions

func StartUsageReportLoop

func StartUsageReportLoop() chan struct{}

Types

type Counter

type Counter interface {
	Clear()
	Count() int64
	Dec(int64)
	Inc(int64)
	Snapshot() Counter
}

Counters hold an int64 value that can be incremented and decremented.

func NewComboCounterRef

func NewComboCounterRef(name string) Counter

func NewCounter

func NewCounter() Counter

NewCounter constructs a new StandardCounter.

type CounterSnapshot

type CounterSnapshot int64

CounterSnapshot is a read-only copy of another Counter.

func (CounterSnapshot) Clear

func (CounterSnapshot) Clear()

Clear panics.

func (CounterSnapshot) Count

func (c CounterSnapshot) Count() int64

Count returns the count at the time the snapshot was taken.

func (CounterSnapshot) Dec

func (CounterSnapshot) Dec(int64)

Dec panics.

func (CounterSnapshot) Inc

func (CounterSnapshot) Inc(int64)

Inc panics.

func (CounterSnapshot) Snapshot

func (c CounterSnapshot) Snapshot() Counter

Snapshot returns the snapshot.

type DuplicateMetric

type DuplicateMetric string

DuplicateMetric is the error returned by Registry.Register when a metric already exists. If you mean to Register that metric you must first Unregister the existing metric.

func (DuplicateMetric) Error

func (err DuplicateMetric) Error() string

type Registry

type Registry interface {
	// Call the given function for each registered metric.
	Each(func(string, interface{}))

	// Get the metric by the given name or nil if none is registered.
	Get(string) interface{}

	// Gets an existing metric or registers the given one.
	// The interface can be the metric to register if not found in registry,
	// or a function returning the metric for lazy instantiation.
	GetOrRegister(string, interface{}) interface{}

	// Register the given metric under the given name.
	Register(string, interface{}) error
}

func NewRegistry

func NewRegistry() Registry

Create a new registry.

type StandardCounter

type StandardCounter struct {
	// contains filtered or unexported fields
}

StandardCounter is the standard implementation of a Counter and uses the sync/atomic package to manage a single int64 value.

func (*StandardCounter) Clear

func (c *StandardCounter) Clear()

Clear sets the counter to zero.

func (*StandardCounter) Count

func (c *StandardCounter) Count() int64

Count returns the current count.

func (*StandardCounter) Dec

func (c *StandardCounter) Dec(i int64)

Dec decrements the counter by the given amount.

func (*StandardCounter) Inc

func (c *StandardCounter) Inc(i int64)

Inc increments the counter by the given amount.

func (*StandardCounter) Snapshot

func (c *StandardCounter) Snapshot() Counter

Snapshot returns a read-only copy of the counter.

type StandardRegistry

type StandardRegistry struct {
	// contains filtered or unexported fields
}

The standard implementation of a Registry is a mutex-protected map of names to metrics.

func (*StandardRegistry) Each

func (r *StandardRegistry) Each(f func(string, interface{}))

Call the given function for each registered metric.

func (*StandardRegistry) Get

func (r *StandardRegistry) Get(name string) interface{}

Get the metric by the given name or nil if none is registered.

func (*StandardRegistry) GetOrRegister

func (r *StandardRegistry) GetOrRegister(name string, i interface{}) interface{}

Gets an existing metric or creates and registers a new one. Threadsafe alternative to calling Get and Register on failure. The interface can be the metric to register if not found in registry, or a function returning the metric for lazy instantiation.

func (*StandardRegistry) Register

func (r *StandardRegistry) Register(name string, i interface{}) error

Register the given metric under the given name. Returns a DuplicateMetric if a metric by the given name is already registered.

Jump to

Keyboard shortcuts

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