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 |
Structs§
- Payload
- What a generated payload holds, for anchoring assertions.
Enums§
- Batch
- Per-run line composition: every line clean, every line feral, or a per-line clean-or-feral mix.
- Vibe
- Clean by-the-book output, or feral.
Constants§
- PAYLOAD_
BYTE_ LIMIT - Ceiling on a generated datagram, the Datadog Agent’s default
dogstatsd_buffer_size. A run caps each datagram to the smaller of this and the SUT’s sampled receive buffer, so a packed datagram always fits one read and the SUT never truncates a line mid-token.
Functions§
- sample_
vibe - Sample a per-line vibe, evenly, from
rng. - write_
line - Append one
DogStatsDline of a sampled type tobuf. When a line would exceedlimit_bytes, drop it whole rather than shear it, leavingbufunchanged. A non-empty line always ends in\n. - write_
payload - Pack whole
\n-terminated lines intobufuntil the next sampled line does not fit the space left underlimit_bytes. That overflowing line is dropped whole rather than sheared and ends the payload, so the packed datagram never exceedslimit_bytesand holds only whole lines. Each line takes its vibe frombatch, so aMixedpayload interleaves clean and feral lines. Clearsbuffirst.