prometheus

package
v0.0.0-...-1aa08c1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package prometheus provides utilities to collect and consume metrics (instrumentation data).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Operator

type Operator interface {
	// GatherMetrics try to collect metrics available on a best-effort manner.
	GatherMetrics() ([]*dto.MetricFamily, error)

	// MetricsHandler returns an interface to gather metrics via HTTP.
	MetricsHandler() http.Handler

	// InitializeMetrics initializes all metrics, with their appropriate null value,
	// for all gRPC methods registered on a gRPC server. This is useful, to ensure
	// that all metrics exist when collecting and querying. The server interceptors
	// MUST be registered BEFORE performing this operation.
	InitializeMetrics(srv *grpc.Server)

	// Client returns the unary and stream interceptor required to instrument a
	// gRPC client instance. Captured metrics include histograms by default; this
	// allows calculating service latency but is expensive.
	//   https://github.com/grpc-ecosystem/go-grpc-prometheus#histograms
	Client() (grpc.UnaryClientInterceptor, grpc.StreamClientInterceptor)

	// Server returns required gRPC interceptors to instrument a server instance.
	// Captured metrics include histograms by default; this allows calculating service
	// latency but is expensive.
	//   https://github.com/grpc-ecosystem/go-grpc-prometheus#histograms
	//
	// Example Grafana base dashboard:
	//   https://grafana.com/grafana/dashboards/9186
	Server() (grpc.UnaryServerInterceptor, grpc.StreamServerInterceptor)
}

Operator instances allows to easily collect and consume prometheus metrics.

func NewOperator

func NewOperator(reg *prometheus.Registry, cols ...prometheus.Collector) (Operator, error)

NewOperator returns a ready-to-use operator instance. An operator allows to easily collect and consume instrumentation data. Host and runtime metrics are collected by default, in addition to any additional collector provided. If you don't provide a prometheus registry `reg`, a new empty one will be created by default.

prom, _ := pkg.NewOperator(prometheus.NewRegistry())
opts := []rpc.ServerOption{WithPrometheus(prom)}

Jump to

Keyboard shortcuts

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