finish
v1.47.0
Documentation
pkg.go.dev ↗Package finish coordinates the lifecycle of finish-aware metric series.
Types
Collection
type Collection struct {
// contains filtered or unexported fields
}
Collection describes an exclusive collection phase for a metric-series lifetime. A Collection returned with true by a Lifecycle collection method must be completed exactly once after the aggregate and exemplars are read.
Collection.Complete
func (c Collection) Complete()
Complete ends the exclusive collection phase. It must be called exactly once.
Collection.ShouldRetire
func (c Collection) ShouldRetire() bool
ShouldRetire reports whether Complete will retire the series lifetime.
Collection.Time
func (c Collection) Time() time.Time
Time returns the timestamp to use for the collected point.
Lifecycle
type Lifecycle struct {
// contains filtered or unexported fields
}
Lifecycle coordinates measurements, explicit finishes, collections, and retirement for one metric series. Its zero value is ready for use.
Lifecycle methods are safe to call concurrently. A successful measurement acquisition and an emitted collection must each be completed exactly once. A Lifecycle must not be copied after first use.
The valid transitions are active to finish-pending on Finish, active or finish-pending to shared on a shared measurement, finish-pending to active on an ordinary measurement, any non-retired state to collecting on collection, and collecting to its prior state or retired when collection completes. Shared lifetimes ignore Finish. Retired is terminal.
Lifecycle.AcquireMeasurement
func (l *Lifecycle) AcquireMeasurement() (Measurement, bool)
AcquireMeasurement reserves this series lifetime for a measurement. It waits for an in-progress collection and returns false only if the lifetime is retired. A successful acquisition must be paired with exactly one call to Measurement.Release after the aggregate and exemplars are updated.
Lifecycle.AcquireSharedMeasurement
func (l *Lifecycle) AcquireSharedMeasurement() (Measurement, bool)
AcquireSharedMeasurement reserves this series lifetime for a measurement and atomically makes the lifetime shared. A shared lifetime cannot be finished. It waits for an in-progress collection and returns false only if the lifetime is retired. A successful acquisition must be paired with exactly one call to Measurement.Release after the aggregate and exemplars are updated.
Lifecycle.BeginCumulativeCollection
func (l *Lifecycle) BeginCumulativeCollection(at time.Time) (Collection, bool)
BeginCumulativeCollection closes measurement admission and waits for admitted measurements to complete. An active or shared lifetime returns to its prior state when the returned Collection is completed; a finish-pending lifetime is retired. It returns false without a Collection if the lifetime is retired. A returned Collection must be completed exactly once.
Lifecycle.BeginDeltaCollection
func (l *Lifecycle) BeginDeltaCollection(at time.Time) (Collection, bool)
BeginDeltaCollection closes measurement admission and waits for admitted measurements to complete. Every emitted lifetime is retired when the returned Collection is completed. It returns false without a Collection if the lifetime is retired. A returned Collection must be completed exactly once.
Lifecycle.Finish
func (l *Lifecycle) Finish(at time.Time) bool
Finish marks an active series lifetime to be retired by its next collection at the supplied time. It returns false if the lifetime is already pending, shared, collecting, or retired. A measurement admitted after Finish reactivates the lifetime.
Lifecycle.Retire
func (l *Lifecycle) Retire()
Retire permanently closes the series lifetime. It waits for admitted measurements to complete and has no effect if the lifetime is already retired.
Measurement
type Measurement struct {
// contains filtered or unexported fields
}
Measurement represents admission to update one metric-series lifetime. A successful call to Lifecycle.AcquireMeasurement returns a Measurement, which must be released exactly once after the aggregate and exemplars are updated.
Measurement.Release
func (m Measurement) Release()
Release completes the admitted measurement.