metricslog

package
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 4 Imported by: 1 module, 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 metricslog is the Prometheus observer on the lifecycle spine. It owns no metrics of its own — it reads the per-request lifecycle Context + outcome and forwards them to the one-liner emitters in pkg/metrics. Registering it is the entire wiring for the request-flow metrics (Q1–Q2, Q5); no runner (pipeline/proxy/ws/ batch) changes, because every runner already feeds the lifecycle spine.

It registers on four seams: pre-flight (inflight gauge up), the post-flight Hook (request-flow histograms for buffered requests), a stream observer (the same histograms for streamed requests, whose Fill is skipped once a stream session pre-fills the collected set), and a Collector (inflight gauge down — Collect runs on every Finalize, unlike Fill which a pre-send stream fill can mark done).

Out of scope: the data-loss and provider-key-health metrics (Q3/Q4) are emitted at their sources (the emitters, keypool) — they don't pass through here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hook

type Hook struct{}

Hook reads request outcome + timing and emits the request-flow metrics. It is a pure lifecycle.Hook: it produces no stored result (returns nil) and never mutates the Context post-flight. Emitting a Prometheus sample is a cheap, non-blocking atomic op, so it satisfies the "Fill must be cheap" rule.

func New

func New() *Hook

New constructs the (stateless) metrics observer.

func (*Hook) Collect added in v0.3.0

func (*Hook) Collect(lc *lifecycle.Context)

Collect lowers the inflight gauge for a finalized request. It is a Collector, not part of Fill, because Fill is skipped when a stream session pre-filled the request — Collect runs on every Finalize.

func (*Hook) Fill

func (*Hook) Name

func (*Hook) Name() string

func (*Hook) NewObserver added in v0.9.8

func (*Hook) NewObserver(lc *lifecycle.Context) lifecycle.StreamObserver

NewObserver makes the metrics observer also a StreamObserverFactory. A streamed request pre-fills its collected set, which marks the Context filled and skips the post-flight Fill fan-out — so the request-flow histograms Fill emits would be lost for every stream. This observer re-emits them at end-of-stream instead. It stores nothing (returns nil), so it never collides with a real producer under the "metrics" name.

func (*Hook) PreFlight added in v0.3.0

PreFlight marks the request admitted: the inflight gauge rises and the Metadata note arms the post-flight decrement. O(1), never errors.

Jump to

Keyboard shortcuts

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