Documentation ¶
Overview ¶
Package kprom provides prometheus plug-in metrics for a kgo client.
This package tracks the following metrics under the following names, all metrics being counter vecs:
#{ns}_connects_total{node_id="#{node}"} #{ns}_connect_errors_total{node_id="#{node}"} #{ns}_write_errors_total{node_id="#{node}"} #{ns}_write_bytes_total{node_id="#{node}"} #{ns}_read_errors_total{node_id="#{node}"} #{ns}_read_bytes_total{node_id="#{node}"} #{ns}_produce_bytes_total{node_id="#{node}",topic="#{topic}"} #{ns}_fetch_bytes_total{node_id="#{node}",topic="#{topic}"} #{ns}_buffered_produce_records_total #{ns}_buffered_fetch_records_total
This can be used in a client like so:
m := kprom.NewMetrics() cl, err := kgo.NewClient( kgo.WithHooks(m), // ...other opts )
More examples are linked in the main project readme: https://github.com/tdx/franz-go/#metrics--logging
By default, metrics are installed under the a new prometheus registry, but this can be overridden with the Registry option.
Note that seed brokers use broker IDs prefixed with "seed_", with the number corresponding to which seed it is.
Index ¶
- type Metrics
- func (m *Metrics) Handler() http.Handler
- func (m *Metrics) OnBrokerConnect(meta kgo.BrokerMetadata, _ time.Duration, _ net.Conn, err error)
- func (m *Metrics) OnBrokerDisconnect(meta kgo.BrokerMetadata, _ net.Conn)
- func (m *Metrics) OnBrokerRead(meta kgo.BrokerMetadata, _ int16, bytesRead int, _, _ time.Duration, err error)
- func (m *Metrics) OnBrokerWrite(meta kgo.BrokerMetadata, _ int16, bytesWritten int, _, _ time.Duration, ...)
- func (m *Metrics) OnFetchBatchRead(meta kgo.BrokerMetadata, topic string, _ int32, fbm kgo.FetchBatchMetrics)
- func (m *Metrics) OnNewClient(cl *kgo.Client)
- func (m *Metrics) OnProduceBatchWritten(meta kgo.BrokerMetadata, topic string, _ int32, pbm kgo.ProduceBatchMetrics)
- func (m *Metrics) Registry() prometheus.Registerer
- type Opt
- type RegistererGatherer
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 prometheus metrics to a given registry.
func NewMetrics ¶
NewMetrics returns a new Metrics that adds prometheus metrics to the registry under the given namespace.
func (*Metrics) OnBrokerConnect ¶
func (*Metrics) OnBrokerDisconnect ¶
func (m *Metrics) OnBrokerDisconnect(meta kgo.BrokerMetadata, _ net.Conn)
func (*Metrics) OnBrokerRead ¶
func (*Metrics) OnBrokerWrite ¶
func (*Metrics) OnFetchBatchRead ¶
func (m *Metrics) OnFetchBatchRead(meta kgo.BrokerMetadata, topic string, _ int32, fbm kgo.FetchBatchMetrics)
func (*Metrics) OnNewClient ¶
func (*Metrics) OnProduceBatchWritten ¶
func (m *Metrics) OnProduceBatchWritten(meta kgo.BrokerMetadata, topic string, _ int32, pbm kgo.ProduceBatchMetrics)
func (*Metrics) Registry ¶
func (m *Metrics) Registry() prometheus.Registerer
Registry returns the prometheus registry that metrics were added to.
This is useful if you want the Metrics type to create its own registry for you to add additional metrics to.
type Opt ¶
type Opt interface {
// contains filtered or unexported methods
}
Opt applies options to further tune how prometheus metrics are gathered or which metrics to use.
func Gatherer ¶
func Gatherer(gatherer prometheus.Gatherer) Opt
Registry sets the gatherer to add metrics to, rather than a new registry.
func GoCollectors ¶
func GoCollectors() Opt
GoCollectors adds the prometheus.NewProcessCollector and prometheus.NewGoCollector collectors the the Metric's registry.
func HandlerOpts ¶
func HandlerOpts(opts promhttp.HandlerOpts) Opt
HandlerOpts sets handler options to use if you wish you use the Metrics.Handler function.
This is only useful if you both (a) do not want to provide your own registry and (b) want to override the default handler options.
func Registerer ¶
func Registerer(reg prometheus.Registerer) Opt
Registry sets the registerer to add metrics 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.
type RegistererGatherer ¶
type RegistererGatherer interface { prometheus.Registerer prometheus.Gatherer }