observability

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) 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