Documentation
¶
Overview ¶
Package metricspush starts the OpenTelemetry SDK and an OTLP/JSON exporter that send a proxy's metrics to the central collector (R15). It is the only package that imports the SDK, so the metrics package stays API-only. Each proxy holds its own copy of this setup: the URL, the token and the exporter are settings of the host, not of the accountant.
The push is asynchronous (R16). The SDK aggregates in its own memory and exports from its own goroutine. A recording call never waits for the collector, and a failed push loses no count: the next push carries the totals (R20).
Index ¶
Constants ¶
const (
DefaultInterval = 30 * time.Second
)
Defaults.
Variables ¶
This section is empty.
Functions ¶
func MachineID ¶
MachineID returns the random ID of this install (R43). It is made once and kept in path, so it survives a restart. It is random on purpose: it holds no host name, no user name and no address, so it names an install and nobody.
If path is empty or cannot be written, MachineID returns a fresh ID for this run and the error. The push still works. The same machine then shows up as a new `machine` value after each restart, which is a small, bounded cost.
Types ¶
type Config ¶
type Config struct {
// URL is the collector base URL. There is no default: with no URL, Start logs one warning and
// makes no connection.
URL string
// Token is the per-install access token, sent as a bearer token (R44).
Token string
// Interval is the time between pushes. Zero means DefaultInterval.
Interval time.Duration
// Disabled turns the push off. The proxy then makes no connection (R19).
Disabled bool
// Resource attributes (R30, R43). The collector turns them into the labels proxy and machine.
Proxy string // "cortex" or "context-guru"
Machine string // random install ID
Version string
Preset string
// Logger receives the one start line and the first failure of a run. Nil means slog.Default().
Logger *slog.Logger
}
Config is what a proxy gives Start.
type Shutdown ¶
Shutdown flushes the last totals and stops the exporter. Give it a short timeout.