client

package
v3.6.21 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricsPrefix = "loki_kafka_client"
)

Variables

This section is empty.

Functions

func NewClientMetrics added in v3.6.0

func NewClientMetrics(component string, reg prometheus.Registerer, enableKafkaHistograms bool) *kprom.Metrics

NewClientMetrics returns a new instance of `kprom.Metrics` (used to monitor Kafka interactions), provided the `MetricsPrefix` as the `Namespace` for the default set of Prometheus metrics

func NewReaderClient

func NewReaderClient(component string, kafkaCfg kafka.Config, logger log.Logger, reg prometheus.Registerer, opts ...kgo.Opt) (*kgo.Client, error)

NewReaderClient returns the kgo.Client that should be used by the Reader.

The returned Client utilizes the standard set of *kprom.Metrics, prefixed with `MetricsPrefix`

func NewWriterClient

func NewWriterClient(component string, kafkaCfg kafka.Config, maxInflightProduceRequests int, logger log.Logger, reg prometheus.Registerer) (*kgo.Client, error)

NewWriterClient returns the kgo.Client that should be used by the Writer.

The returned Client collects the standard set of *kprom.Metrics, prefixed with `MetricsPrefix`

func WrapPrometheusRegisterer added in v3.6.0

func WrapPrometheusRegisterer(component string, reg prometheus.Registerer) prometheus.Registerer

WrapPrometheusRegisterer returns a prometheus.Registerer with labels applied

This Registerer is used internally by the reader/writer Kafka clients to collect *kprom.Metrics (or any custom metrics passed by a calling service)

Types

type Producer

type Producer struct {
	*kgo.Client
	// contains filtered or unexported fields
}

Producer is a kgo.Client wrapper exposing some higher level features and metrics useful for producers.

func NewProducer

func NewProducer(component string, client *kgo.Client, maxBufferedBytes int64, reg prometheus.Registerer) *Producer

NewProducer returns a new KafkaProducer.

The input prometheus.Registerer must be wrapped with a prefix (the names of metrics registered don't have a prefix).

func (*Producer) Close

func (c *Producer) Close()

func (*Producer) ProduceSync

func (c *Producer) ProduceSync(ctx context.Context, records []*kgo.Record) kgo.ProduceResults

ProduceSync produces records to Kafka and returns once all records have been successfully committed, or an error occurred.

This function honors the configure max buffered bytes and refuse to produce a record, returnin kgo.ErrMaxBuffered, if the configured limit is reached.

Jump to

Keyboard shortcuts

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