Documentation
¶
Overview ¶
How icebath stands, read from outside in the tools an operator already has: the measures every feature takes of itself and the events it tells of, bounded and free of anything a person or the agent wrote, sent to an OpenTelemetry collector once a person turns the export on and served in the Prometheus text format where the server is let. What there is to measure is brought by the features themselves, each registering what it measures and tells of
Index ¶
- Constants
- Variables
- func Shared[T any](ctx context.Context, key string, read func() T) T
- func Shown(address string) string
- type Attribute
- type Cause
- type Event
- type Happening
- type Kind
- type Label
- type Measure
- type Metric
- type Monitoring
- func (m *Monitoring) Admits(r *http.Request) (bool, int, string)
- func (m *Monitoring) As(purpose install.Purpose)
- func (m *Monitoring) Config() *config.Config
- func (m *Monitoring) Instance() string
- func (m *Monitoring) KeyIssue() string
- func (m *Monitoring) Leaving(label Pair) string
- func (m *Monitoring) Logged(level zerolog.Level, profile string, fields map[string]string)
- func (m *Monitoring) Measure(ctx context.Context) []Measure
- func (m *Monitoring) Opaque(value string) string
- func (m *Monitoring) Plan() Plan
- func (m *Monitoring) Purpose() install.Purpose
- func (m *Monitoring) Queued() (int, int64)
- func (m *Monitoring) Reach(ctx context.Context) []Tried
- func (m *Monitoring) Recent() []Told
- func (m *Monitoring) Register(registrant Registrant)
- func (m *Monitoring) Resource() ([]Attribute, []string)
- func (m *Monitoring) Run(ctx context.Context) error
- func (m *Monitoring) Scrape(ctx context.Context) []byte
- func (m *Monitoring) Sends() []Send
- func (m *Monitoring) Serve(w http.ResponseWriter, r *http.Request)
- func (m *Monitoring) Started() time.Time
- func (m *Monitoring) Tell(event Event)
- func (m *Monitoring) Test(ctx context.Context) []Tried
- func (m *Monitoring) Token() (string, error)
- type Number
- type Pair
- type Plan
- type Point
- type Registrant
- type Registry
- type Sample
- type Send
- type Severity
- type Target
- type Teller
- type Told
- type Tried
- type Watcher
Constants ¶
const ( LogWarning = "icebath.log.warning" LogError = "icebath.log.error" )
Kinds of event of the warnings and errors the log of the process writes
const ( SignalMetrics = "metrics" SignalLogs = "logs" SignalTraces = "traces" )
Signals the export sends, as the collector names them
const ( // This process began to keep its measures and send them Started = "icebath.process.started" // This process is stopping Stopping = "icebath.process.stopping" // A person sent a test to the collector Tested = "icebath.monitoring.test" )
Kinds of event the host tells of itself
const CauseLabel = "cause"
The label every event carries, which a measure counted from events may name: the cause the event gives, one of Causes
const Other = "other"
Value a label keeps for a value it does not allow
const ScrapePath = "/metrics"
Route of the server the measures are served at, in the Prometheus text format
Variables ¶
var Causes = []string{string(AuthFailed), string(RateLimited), string(Timeout), string(NetworkError), string(InvalidConfig), string(StartupFailed), string(Refused), string(NotFound), string(Disk), string(Interrupted), string(Panic), string(Stopped), string(Shutdown), string(EmptyResponse), string(Unknown)}
Every cause an event may give, in the order they are listed
var Signals = []string{SignalMetrics, SignalLogs, SignalTraces}
The signals in the order they are listed
Functions ¶
Types ¶
type Attribute ¶
type Attribute struct {
Key, Value string
}
One label every request carries, of the process it comes from
type Cause ¶
type Cause string
Why something happened, as an event says it: one of a few words, never the text it was read from
const ( // A key, token or password was refused, or none was given AuthFailed Cause = "auth_failed" // The other end asked for fewer requests RateLimited Cause = "rate_limited" // An answer did not come in time Timeout Cause = "timeout" // The other end could not be reached, or the connection broke NetworkError Cause = "network_error" // A setting is missing or holds what can't be used InvalidConfig Cause = "invalid_config" // It could not start StartupFailed Cause = "startup_failed" // The other end refused what was asked, other than for a key Refused Cause = "refused" // What was asked for is not there NotFound Cause = "not_found" // A disk is full, a file can't be written, or a store is held Disk Cause = "disk" // It was cut short, such as by a process that ended under it Interrupted Cause = "interrupted" // A fault of the code Panic Cause = "panic" // A person or a feature asked it to stop Stopped Cause = "stopped" // icebath stopped Shutdown Cause = "shutdown" // The answer came and said nothing EmptyResponse Cause = "empty_response" // None of the above Unknown Cause = "unknown" )
type Event ¶
type Event struct {
// Name of a Happening a registrant declared; an event of no declared kind is dropped
Name string
Cause Cause
// Value of each label by name
Labels map[string]string
// Each number by name
Values map[string]float64
// When it happened, now when zero
At time.Time
}
Something that happened, as a feature tells it. What it says is bounded by the Happening it names before it is kept: labels it does not declare and numbers it does not name are dropped, values are kept as its labels allow
type Happening ¶
type Happening struct {
// Unique across icebath, as the name of a measure: icebath.service.died
Name string
About string
// How serious each event of it is
Severity Severity
Labels []Label
// Names of the numbers each event carries, such as duration, in the unit the name says or seconds for a length of time
Values []string
}
A kind of event a feature tells of
type Kind ¶
type Kind int
How a measure counts
const ( // A level read as it stands, which goes up and down: a service up, the jobs running, the memory in use Gauge Kind = iota // A total that only grows while the process runs: the starts of a service, the runs that ended Counter // How long or how large what happened was, kept in buckets Histogram )
type Label ¶
A label of a measure or an event. Its values are words of the code, never what a person wrote: a value outside Values is kept as other; with Values nil a value must be lower case letters, digits, dots, dashes and underscores, at most 64, or it is kept as other. The value of an Opaque label names something of a person, such as a profile, a job or a board: shown as it is on this computer and sent elsewhere as an id made from it with a key that never leaves this computer
type Metric ¶
type Metric struct {
// Unique across icebath: icebath and the feature first, lower case words joined by dots, such as icebath.service.up
Name string
// What it measures, a phrase a person reads, as the scrape and the collector describe it
About string
// Unit as OpenTelemetry names it: 1 for a flag or a count, s, By, or a word in braces such as {run}
Unit string
Kind Kind
Labels []Label
// Its points as they stand now, read when the measures are taken. Nil for a measure counted from events: From names the kind of
// event, a Counter then counts its events by the labels the measure names, a Histogram takes the value of each named Value
Read func(ctx context.Context) []Point
From string
Value string
// Upper bounds of the buckets of a histogram, lowest first; seconds from a tenth to an hour when nil
Bounds []float64
}
One measure a feature takes of itself
type Monitoring ¶
type Monitoring struct {
Registry
// contains filtered or unexported fields
}
The measures and events of icebath: what every feature measures of itself and tells of, kept in this process, the counts and buckets of the measures counted from events, the events lately told, and the export of them to a collector that the monitoring service runs
func New ¶
func New(cfg *config.Config) *Monitoring
func (*Monitoring) Admits ¶
Whether the request may read /metrics as the settings say, and when it may not the status to answer and why, a sentence: served at all, then open to anyone, to this computer, or to whoever gives the token as Bearer or as the password of Basic
func (*Monitoring) As ¶
func (m *Monitoring) As(purpose install.Purpose)
Says what this process is, the server or a window, which the export names it by
func (*Monitoring) Config ¶
func (m *Monitoring) Config() *config.Config
The config the host reads, for its facets
func (*Monitoring) Instance ¶
func (m *Monitoring) Instance() string
The id of this process as the collector names it: of the install, the settings folder and the server, the same from one start to the next; or of a window, which is one process and starts anew each time
func (*Monitoring) KeyIssue ¶
func (m *Monitoring) KeyIssue() string
Why the key can't be kept, so the ids change at every start; empty while it is kept
func (*Monitoring) Leaving ¶
func (m *Monitoring) Leaving(label Pair) string
The value of a label as it leaves this computer: the id of what a person named, the word of the code as it is
func (*Monitoring) Logged ¶
Tells a warning or an error the log of the process wrote as a diagnostic event: the part of icebath its caller names, the profile it is of, and the cause its message and error say. Nothing of the text of the record is kept: its message, its error and every other field stay in the log files. Handed to the logs host in main.go, which gives each record as it writes it, masked
func (*Monitoring) Measure ¶
func (m *Monitoring) Measure(ctx context.Context) []Measure
Every measure of icebath as it stands now: each registrant's read at once within the time a collection has, those counted from events as counted, the labels of every point bounded as their measure declares them. A measure that breaks or answers late is left out, said in the log
func (*Monitoring) Opaque ¶
func (m *Monitoring) Opaque(value string) string
The id a thing a person named leaves this computer as, such as a profile or a job: sixteen hex digits of its digest under a key that never leaves, the same for the same thing on this install and saying nothing of it elsewhere
func (*Monitoring) Purpose ¶
func (m *Monitoring) Purpose() install.Purpose
What this process is, the server or a window
func (*Monitoring) Queued ¶
func (m *Monitoring) Queued() (int, int64)
Events waiting to be sent now, and those dropped since the process started as the queue was full
func (*Monitoring) Reach ¶
func (m *Monitoring) Reach(ctx context.Context) []Tried
Asks the collector whether it takes a request of each signal the settings send, by a request that carries nothing, once and without trying again: how each went
func (*Monitoring) Recent ¶
func (m *Monitoring) Recent() []Told
The events told lately, the newest last
func (*Monitoring) Register ¶
func (m *Monitoring) Register(registrant Registrant)
Adds a registrant; a registry nested in the host reaches it through Host
func (*Monitoring) Resource ¶
func (m *Monitoring) Resource() ([]Attribute, []string)
What every request says of the process it comes from, in the order it is sent, and the labels a person gave that are not sent, each with why
func (*Monitoring) Run ¶
func (m *Monitoring) Run(ctx context.Context) error
The work of the monitoring service until the context ends: every registrant that looks at how its feature stands looking every while, and while the export is on the measures sent every interval and the events as they come; as it stops, what is left is sent within the time it has
func (*Monitoring) Scrape ¶
func (m *Monitoring) Scrape(ctx context.Context) []byte
The measures as Prometheus reads them, in its text format 0.0.4: what every request to the collector says of the process as target_info, then every measure with its HELP and TYPE, each opaque label as its id
func (*Monitoring) Sends ¶
func (m *Monitoring) Sends() []Send
How each signal went to the collector, of those tried, in the order of the signals
func (*Monitoring) Serve ¶
func (m *Monitoring) Serve(w http.ResponseWriter, r *http.Request)
Answers a request of /metrics: the measures in the text format to a request the settings let in, else the status and why
func (*Monitoring) Started ¶
func (m *Monitoring) Started() time.Time
When this process started, which the counters count from
func (*Monitoring) Tell ¶
func (m *Monitoring) Tell(event Event)
Keeps the event, bounded by the kind it names, among those told lately, in the counts of the measures counted from it and, while the export takes events, among those waiting to be sent. Never blocks and never fails the teller: an event of no kind declared is dropped. Before the monitoring service starts, while features still register, the event waits and is taken as the service starts
func (*Monitoring) Test ¶
func (m *Monitoring) Test(ctx context.Context) []Tried
Sends what the export would send now, once and without trying again, whether the export is on or not, as a person asks to see that the collector takes it: the measures as they stand, and a test event as a log record and as a span; each signal the settings leave out is said as skipped
func (*Monitoring) Token ¶
func (m *Monitoring) Token() (string, error)
The token /metrics takes: ICEBATH_METRICS_TOKEN of the profile the server runs on, its environment or a secret store, made and kept in the .env of that profile when none is set
type Pair ¶
One label as it is kept: its name, its value, and whether the value leaves this computer only as an id
type Plan ¶
type Plan struct {
// The export is on, else why not
On bool
Off string
// Of each signal: where it goes, by what protocol, how compressed, and the headers each request carries
Targets map[string]Target
// Longest one request may take, how long a failed batch is tried again, how often the measures are sent
Timeout, Retry, Interval time.Duration
// What is sent: the measures, the events, the warnings and errors of the log, the events as spans too
Metrics, Events, Logs, Spans bool
// Totals as what changed since the last send rather than as they stand
Delta bool
// Most events that wait to be sent
Queue int
// What keeps the export from being whole, each a sentence: a variable a header names that is not set, a certificate that does not read
Problems []string
}
The export as the settings and the variables of OpenTelemetry say it, read anew before each send
type Registrant ¶
type Registrant interface {
// Measures the feature takes of itself, read at every collection without waiting on anything: what is slow goes in their Read
Metrics() []Metric
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) Happenings ¶
Every kind of event the registrants tell of, in the order they were registered
func (*Registry) Host ¶
func (r *Registry) Host() *Monitoring
Host the registry is nested in, through which plugins tell of events and read how the export stands
func (*Registry) Register ¶
func (r *Registry) Register(registrant Registrant)
type Sample ¶
type Sample struct {
Labels []Pair
Value float64
// Of a histogram: how many values fell in each bucket, the last past every bound, their sum, and the least and most of them
Buckets []uint64
Bounds []float64
Sum float64
Low, Top float64
}
One point of a measure as it stands
type Send ¶
type Send struct {
Signal string
// Where it goes and by what protocol, as a person reads them
Where, Protocol string
// When the collector last took a send of it, and when one was last tried
Last, Tried time.Time
// Why the last try failed, empty once one went
Failure string
// Since the process started: sends that failed, and the items the collector took, refused, and those dropped unsent as their send
// failed for good
Failures int
Sent, Refused, Lost int64
}
How one signal goes to the collector, as the screen, the doctor and the report of the install say it
type Target ¶
type Target struct {
Signal string
// HTTP with protobuf, HTTP with JSON, or gRPC
Protocol string
// The web address a request over HTTP is posted to; over gRPC, the address it dials
Address string
// Over gRPC, the connection is not encrypted
Plain bool
// gzip or none
Compression string
// Headers each request carries, by name
Headers map[string]string
// The address as a person reads it, with no password or query
Shown string
// The address was not set, so the standard one of this computer is used
Standard bool
// Certificates of the requests, nil for those of this computer alone, and the files they were read from, which tell one set from another
TLS *tls.Config
// contains filtered or unexported fields
}
Where one signal goes and how
type Teller ¶
type Teller interface {
// Kinds of event it tells of
Happenings() []Happening
}
Registrant that tells of what happens to its feature, each event handed to the host's Tell as it happens
type Told ¶
type Told struct {
Name string
Severity Severity
Cause Cause
Labels []Pair
Values []Number
At time.Time
}
An event as it is kept: what its kind allows of what was told, nothing more
type Tried ¶
type Tried struct {
Signal string
// Where it went, as a person reads it, and by what protocol
Where, Protocol string
// The collector took it, else why not; or the settings leave the signal out, said in Skipped
Went bool
Said string
Skipped bool
// How long it took
Took time.Duration
}
What a test send of one signal came to
type Watcher ¶
type Watcher interface {
// Tells each change through tell until the context ends; runs in the monitoring service while icebath runs
Watch(ctx context.Context, tell func(Event))
}
Registrant that looks every while at how its feature stands and tells what changed since it last looked, such as the services that died or a chat app that lost its connection