Expand description
DogStatsD payload generation.
Dogstatsd is three message types: metric, event, service check.
§Metrics
<NAME>:<VALUE>|<TYPE>|@<SAMPLE_RATE>|#<TAG>,<TAG>...|c:<CONTAINER>|T<TS>|e:<EXT>|card:<CARD>
Required: <NAME>:<VALUE>|<TYPE>.
<NAME> := [^:|\n]+
<VALUE> := <NUMBER>(:<NUMBER>)* ':'-packed multi-value, non-set
| [^|\n]+ raw string, set type
<NUMBER> := [+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)? | [+-]?(inf|infinity|nan)
<TYPE> := c|g|ms|h|s|d count gauge timer histogram set distribution
<SAMPLE_RATE> := @<NUMBER>
<TAG> := [^,|\n]+ conventionally <KEY>:<VALUE>, the ':' is not required
<CONTAINER> := c:[^|\n]+ e.g. ci-<id>, in-<inode>
<TS> := T\d+ unix seconds
<EXT> := e:[^|\n]+ e.g. it-,cn-,pu-
<CARD> := card:[^|\n]+ recognized: none|low|orchestrator|high§Events
_e{<TITLE_LEN>,<TEXT_LEN>}:<TITLE>|<TEXT>|d:<TS>|h:<HOST>|k:<AGGKEY>|p:<PRIO>|s:<SRC>|t:<ALERT>|#<TAGS>
Required: _e{<TITLE_LEN>,<TEXT_LEN>}:<TITLE>|<TEXT>. c: / e: / card: are valid here too.
<TITLE_LEN>,<TEXT_LEN> := \d+ byte length of TITLE / TEXT
<TITLE>,<TEXT> := [^\n]{LEN} length-delimited, so '|' and ':' are allowed
<TS> := d:\d+ unix seconds
<HOST> := h:[^|\n]+
<AGGKEY> := k:[^|\n]+
<PRIO> := p:[^|\n]+ recognized: normal|low (else default)
<SRC> := s:[^|\n]+
<ALERT> := t:[^|\n]+ recognized: error|warning|info|success (else default)
<TAGS> := #<TAG>(,<TAG>)*§Service checks
_sc|<NAME>|<STATUS>|d:<TS>|h:<HOST>|#<TAG>,<TAG>...|m:<MESSAGE>
Required: _sc|<NAME>|<STATUS>. c: / e: / card: are valid here too.
<NAME> := [^|\n]+
<STATUS> := [0-3] OK warning critical unknown
<TS> := d:\d+ unix seconds
<HOST> := h:[^|\n]+
<TAGS> := #<TAG>(,<TAG>)*
<MESSAGE> := m:[^|\n]+§Name combinatorics
A clean name is c segments from COMPLIANT_WORD (10 words) joined by
NAME_SEPARATORS (4). Distinct names at count c: 10^c · 4^(c-1). c is
sampled by vibe: clean draws from ELEMENT_COUNTS_CLEAN (a small body, no
boundary cases); feral draws from ELEMENT_COUNTS_FERAL, which adds the 0
and large boundary counts as a tail.
c | P(c) clean | P(c) feral | distinct names |
|---|---|---|---|
| 0 | — | 1/12 | 1 (empty) |
| 1-3 | 6/9 | 6/12 | 10 .. ~16e3 |
| 4-6 | 3/9 | 3/12 | ~640e3 .. ~1e9 |
| 127 | — | 1/12 | ~10^203 |
| 255 | — | 1/12 | ~10^408 |
Enums§
- Vibe
- Clean by-the-book output, or feral.
Functions§
- sample_
vibe - Sample a per-line vibe, evenly.
- send
- Write one
DogStatsDmessage of a sampled type tobufat the given vibe. Returns the packed value count when a multi-value metric was emitted, elseNone.