stats

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package stats provides functions for reporting metrics to a service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(ctx context.Context, key string, n interface{}, meta ...map[string]string)

Count calls `Count` on the context `Stats`

func Dec

func Dec(ctx context.Context, key string, meta ...map[string]string)

Dec calls `Dec` on the context `Stats`

func Gauge

func Gauge(ctx context.Context, key string, n interface{}, meta ...map[string]string)

Gauge calls `Gauge` on the context `Stats`

func Histogram

func Histogram(ctx context.Context, key string, n interface{}, tags ...map[string]string)

Histogram calls `Histogram` on the context `Stats`

func Inc

func Inc(ctx context.Context, key string, meta ...map[string]string)

Inc calls `Inc` on the context `Stats`

func Timing

func Timing(ctx context.Context, key string, t time.Duration, meta ...map[string]string)

Timing calls `Timing` on the context `Stats`

func WithContext

func WithContext(ctx context.Context, s Stats) context.Context

WithContext returns a copy of parent in which `Stats` is stored

Types

type Stats

type Stats interface {
	Start()
	Stop()

	// Count is a simple counter
	Count(key string, n interface{}, meta ...map[string]string)
	// Inc increments the given counter by 1
	Inc(key string, meta ...map[string]string)
	// Dec decrements the given counter by 1
	Dec(key string, meta ...map[string]string)
	// Gauge measures the amount, level, or contents of something
	// The given value replaces the current one
	// e.g. in-flight requests, uptime, ...
	Gauge(key string, n interface{}, meta ...map[string]string)
	// Timing measures how long it takes to accomplish something
	// e.g. algorithm, request, ...
	Timing(key string, t time.Duration, meta ...map[string]string)
	// Histogram measures the distribution of values over the time
	Histogram(key string, n interface{}, tags ...map[string]string)

	// With returns a child Stats, and add meta to that Stats
	With(meta map[string]string) Stats
}

Stats is an interface for app statistics

func FromContext

func FromContext(ctx context.Context) Stats

FromContext returns a `Stats` instance associated with `ctx`, or `NopStats` if no `Stats` instance could be found.

func NopStats

func NopStats() Stats

NopStats returns a stats adapter that does not do anything

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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