Documentation
Overview ¶
Package metrics defines a set of primitives for declaring and managing metrics within Bigslice. Users declare metrics (such as a counter) using the registration mechanisms provided by this package (e.g., NewCounter). These return handles that are used for metric operations (e.g., incrementing a counter).
Every operation on a metric is performed in a Scope. Scopes are provided by the Bigslice runtime and represent an operational scope in which the metric is aggregated. For example, Bigslice defines a Scope that is attached to each task scheduled by the system. Scopes are merged by the Bigslice runtime to provide aggregated metrics across larger operations (e.g., a single session.Run).
User functions called by Bigslice are supplied a scope through the optional context.Context argument. The user must retrieve this Scope using the ContextScope func.
Metrics cannot be declared concurrently.
Index ¶
Examples ¶
Constants ¶
Variables ¶
Functions ¶
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a simple counter metric. Counters implement atomic addition and subtraction on top of an int64.
func NewCounter ¶
func NewCounter() Counter
NewCounter creates, registers, and returns a new Counter metric.
type Metric ¶
type Metric interface {
// contains filtered or unexported methods
}
Metric is the abstract type of a metric. Each metric type must implement a set of generic operations; the metric-specific operations are provided by the metric types themselves.
TODO(marius): eventually consider opening up this interface to allow users to provide their own metrics implementations.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope is a collection of metric instances.
func ContextScope ¶
ContextScope returns the scope attached to the provided context. ContextScope panics if the context does not have an attached scope.