prometheusbp

package
v0.10.3-beta.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package prometheusbp provides common code used for exporting Prometheus metrics.

Index

Constants

View Source
const (
	// DefaultNativeHistogramBucketFactor is the default bucket factor for native histograms.
	// This controls the resolution of the histogram buckets.
	DefaultNativeHistogramBucketFactor = 1.1

	// DefaultNativeHistogramMaxBucketNumber is the default maximum number of buckets
	// for native histograms.
	DefaultNativeHistogramMaxBucketNumber = 160

	// DefaultNativeHistogramMinResetDuration is the default minimum duration between
	// resets for native histograms.
	DefaultNativeHistogramMinResetDuration = 1 * time.Hour
)

Variables

View Source
var (
	// DefaultLatencyBuckets is the default bucket values for a prometheus latency histogram metric.
	//
	// These match the spec defined at https://github.snooguts.net/reddit/baseplate.spec/blob/master/component-apis/prom-metrics.md#latency-histograms
	DefaultLatencyBuckets = []float64{
		0.000_100,
		0.000_500,
		0.001_000,
		0.002_500,
		0.005_000,
		0.010_000,
		0.025_000,
		0.050_000,
		0.100_000,
		0.250_000,
		0.500_000,
		1.000_000,
		5.000_000,
		15.000_000,
		30.000_000,
	}

	// Deprecated: Please use DefaultLatencyBuckets instead for latencies if the buckets suit your needs, otherwise define your own buckets.
	DefaultBuckets = DefaultLatencyBuckets

	DefaultNativeHistogramBucketing = &NativeHistogramBucketing{
		BucketFactor:     DefaultNativeHistogramBucketFactor,
		MaxBucketNumber:  DefaultNativeHistogramMaxBucketNumber,
		MinResetDuration: DefaultNativeHistogramMinResetDuration,
	}
)

Functions

func BoolString added in v0.9.5

func BoolString(b bool) string

BoolString returns the string version of a boolean value that should be used in a prometheus metric label.

func RecordModuleVersions added in v0.9.12

func RecordModuleVersions(info *debug.BuildInfo)

RecordModuleVersions records the modules linked into this binary in the baseplate_go_modules prometheus metric.

Users should not need to call this directly, as it is called by baseplate.New. This should generally not be called more than once, and it is not safe to call concurrently.

Types

type HistogramOpts

type HistogramOpts struct {
	Name                     string
	Help                     string
	LegacyBuckets            []float64
	NativeHistogramBucketing *NativeHistogramBucketing
}

func (HistogramOpts) ToPrometheus

func (opts HistogramOpts) ToPrometheus() prometheus.HistogramOpts

type NativeHistogramBucketing

type NativeHistogramBucketing struct {
	BucketFactor     float64
	MaxBucketNumber  uint32
	MinResetDuration time.Duration
}

Directories

Path Synopsis
Package promtest provides test utilites for testing Prometheus metrics.
Package promtest provides test utilites for testing Prometheus metrics.

Jump to

Keyboard shortcuts

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