Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRegister ¶ added in v0.5.0
func MustRegister(metrics ...Metric)
MustRegister is a helper function that will ensure that the provided Metrics are registered. If a metric fails to register, this method will panic.
func RegisterRecordHook ¶ added in v0.5.0
func RegisterRecordHook(name string, h RecordHook)
RegisterRecordHook adds a RecordHook for a given measure.
Types ¶
type DerivedMetric ¶ added in v0.5.0
type DerivedMetric interface { // Name returns the name value of a DerivedMetric. Name() string // Register handles any required setup to ensure metric export. Register() error }
DerivedMetrics can be used to supply values that dynamically derive from internal state, but are not updated based on any specific event. Their value will be calculated based on a value func that executes when the metrics are exported.
At the moment, only a Gauge type is supported.
func NewDerivedGauge ¶ added in v0.5.0
func NewDerivedGauge(name, description string, valueFn func() float64) DerivedMetric
NewDerivedGauge creates a new Metric with an aggregation type of LastValue that generates the value dynamically according to the provided function. This can be used for values based on querying some state within a system (when event-driven recording is not appropriate). NOTE: Labels not currently supported.
type Label ¶ added in v0.5.0
A Label provides a named dimension for a Metric.
func MustCreateLabel ¶ added in v0.5.0
MustCreateLabel will attempt to create a new Label. If creation fails, then this method will panic.
func (Label) Value ¶ added in v0.5.0
func (l Label) Value(value string) LabelValue
Value creates a new LabelValue for the Label.
type LabelValue ¶ added in v0.5.0
A LabelValue represents a Label with a specific value. It is used to record values for a Metric.
type Metric ¶ added in v0.5.0
type Metric interface { // Increment records a value of 1 for the current measure. For Sums, // this is equivalent to adding 1 to the current value. For Gauges, // this is equivalent to setting the value to 1. For Distributions, // this is equivalent to making an observation of value 1. Increment() // Decrement records a value of -1 for the current measure. For Sums, // this is equivalent to subtracting -1 to the current value. For Gauges, // this is equivalent to setting the value to -1. For Distributions, // this is equivalent to making an observation of value -1. Decrement() // Name returns the name value of a Metric. Name() string // Record makes an observation of the provided value for the given measure. Record(value float64) // RecordInt makes an observation of the provided value for the measure. RecordInt(value int64) // With creates a new Metric, with the LabelValues provided. This allows creating // a set of pre-dimensioned data for recording purposes. This is primarily used // for documentation and convenience. Metrics created with this method do not need // to be registered (they share the registration of their parent Metric). With(labelValues ...LabelValue) Metric // Register configures the Metric for export. It MUST be called before collection // of values for the Metric. An error will be returned if registration fails. Register() error }
A Metric collects numerical observations.
func NewDistribution ¶ added in v0.5.0
NewDistribution creates a new Metric with an aggregation type of Distribution. This means that the data collected by the Metric will be collected and exported as a histogram, with the specified bounds.
type Options ¶ added in v0.5.0
type Options func(*options)
Options encode changes to the options passed to a Metric at creation time.
func WithInt64Values ¶ added in v0.5.0
func WithInt64Values() Options
WithInt64Values provides configuration options for a new Metric, indicating that recorded values will be saved as int64 values. Any float64 values recorded will converted to int64s via math.Floor-based conversion.
func WithLabels ¶ added in v0.5.0
WithLabels provides configuration options for a new Metric, providing the expected dimensions for data collection for that Metric.
type RecordHook ¶ added in v0.5.0
type RecordHook interface { OnRecordFloat64Measure(f *stats.Float64Measure, tags []tag.Mutator, value float64) OnRecordInt64Measure(i *stats.Int64Measure, tags []tag.Mutator, value int64) }
RecordHook has a callback function which a measure is recorded.