Documentation
¶
Overview ¶
Package logcount counts the log lines a miren process prints, by level and by source, so the error rate can be shipped as a metric and alerted on instead of read out of a journal nobody collects.
Counting happens in a slog.Handler that wraps the process's root handler, so it sees exactly the records that get printed. Output relayed from child processes (vmagent, etcd, buildkit and friends) passes through the same handler, but it is counted under the child's name and at the child's own level, which the relay may have clamped for display. Without that split an etcd error would count as a miren info line, and a burst of vmagent failures would be invisible.
Index ¶
Constants ¶
const NumSources = int(numSources)
NumSources is the number of distinct Source values, for iterating Counts.
Variables ¶
var Default = &Counts{}
Default is the process-wide set that the CLI's root logger counts into and the metrics collectors read from.
var Levels = [numLevels]string{"debug", "info", "warn", "error"}
Levels are the label values for the four buckets a counted line lands in.
Functions ¶
func CountAt ¶
CountAt marks ctx so that a record logged with it is counted as miren's own line at level, whatever level it prints at. It's for lines that log loud only so they always print, like a log level change, and would otherwise count as errors.
func MirenLevel ¶ added in v0.18.0
MirenLevel returns the level a miren line logged with ctx is counted at: the one CountAt set, or printed when it set none. Relayed children keep their printed level, since a clamp lowers it on purpose.
Types ¶
type Counts ¶
type Counts struct {
// contains filtered or unexported fields
}
Counts holds cumulative line counts for one process.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler counts every record it handles into Counts, then passes it on.
func NewHandler ¶
NewHandler wraps inner so that its records are counted into counts.
type Source ¶
type Source int
Source is who wrote a counted line: miren itself, or a relayed child.
const ( SourceMiren Source = iota SourceBuildkit SourceContainerd SourceEtcd SourceEtcdutl SourceVictoriaLogs SourceVictoriaMetrics SourceVMAgent SourceOther )
The relayed sources are a fixed set, so the metric's source label stays bounded no matter what a caller passes to SourceFor.