daemon

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package daemon implements a daemon to import librdkafka metrics from JSON and export librdkafka metrics in Prometheus exposition format over an HTTP API. An example command to run the daemon is provided at the root of this distribution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ListenAddr      string        // Address and TCP port to listen on, e.g. "127.0.0.1:8080"
	ReadTimeout     time.Duration // Amount of time allowed to read request
	WriteTimeout    time.Duration // Amount of time allowed to write response
	ShutdownTimeout time.Duration // Amount of time allowed for graceful shutdown
}

Config holds configuration for the daemon.

type Daemon

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

Daemon holds internal state and contains no exported fields.

func New

func New(m Metrics) Daemon

New returns an instance of the daemon.

func (Daemon) Listen

func (d Daemon) Listen(ctx context.Context, cfg Config) error

Listen starts the HTTP server which handles connections. Cancelling the context will start a graceful shutdown of the server. The server continues to run until all remaining active connections have been served or the [Config.ShutdownTimeout] is reached.

type Metrics

type Metrics interface {
	ReadFrom(io.Reader) error
	Handler() http.Handler
}

Metrics is the interface required for the daemon to support metrics functionality, including the POST /metrics endpoint, which uses the ReadFrom() method to accept metric values in JSON format, and the GET /metrics endpoint, which uses the Handler() method to returns metric values in Prometheus exposition format.

See github.com/allsopp/librdkafka-exporter/metrics.Metrics for the reference implementation of this interface.

Jump to

Keyboard shortcuts

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