segmentobs

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 7 Imported by: ? 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 segmentobs observes the resolvers of the dynamic segments for Prometheus.

The default series carry the connection (a name of the bootstrap file, a handful) and bounded enums (result, reason), never a flag set, a segment, a member or a key. The series per segment name are opt-in and capped: the names beyond the cap share the series of one bucket, OtherSegment.

The observer of a connection counts with atomics only: no lock and no allocation on the evaluation path. The per-segment series take a read lock once for each segment of a call, and only when they are enabled.

Index

Constants

View Source
const (
	MetricLookups  = "semaphore_segment_lookups_total"
	MetricDuration = "semaphore_segment_lookup_duration_seconds"
	MetricUnknown  = "semaphore_segment_unknown_total"
	MetricNamed    = "semaphore_segment_named_lookups_total"
	MetricNamedUnk = "semaphore_segment_named_unknown_total"
	MetricOverflow = "semaphore_segment_named_overflow_total"
)

The series of the observers.

View Source
const (
	// DefaultMaxSegments is the cap of distinct segment names of the per-segment series.
	DefaultMaxSegments = 100
	// OtherSegment is the value of the segment label for the names beyond the cap.
	OtherSegment = "other"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnObserver

type ConnObserver struct {
	*resolver.Counters
	// contains filtered or unexported fields
}

ConnObserver counts the calls of the resolvers of one connection. The embedded counters count with atomics only, so a call takes no lock and allocates nothing; the segments are added to the per-segment series when they are on.

func (*ConnObserver) ObserveSegment

func (c *ConnObserver) ObserveSegment(obs resolver.SegmentObservation)

ObserveSegment implements resolver.Observer.

type Observers

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

Observers is the source of the observers of the resolvers: one for each connection. It is also the Prometheus collector of what they count.

func New

func New(opts Options) *Observers

New returns observers with the options.

func (*Observers) Collect

func (o *Observers) Collect(out chan<- prom.Metric)

Collect implements prom.Collector.

func (*Observers) Describe

func (o *Observers) Describe(out chan<- *prom.Desc)

Describe implements prom.Collector.

func (*Observers) For

func (o *Observers) For(connection string) *ConnObserver

For returns the observer of the resolvers of a connection. The same connection gets the same observer. It is meant for the build of a binding, never for the evaluation path.

func (*Observers) SetLive

func (o *Observers) SetLive(names []string)

SetLive tells which segment names are live (defined by the segments objects that are served): only these, up to the cap and in sorted order, have a series by segment name; a name that is gone loses its series. It is called when a generation is applied. It does nothing when the per-segment series are off.

func (*Observers) Stats

func (o *Observers) Stats() resolver.Stats

Stats sums what the resolvers of every connection did since the start.

type Options

type Options struct {
	// PerSegment turns on the series labelled by segment name.
	PerSegment bool
	// MaxSegments caps the distinct segment names of the per-segment series. Zero means [DefaultMaxSegments].
	MaxSegments int
}

Options configures the observers.

Jump to

Keyboard shortcuts

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