rprom

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2023 License: MIT Imports: 7 Imported by: 0

README

Prometheus plugin

Provides Prometheus metrics for Regatta Go client.

Metrics

  • <namespace>[_subsystem]_connects_total - Total number of connections opened
  • <namespace>[_subsystem]_disconnects_total - Total number of connections closed
  • <namespace>[_subsystem]_connect_active - Number of active connections
  • <namespace>[_subsystem]_write_bytes_total - Total number of bytes written
  • <namespace>[_subsystem]_read_bytes_total - Total number of bytes read
  • <namespace>[_subsystem]_request_duration_seconds{table,op} - Time histogram spent executing KV operation per table and operation
  • <namespace>[_subsystem]_request_errors_total{table,op} - Total number of errors while executing KV operation per table and operation

Documentation

Index

Constants

View Source
const DefNamespace = "regatta"

DefNamespace is the default namespace for the metrics

Variables

View Source
var DefBuckets = []float64{0.001, 0.002, 0.004, 0.008, 0.016, 0.032, 0.064, 0.128, 0.256, 0.512, 1.024, 2.048}

DefBuckets are the default Histogram buckets. The default buckets are tailored to broadly measure the kafka timings (in seconds).

Functions

This section is empty.

Types

type Histogram

type Histogram uint8

A Histogram is an identifier for a rprom histogram that can be enabled

const (
	ReadTime  Histogram = iota // Enables {ns}_{ss}_read_time_seconds.
	WriteTime                  // Enables {ns}_{ss}_write_time_seconds.
)

type HistogramOpts

type HistogramOpts struct {
	Enable  Histogram
	Buckets []float64
}

HistogramOpts allows histograms to be enabled with custom buckets

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(opts ...Opt) *Metrics

NewMetrics returns a new Metrics that adds prometheus metrics to the registry under the given namespace.

func (*Metrics) OnClientClose

func (m *Metrics) OnClientClose(_ *client.Client)

func (*Metrics) OnHandleConn

func (m *Metrics) OnHandleConn(_ context.Context, cs stats.ConnStats)

func (*Metrics) OnHandleRPC

func (m *Metrics) OnHandleRPC(_ context.Context, rs stats.RPCStats)

func (*Metrics) OnKVCall added in v0.1.2

func (m *Metrics) OnKVCall(ctx context.Context, table string, op client.Op, fn client.KvDo) (resp client.OpResponse, err error)

func (*Metrics) OnNewClient

func (m *Metrics) OnNewClient(_ *client.Client)

type Opt

type Opt interface {
	// contains filtered or unexported methods
}

Opt is an option to configure Metrics.

func Buckets

func Buckets(buckets []float64) Opt

Buckets sets the buckets to be used with Histograms, overriding the default of rprom.DefBuckets. If custom buckets per histogram is needed, HistogramOpts can be used.

func Gatherer

func Gatherer(gatherer prometheus.Gatherer) Opt

Gatherer sets the gatherer to add gather to, rather than a new registry.

func Histograms

func Histograms(hs ...Histogram) Opt

Histograms sets the histograms to be enabled for rprom, overiding the default of disabling all histograms.

metrics, _ := rprom.NewMetrics(
	rprom.Histograms(
		rprom.RequestDurationE2E,
	),
)

func HistogramsFromOpts

func HistogramsFromOpts(hs ...HistogramOpts) Opt

HistogramsFromOpts allows the user full control of what histograms to enable and define buckets to be used with each histogram.

metrics, _ := rprom.NewMetrics(
 rprom.HistogramsFromOpts(
 	rprom.HistogramOpts{
 		Enable:  rprom.ReadWait,
 		Buckets: prometheus.LinearBuckets(10, 10, 8),
 	},
 	rprom.HistogramOpts{
 		Enable: rprom.ReadeTime,
 		// rprom default bucket will be used
 	},
 ),
)

func Namespace added in v0.1.2

func Namespace(namespace string) Opt

Namespace sets the Prometheus namespace for exposed metrics, overriding the default "regatta" namespace

func Registerer

func Registerer(reg prometheus.Registerer) Opt

Registerer sets the registerer to add register to, rather than a new registry.

func Registry

func Registry(rg RegistererGatherer) Opt

Registry sets the registerer and gatherer to add metrics to, rather than a new registry. Use this option if you want to configure both Gatherer and Registerer with the same object.

func Subsystem

func Subsystem(ss string) Opt

Subsystem sets the subsystem for the rprom metrics, overriding the default empty string.

func WithClientLabel

func WithClientLabel() Opt

WithClientLabel adds a "cliend_id" label to all metrics.

type RegistererGatherer

type RegistererGatherer interface {
	prometheus.Registerer
	prometheus.Gatherer
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL