Documentation ¶
Overview ¶
Package stats provides functions for reporting metrics to a service.
Index ¶
- func Count(ctx context.Context, key string, n interface{}, meta ...map[string]string)
- func Dec(ctx context.Context, key string, meta ...map[string]string)
- func Gauge(ctx context.Context, key string, n interface{}, meta ...map[string]string)
- func Histogram(ctx context.Context, key string, n interface{}, tags ...map[string]string)
- func Inc(ctx context.Context, key string, meta ...map[string]string)
- func Timing(ctx context.Context, key string, t time.Duration, meta ...map[string]string)
- func WithContext(ctx context.Context, s Stats) context.Context
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 // Log attaches a logger to a Stats instance Log(l log.Logger) Stats }
Stats is an interface for app statistics
func FromContext ¶
func FromContext(ctx contextutil.ValueContext) Stats
FromContext returns a `Stats` instance associated with `ctx`, or `NopStats` if no `Stats` instance could be found.
Click to show internal directories.
Click to hide internal directories.