Documentation ¶
Overview ¶
Package metrics implements a Prometheus metrics submission interface for BMDB client components. A Metrics object can be attached to a BMDB object, which will make all BMDB sessions/transactions/work statistics be submitted to that Metrics object.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetricsSet ¶
type MetricsSet struct {
// contains filtered or unexported fields
}
MetricsSet contains all the Prometheus metrics objects related to a BMDB client.
The MetricsSet object is goroutine-safe.
An empty MetricsSet object is not valid, and should be instead constructed using New.
A nil MetricsSet object is valid and represents a no-op metrics recorder that's never collected.
func New ¶
func New(registry *prometheus.Registry) *MetricsSet
New creates a new BMDB MetricsSet object which can be then attached to a BMDB object by calling BMDB.EnableMetrics on the MetricsSet object.
The given registry must be a valid Prometheus registry, and all metrics contained in this MetricsSet object will be registered into it.
The MetricsSet object can be shared between multiple BMDB object.
The MetricsSet object is goroutine-safe.
func (*MetricsSet) Recorder ¶
func (m *MetricsSet) Recorder(p Processor) *ProcessorRecorder
Recorder builds a ProcessorRecorder for the given Metrics and a given Processor.
type ProcessRecorder ¶
type ProcessRecorder struct { *ProcessorRecorder // contains filtered or unexported fields }
ProcessRecorder wraps a ProcessorRecorder with an additional model.Process. The resulting object can then record work-specific events.
The PusherWithProcess object is goroutine-safe.
func (*ProcessRecorder) OnWorkFinished ¶
func (r *ProcessRecorder) OnWorkFinished(result WorkResult)
OnWorkFinished should be called any time a BMDB client finishes, cancels or fails a Work item.
func (*ProcessRecorder) OnWorkStarted ¶
func (r *ProcessRecorder) OnWorkStarted()
OnWorkStarted should be called any time a BMDB client starts a new Work item.
type Processor ¶
type Processor string
Processor describes some cloud component and possibly sub-component which acts upon the BMDB. When starting a BMDB session, this Processor can be provided to contextualize the metrics emitted by this session. Because the selected Processor ends up directly as a Prometheus metric label, it must be low-cardinality - thus all possible values are defined as an enum here. If a Session is not configured with a Processor, the default (ProcessorUnknown) will be used.
const ( ProcessorUnknown Processor = "" ProcessorShepherdInitializer Processor = "shepherd-initializer" ProcessorShepherdProvisioner Processor = "shepherd-provisioner" ProcessorShepherdRecoverer Processor = "shepherd-recoverer" ProcessorShepherdUpdater Processor = "shepherd-updater" ProcessorBMSRV Processor = "bmsrv" ProcessorScruffyStats Processor = "scruffy-stats" )
type ProcessorRecorder ¶
type ProcessorRecorder struct {
// contains filtered or unexported fields
}
ProcessorRecorder wraps a MetricsSet object with the context of some Processor. It exposes methods that record specific events into the managed Metrics.
The ProcessorRecorder object is goroutine safe.
An empty ProcessorRecorder object is not valid, and should be instead constructed using Metrics.Recorder.
A nil ProcessorRecorder object is valid and represents a no-op metrics recorder.
func (*ProcessorRecorder) OnSessionStarted ¶
func (r *ProcessorRecorder) OnSessionStarted()
OnSessionStarted should be called any time a BMDB client opens a new BMDB Session.
func (*ProcessorRecorder) OnTransactionFailed ¶
func (r *ProcessorRecorder) OnTransactionFailed()
OnTransactionFailed should be called any time a BMDB client fails a BMDB Transaction permanently.
func (*ProcessorRecorder) OnTransactionStarted ¶
func (r *ProcessorRecorder) OnTransactionStarted(attempt int64)
OnTransactionStarted should be called any time a BMDB client starts or re-starts a BMDB Transaction. The attempt should either be '1' (for the first attempt) or a number larger than 1 for any subsequent attempt (i.e. retry) of a transaction.
func (*ProcessorRecorder) WithProcess ¶
func (r *ProcessorRecorder) WithProcess(process model.Process) *ProcessRecorder
WithProcess wraps a given Pusher with a Process.
The resulting PusherWithProcess object is goroutine-safe.
type WorkResult ¶
type WorkResult string
const ( WorkResultFinished WorkResult = "finished" WorkResultCanceled WorkResult = "canceled" WorkResultFailed WorkResult = "failed" )