metrics

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(namespace string) error

Configure sets the metrics used by packages that emit shared internal metrics. Applications must call Configure with their application namespace before starting those packages.

Calling Configure repeatedly with the same namespace is allowed. Attempting to replace an existing configuration with a different namespace returns an error because metrics may already be registered under the original name.

Types

type Metrics

type Metrics struct {
	// PanicsTotal tracks panics recovered by library components.
	//
	// Labels:
	//   - "caller": The function or component that recovered the panic
	//   - "context": Additional context about where the panic occurred
	//
	// Example usage:
	//   metrics.RecordPanic("repeat.Every", "background")
	PanicsTotal *lazy.CounterVec
}

func Configured

func Configured() *Metrics

Configured returns the application-configured internal metrics. It panics with a setup error when Configure has not been called, preventing ambiguous unnamespaced metrics from being emitted.

func New

func New(namespace string) *Metrics

func (*Metrics) RecordPanic

func (m *Metrics) RecordPanic(caller, context string)

RecordPanic records a recovered panic. It is nil-safe so callers do not need conditional metric handling when instrumentation is disabled.

Jump to

Keyboard shortcuts

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