kgmetrics

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

README

kgmetrics

kgmetrics is a plug-in package to provide rcrowley/go-metrics metrics through a kgo.Hook.

This package tracks the following metrics under the following names, all metrics are meters:

    broker.<id>.connects
    broker.<id>.connect_errors
    broker.<id>.disconnects
    broker.<id>.write_errors
    broker.<id>.write_bytes
    broker.<id>.read_errors
    broker.<id>.read_bytes
    broker.<id>.topic.<topic>.produce_bytes
    broker.<id>.topic.<topic>.fetch_bytes

Note that seed brokers use broker IDs starting at math.MinInt32.

To use,

m := kgmetrics.NewMetrics()
cl, err := kgo.NewClient(
	kgo.WithHooks(m),
	// ...other opts
)

You can use your own metrics registry, as well as specify a prefix on metrics. See the package documentation for more info!

Documentation

Overview

Package kgmetrics provides rcrowley/go-metrics drop-in metrics for a kgo client.

This package tracks the following metrics under the following names, all metrics are meters:

broker.<id>.connects
broker.<id>.connect_errors
broker.<id>.disconnects
broker.<id>.write_errors
broker.<id>.write_bytes
broker.<id>.read_errors
broker.<id>.read_bytes
broker.<id>.topic.<topic>.produce_bytes
broker.<id>.topic.<topic>.fetch_bytes

The metrics can be prefixed with the NamePrefix option.

This can be used in a client like so:

m := kgmetrics.NewMetrics()
cl, err := kgo.NewClient(
        kgo.WithHooks(m),
        // ...other opts
)

By default, metrics are installed under the DefaultRegistry, but this can be overridden with the Registry option.

Note that seed brokers use broker IDs starting at math.MinInt32.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

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

Metrics provides rcrowley/go-metrics.

func NewMetrics

func NewMetrics(opts ...Opt) *Metrics

NewMetrics returns a new Metrics.

func (*Metrics) OnBrokerConnect

func (m *Metrics) OnBrokerConnect(meta kgo.BrokerMetadata, _ time.Duration, _ net.Conn, err error)

func (*Metrics) OnBrokerDisconnect

func (m *Metrics) OnBrokerDisconnect(meta kgo.BrokerMetadata, _ net.Conn)

func (*Metrics) OnBrokerRead

func (m *Metrics) OnBrokerRead(meta kgo.BrokerMetadata, _ int16, bytesRead int, _, _ time.Duration, err error)

func (*Metrics) OnBrokerWrite

func (m *Metrics) OnBrokerWrite(meta kgo.BrokerMetadata, _ int16, bytesWritten int, _, _ time.Duration, err error)

func (*Metrics) OnFetchBatchRead

func (m *Metrics) OnFetchBatchRead(meta kgo.BrokerMetadata, topic string, _ int32, fbm kgo.FetchBatchMetrics)

func (*Metrics) OnProduceBatchWritten

func (m *Metrics) OnProduceBatchWritten(meta kgo.BrokerMetadata, topic string, _ int32, pbm kgo.ProduceBatchMetrics)

func (*Metrics) Registry

func (m *Metrics) Registry() metrics.Registry

Registry returns the registry that metrics were added to.

type Opt

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

Opt applies options to further tune how metrics are gathered.

func NamePrefix

func NamePrefix(prefix string) Opt

NamePrefix sets configures all register names to be prefixed with this value.

func Registry

func Registry(reg metrics.Registry) Opt

Registry sets the registry to add metrics to, rather than metrics.DefaultRegistry.

Jump to

Keyboard shortcuts

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