Module dogstatsd

Module dogstatsd 

Source
Expand description

DogStatsD datagram packing from one pull of pooled contexts.

A driver pulls a set of Contexts from the shared intake pool, crate::contexts, once per invocation and reuses it for every datagram it sends. Each datagram is a fresh per-occurrence render of as many of those contexts as fit, and the rest are dropped. Identities recur because the pool is bounded, while their load varies per render. There is no clean/feral/mixed configuration. The legal space is exactly the set of payloads crate::dogstatsd::is_malformed accepts.

Whether a datagram carries a non-UTF-8 byte is settled by the pull, before the driver sees the contexts. The intake puts such a context in a fixed fraction of pulls, and a pull holding one leads every datagram with it, so the fraction of datagrams carrying the byte is the fraction of pulls that do. Nothing here depends on how many contexts a timeline sampled, which is what makes the rate hold for a pull of one as well as a pull of a thousand.

metric:        <NAME>:<VALUE>(:<VALUE>)*|<TYPE>[|@<RATE>][|#<TAGS>][|c:..][|e:..][|card:..]
event:         _e{<TITLE_LEN>,<TEXT_LEN>}:<TITLE>|<TEXT>[|opt...]|d:<TS>[|#<TAGS>]
service check: _sc|<NAME>|<STATUS>[|opt...]|d:<TS>[|#<TAGS>]|m:<MESSAGE>

Structs§

DatagramStats
What a generated datagram holds, for anchoring assertions.
Pull
One pull of contexts, held for a driver invocation and packed into every datagram it sends.

Constants§

DATAGRAM_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§

write_datagram
Pack one \n-terminated line per context into buf, within limit_bytes, until the room left cannot hold the smallest context in the pull. Each line is a fresh per-occurrence render against the room left, so nothing is built and then thrown away, and a context whose line will not fit is passed over. Clears buf first.