stats

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package stats emits best-effort stats-me / statsd telemetry for the tommy CLI.

stats-me is upstream statsd packaged under Bun; clients publish by sending UDP datagrams in the statsd wire format to the daemon (see stats-me-clients(7) in the amarbel-llc/stats-me repo). There is no library API and no auth — anything that can write UDP can publish.

Emission is gated on the *presence* of the STATSD_HOST / STATSD_PORT environment variables that the stats-me home-manager module exports via home.sessionVariables. When neither is set every call is a no-op, so tommy never sprays UDP at a host that has not opted in. When at least one is present we follow the documented resolution order: STATSD_HOST (present-but-empty treated as loopback 127.0.0.1) and STATSD_PORT (default 8125).

UDP is fire-and-forget: any failure to resolve, dial, or send is swallowed. Telemetry must never perturb code generation. The mirror of piggy's crates/piggy/src/stats.rs (the reference implementation), adapted to Go and to the tommy.<op> namespace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Timed

func Timed(op string, f func() int) int

Timed runs f (a CLI subcommand handler returning its process exit code), emits a tommy.<op> counter (keyed by success/failure of the exit code) plus a duration timer, and returns the code so the caller can os.Exit it. The closure always runs; only the emit is gated on STATSD_*.

Types

type Outcome

type Outcome int

Outcome is the result of an operation, encoded into the metric name and a tag.

const (
	Success Outcome = iota
	Failure
)

func (Outcome) String

func (o Outcome) String() string

Jump to

Keyboard shortcuts

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