saramaprom

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README

saramaprom

is a library for exporting sarama metrics (provided through go-metrics) to Prometheus. It is a fork of saramaprom with few fixes and tweaks:

  • go-metrics histograms are registered as Prometheus summaries (to better present client side quantiles)
  • removed histogram and timer words from metric names
  • removed configuration of optional labels from saramaprom (we never configure it and it was creating additional unnecessary dimension to metrics due to bad implementation)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricsRegistry

type MetricsRegistry interface {
	Each(func(name string, i interface{}))
}

MetricsRegistry is an interface for 'github.com/rcrowley/go-metrics'.Registry which is used for metrics in sarama.

type Options

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

	// RefreshInterval specifies interval between updating metrics. Default 1s.
	RefreshInterval time.Duration
}

Options holds optional params for ExportMetrics.

type Scheduler

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

Scheduler is used to run jobs in specific intervals.

func StartScheduler

func StartScheduler(interval time.Duration, job func()) Scheduler

StartScheduler starts goroutine that will run given job in given intervals until Stop() is called.

func (Scheduler) Stop

func (s Scheduler) Stop()

Stop stops the goroutine running scheduled job.

type StopFunc

type StopFunc func()

StopFunc represents function for stopping scheduled task.

func ExportMetrics

func ExportMetrics(metricsRegistry MetricsRegistry, opt Options) StopFunc

ExportMetrics exports metrics from go-metrics to prometheus by starting background task, which periodically sync sarama metrics to prometheus registry.

Jump to

Keyboard shortcuts

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