### Install saramaprom Go Library via go get Source: https://github.com/iimos/saramaprom/blob/master/README.md This console command installs the `saramaprom` Go library using `go get`. It fetches the package from its GitHub repository, making it available for import and use in Go projects. This is the standard way to add the dependency to your Go module. ```console go get github.com/iimos/saramaprom ``` -------------------------------- ### Export Sarama Metrics to Prometheus with saramaprom in Go Source: https://github.com/iimos/saramaprom/blob/master/README.md This Go code demonstrates how to integrate `saramaprom` to export Sarama Kafka client metrics to Prometheus. It initializes a Sarama configuration and calls `saramaprom.ExportMetrics`, passing a context, Sarama's metric registry, and an `Options` struct. The `Label` field is crucial for distinguishing metrics from different Sarama instances. ```go import ( "context" "github.com/Shopify/sarama" "github.com/iimos/saramaprom" ) ctx := context.Background() cfg := sarama.NewConfig() err := saramaprom.ExportMetrics(ctx, cfg.MetricRegistry, saramaprom.Options{ Label: "some name to distinguish between different sarama instances", }) ``` -------------------------------- ### saramaprom.Options Configuration Struct Reference Source: https://github.com/iimos/saramaprom/blob/master/README.md This `APIDOC` entry details the `saramaprom.Options` struct, which configures how metrics are exported. It specifies fields like `PrometheusRegistry` for custom Prometheus integration, `Namespace` and `Subsystem` for metric naming, and `Label` for instance identification. Other fields control flush intervals, error handling, and debug logging, providing fine-grained control over metric reporting. ```APIDOC type Options struct { // PrometheusRegistry is prometheus registry. Default prometheus.DefaultRegisterer. PrometheusRegistry prometheus.Registerer // Namespace and Subsystem form the metric name prefix. // Default Subsystem is "sarama". Namespace string Subsystem string // Label specifies value of "label" label. It is recomended // to always set the label to avoid collisions between sarama // instances. Default "". Label string // FlushInterval specifies interval between updating metrics. Default 1s. FlushInterval time.Duration // OnError is error handler. Default handler panics when error occurred. OnError func(err error) // Debug turns on debug logging. Debug bool } ``` -------------------------------- ### Default Prometheus Metrics and Labels Exposed by saramaprom Source: https://github.com/iimos/saramaprom/blob/master/README.md This `APIDOC` section lists the standard Prometheus metrics exported by `saramaprom`, categorized into Gauges and Histograms. These metrics provide detailed insights into Sarama's internal operations, such as byte rates, request latencies, and batch sizes. Crucially, each metric includes `broker`, `topic`, and a custom `label` to enable precise filtering and analysis in Prometheus. ```APIDOC Gauges: sarama_batch_size sarama_compression_ratio sarama_incoming_byte_rate sarama_outgoing_byte_rate sarama_record_send_rate sarama_records_per_request sarama_request_latency_in_ms sarama_request_rate sarama_request_size sarama_requests_in_flight sarama_response_rate sarama_response_size Histograms: sarama_batch_size_histogram sarama_compression_ratio_histogram sarama_records_per_request_histogram sarama_request_latency_in_ms_histogram sarama_request_size_histogram sarama_response_size_histogram ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.