Documentation
¶
Overview ¶
Package observability provides process and service metrics without depending on one metrics provider.
Index ¶
- func DurationBucketsSeconds() []float64
- func ParseMetrics(reader io.Reader) ([]*dto.MetricFamily, error)
- func ProcessHandler(metrics http.Handler, ready func() bool) http.Handler
- type DatabaseConnectionSnapshot
- type DatabaseOperationSnapshot
- type DatabaseSnapshot
- type DurationSummary
- type IngressRoutingSnapshot
- type Metrics
- func (m *Metrics) APIRequests(surface string, next http.Handler) http.Handler
- func (m *Metrics) AddAssignmentReplacements(reason string, count int)
- func (m *Metrics) AddForwardedBytes(direction string, count int64)
- func (m *Metrics) AddReadyPublisherConnections(delta int)
- func (m *Metrics) AddRecoveryPending(delta int)
- func (m *Metrics) AddRegisteredPublisherConnections(delta int)
- func (m *Metrics) AddRelayLeases(state string, delta int)
- func (m *Metrics) AddRelayStreams(delta int)
- func (m *Metrics) AddUsageItems(result string, count int)
- func (m *Metrics) Gather() ([]*dto.MetricFamily, error)
- func (m *Metrics) Handler() http.Handler
- func (m *Metrics) IncCapacityRejection(resource string)
- func (m *Metrics) IncChallengeRejection(reason string)
- func (m *Metrics) IncDrainingRejection()
- func (m *Metrics) IncInspectionFailure(stage string)
- func (m *Metrics) ObserveAPIRequest(surface, operation, outcome string, duration time.Duration)
- func (m *Metrics) ObserveCertificateClaim(kind, outcome string)
- func (m *Metrics) ObserveCertificateIteration(kind, stage, outcome string, duration time.Duration)
- func (m *Metrics) ObserveCertificateMilestone(milestone string, age time.Duration)
- func (m *Metrics) ObserveCertificateTransition(kind, state string)
- func (m *Metrics) ObserveCertificateWork(stage, outcome string, duration time.Duration)
- func (m *Metrics) ObserveCleanup(kind string, count int, busy bool, err error)
- func (m *Metrics) ObserveDNSTransition(kind, state string)
- func (m *Metrics) ObserveDNSWork(kind, phase, outcome string, elapsed time.Duration)
- func (m *Metrics) ObserveDatabaseAcquire(err error, elapsed time.Duration)
- func (m *Metrics) ObserveDatabaseGuard(operation string, err error, elapsed time.Duration)
- func (m *Metrics) ObserveDatabaseQuery(operation string, err error, elapsed time.Duration)
- func (m *Metrics) ObserveOperation(operation string, err error, elapsed time.Duration)
- func (m *Metrics) ObservePlacement(action, outcome string)
- func (m *Metrics) ObservePublishRunReadiness(outcome string, duration, age time.Duration)
- func (m *Metrics) ObservePublisherExit(unexpected bool)
- func (m *Metrics) ObserveRecoveryAttempt(outcome string)
- func (m *Metrics) ObserveRecoveryDuration(duration time.Duration)
- func (m *Metrics) ObserveRelayAttempt(slot, outcome string)
- func (m *Metrics) ObserveRelayStreamRejection(reason string)
- func (m *Metrics) ObserveRoutingHistoryBatch(scanned, deleted int64, busy bool)
- func (m *Metrics) ObserveRoutingHistoryFloor(revision uint64)
- func (m *Metrics) ObserveUsageReceiver(outcome string, elapsed time.Duration)
- func (m *Metrics) ObserveUsageWork(phase, outcome string)
- func (m *Metrics) ObserveVisitor(outcome string)
- func (m *Metrics) ObserveVisitorOpen(success bool, elapsed time.Duration)
- func (m *Metrics) RegisterControlCertificate(source func() time.Time)
- func (m *Metrics) RegisterDatabase(source func(time.Time) DatabaseSnapshot)
- func (m *Metrics) RegisterIngressLease(source func() time.Time)
- func (m *Metrics) RegisterIngressRouting(source func() IngressRoutingSnapshot)
- func (m *Metrics) SetCapacityLimit(resource string, limit int64)
- func (m *Metrics) SetIngressConnections(class string, count int)
- func (m *Metrics) SetIngressStreams(count int)
- func (m *Metrics) SetReadyPublisherConnections(count int)
- func (m *Metrics) SetRelayCertificateExpiry(identity string, expires time.Time)
- func (m *Metrics) SetRelayLeaseExpiry(identity string, expires time.Time)
- func (m *Metrics) SetRelayLeases(state string, count int)
- func (m *Metrics) SetUsageRetained(count int)
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DurationBucketsSeconds ¶
func DurationBucketsSeconds() []float64
DurationBucketsSeconds returns independent boundaries shared by operation, HTTP, SQL, and driver-observed guard histograms. the final implicit +Inf bucket also counts operations longer than two minutes.
func ParseMetrics ¶
func ParseMetrics(reader io.Reader) ([]*dto.MetricFamily, error)
ParseMetrics decodes Prometheus text exposition, retaining types and labels.
Types ¶
type DatabaseSnapshot ¶
type DatabaseSnapshot struct {
Pool *pgxpool.Stat
Connections map[string]DatabaseConnectionSnapshot
ActiveOperations []DatabaseOperationSnapshot
OperationsOmitted int
}
DatabaseSnapshot is process-local database state collected without I/O.
type DurationSummary ¶
type DurationSummary struct {
Name string `json:"name"`
Labels map[string]string `json:"labels"`
Count uint64 `json:"count"`
SumSeconds float64 `json:"sum_seconds"`
MeanSeconds float64 `json:"mean_seconds"`
P50Seconds *float64 `json:"p50_seconds"`
P95Seconds *float64 `json:"p95_seconds"`
P99Seconds *float64 `json:"p99_seconds"`
}
DurationSummary describes observations between two process-local snapshots. quantiles are linear estimates within classic histogram buckets, not exact samples or maxima. they are nil for an empty interval or the unbounded bucket.
func DurationSummaries ¶
func DurationSummaries(before, after []*dto.MetricFamily) ([]DurationSummary, error)
DurationSummaries differences classic histogram counts, sums, and cumulative buckets before estimating quantiles. inputs must describe the same process; process_start_time_seconds and histogram creation timestamps, when present, also detect restarts. new lazy series start at zero. missing end series, changed layouts, invalid samples, and detectable resets invalidate the interval. all histogram families are included; callers should supply durations in seconds.
type IngressRoutingSnapshot ¶
type IngressRoutingSnapshot struct {
Initialized bool
CaughtUp bool
LastSuccessfulCheck time.Time
LastCaughtUp time.Time
LastAcknowledged time.Time
LatestRevision int64
AppliedRevision int64
AcknowledgedRevision int64
UpdateFailures uint64
Resnapshots uint64
}
IngressRoutingSnapshot is bounded, process-local controller state. revisions describe successful routing responses, not control's current revision while a request is pending. CaughtUp requires an event response confirming catch-up; applying the initial snapshot alone only establishes Initialized.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics owns a process-local Prometheus registry.
func (*Metrics) APIRequests ¶
APIRequests records matched route patterns, never URLs or resource IDs. wrap the router so authentication and parameter-binding failures are counted too.
func (*Metrics) AddAssignmentReplacements ¶
func (*Metrics) AddForwardedBytes ¶
func (*Metrics) AddReadyPublisherConnections ¶
func (*Metrics) AddRecoveryPending ¶
func (*Metrics) AddRegisteredPublisherConnections ¶
func (*Metrics) AddRelayLeases ¶
func (*Metrics) AddRelayStreams ¶
func (*Metrics) AddUsageItems ¶
func (*Metrics) Gather ¶
func (m *Metrics) Gather() ([]*dto.MetricFamily, error)
Gather captures this process's registry using only passive collectors.
func (*Metrics) IncCapacityRejection ¶
func (*Metrics) IncChallengeRejection ¶
func (*Metrics) IncDrainingRejection ¶
func (m *Metrics) IncDrainingRejection()
func (*Metrics) IncInspectionFailure ¶
func (*Metrics) ObserveAPIRequest ¶
func (*Metrics) ObserveCertificateClaim ¶
func (*Metrics) ObserveCertificateIteration ¶
func (*Metrics) ObserveCertificateMilestone ¶
func (*Metrics) ObserveCertificateTransition ¶
func (*Metrics) ObserveCertificateWork ¶
func (*Metrics) ObserveCleanup ¶
func (*Metrics) ObserveDNSTransition ¶
func (*Metrics) ObserveDNSWork ¶
func (*Metrics) ObserveDatabaseAcquire ¶
func (*Metrics) ObserveDatabaseGuard ¶
ObserveDatabaseGuard records a driver-observed guard interval. outcome is the transaction-ending command's outcome, not the application operation's outcome.
func (*Metrics) ObserveDatabaseQuery ¶
ObserveDatabaseQuery accepts only names sanitized by the controlstate tracer: compiled sqlc operations, transaction commands, or the fixed "unknown" label.
func (*Metrics) ObserveOperation ¶
ObserveOperation records only the fixed application operations below. nil metrics are useful for callers that do not run a process metrics listener.
func (*Metrics) ObservePlacement ¶
func (*Metrics) ObservePublishRunReadiness ¶
outcomes and stages are closed sets, independent of public URL and order identity.
func (*Metrics) ObservePublisherExit ¶
func (*Metrics) ObserveRecoveryAttempt ¶
func (*Metrics) ObserveRecoveryDuration ¶
func (*Metrics) ObserveRelayAttempt ¶
func (*Metrics) ObserveRelayStreamRejection ¶
func (*Metrics) ObserveRoutingHistoryBatch ¶
func (*Metrics) ObserveRoutingHistoryFloor ¶
func (*Metrics) ObserveUsageReceiver ¶
func (*Metrics) ObserveUsageWork ¶
func (*Metrics) ObserveVisitor ¶
visitor outcomes describe the last ingress boundary reached, not a completed TLS handshake or a successful HTTP request at the local service.
func (*Metrics) ObserveVisitorOpen ¶
func (*Metrics) RegisterControlCertificate ¶
RegisterControlCertificate reads certificate material already in this process.
func (*Metrics) RegisterDatabase ¶
func (m *Metrics) RegisterDatabase(source func(time.Time) DatabaseSnapshot)
RegisterDatabase exposes in-memory database state. its source must never acquire a connection because collection must remain available under database contention and pool exhaustion.
func (*Metrics) RegisterIngressLease ¶
RegisterIngressLease reads a local controller snapshot without external I/O.
func (*Metrics) RegisterIngressRouting ¶
func (m *Metrics) RegisterIngressRouting(source func() IngressRoutingSnapshot)
RegisterIngressRouting exposes one ingress controller's in-memory state. the source must perform no network or database I/O, including during a stalled poll.