Documentation
¶
Index ¶
- func NamedCounter(scope tally.Scope, name string, counter string, value int64, tags ...Tag)
- func NamedGauge(scope tally.Scope, name string, gauge string, value float64, tags ...Tag)
- func NamedHistogram(scope tally.Scope, name string, histogram string, buckets tally.Buckets, ...) tally.Histogram
- func NamedTimer(scope tally.Scope, name string, timer string, d time.Duration, tags ...Tag)
- type Op
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NamedCounter ¶
NamedCounter increments the {name}.{counter} counter by value.
func NamedGauge ¶
NamedGauge updates the {name}.{gauge} gauge to value. Gauges represent a current point-in-time measurement that can go up or down, such as queue depth, active connections, or in-flight requests.
func NamedHistogram ¶
func NamedHistogram(scope tally.Scope, name string, histogram string, buckets tally.Buckets, tags ...Tag) tally.Histogram
NamedHistogram returns a tally.Histogram at {name}.{histogram} with the given bucket configuration. Store the returned histogram and call RecordDuration or RecordValue on each invocation.
Types ¶
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
Op tracks the lifecycle of a named operation. It captures the start time on creation, emits a {name}.called counter, and records the outcome (succeeded/failed counters + latency timer with error classification tags) when Complete is called.
Usage:
func (c *Controller) Process(ctx context.Context, delivery consumer.Delivery) (retErr error) {
op := metrics.Begin(c.scope, "process")
defer func() { op.Complete(retErr) }()
// ... business logic ...
}
func Begin ¶
Begin starts a new operation. It emits a {name}.called counter and captures the start time. Call Complete on the returned Op to record the outcome.
func (Op) Complete ¶
Complete records the outcome of the operation. It emits a {name}.succeeded or {name}.failed counter based on err, and records elapsed time on both {name}.latency (timer) and {name}.latency_histogram (histogram with defaultLatencyBuckets for percentile distributions), tagged with result=success|error. On failure, error classification tags (error_origin, retryable, dependency) are added to both the timer and histogram.
type Tag ¶
type Tag struct {
// Key is the tag name (e.g., "controller", "topic").
Key string
// Value is the tag value (e.g., "land", "request").
Value string
}
Tag is a key-value pair attached to a metric for dimensional filtering.