observability

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package observability owns fixed-cardinality in-process timing observations.

Index

Constants

View Source
const (
	// HTTPWindowResolution is the fixed resolution of the bounded current-deployment view.
	HTTPWindowResolution = time.Minute
	// HTTPWindowRetention is the maximum queryable in-process API timing window.
	HTTPWindowRetention = time.Hour
)

Variables

View Source
var DurationBucketsSeconds = [...]float64{
	0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 120,
}

DurationBucketsSeconds is the shared cumulative histogram boundary set.

Functions

func PercentileMilliseconds

func PercentileMilliseconds(histogram DurationHistogram, quantile float64) *int64

PercentileMilliseconds estimates one percentile from the shared cumulative buckets.

Types

type DurationHistogram

type DurationHistogram struct {
	Count          uint64
	SumSeconds     float64
	MaximumSeconds float64
	BucketCounts   []uint64
}

DurationHistogram is one cumulative histogram snapshot.

func MergeHistograms

func MergeHistograms(histograms []DurationHistogram) DurationHistogram

MergeHistograms combines cumulative histograms with the shared bucket set.

type HTTPDuration

type HTTPDuration struct {
	Route       string
	StatusClass string
	Histogram   DurationHistogram
}

HTTPDuration identifies one bounded route-template and status-class series.

type TimingRecorder

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

TimingRecorder retains process-lifetime and bounded-window HTTP observations.

func NewTimingRecorder

func NewTimingRecorder() *TimingRecorder

NewTimingRecorder creates an empty process-lifetime timing recorder.

func (*TimingRecorder) HTTPSnapshot

func (recorder *TimingRecorder) HTTPSnapshot() []HTTPDuration

HTTPSnapshot returns a stable copy sorted by route and status class.

func (*TimingRecorder) HTTPSnapshotBetween

func (recorder *TimingRecorder) HTTPSnapshotBetween(
	since time.Time,
	until time.Time,
) []HTTPDuration

HTTPSnapshotBetween returns a stable rolling-window copy sorted by route and status class.

func (*TimingRecorder) ObserveHTTP

func (recorder *TimingRecorder) ObserveHTTP(
	route string,
	statusClass string,
	duration time.Duration,
)

ObserveHTTP records one completed request using only bounded dimensions.

func (*TimingRecorder) ObserveHTTPAt

func (recorder *TimingRecorder) ObserveHTTPAt(
	route string,
	statusClass string,
	duration time.Duration,
	observedAt time.Time,
)

ObserveHTTPAt records one completed request in the cumulative and rolling views.

Jump to

Keyboard shortcuts

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