|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
The StatsD metrics client: one metric line per UDP datagram. More...
#include "protocore_config.h"Go to the source code of this file.
The StatsD metrics client: one metric line per UDP datagram.
No formal specification governs StatsD. It is a line protocol that originated at Etsy, and the only description of it is the reference implementation's own documentation, github.com/statsd/statsd README.md and docs/metric_types.md. There is no IETF RFC for it, and no OASIS, OMG, W3C, CNCF or Eclipse document defines it. The names below are that documentation's own.
docs/metric_types.md gives the line as <metricname>:<value>|<type> and names four types:
Counting gorets:1|c "Add 1 to the 'gorets' bucket." Sampling gorets:1|c|@0.1 "this counter is being sent sampled every 1/10th of the time" Timing glork:320|ms "The glork took 320ms to complete this time." Gauges gaugor:333|g "will maintain its value until it is next set" Sets uniques:765|s "counting unique occurrences of events between flushes"
The sample rate is the counter's and the timer's: "The field is optional and defaults to 1." A signed gauge value adjusts instead of assigning, gaugor:-10|g then gaugor:+4|g taking 333 to
README.md: "Each stat is in its own 'bucket'. They are not predefined anywhere", and its example names 8125 as the port the reference daemon listens on.The |#k:v,k2:v2 tail is not Etsy's. It is DogStatsD, Datadog's extension, whose datagram format is <METRIC_NAME>:<VALUE>|<TYPE>|@<SAMPLE_RATE>|#<TAG_KEY_1>:<TAG_VALUE_1>,<TAG_2> and whose tag field is "A comma separated list of strings. Use colons for key/value tags (`env:prod`)". A daemon that does not speak it ignores the field.
The daemon address and the tag list every metric carries are copied into fixed storage by an init, so nothing a caller passes has to outlive the call. Values are rendered by hand and the line is assembled into storage, so a metric costs no heap and nothing lands on a task stack.
The module exports one symbol, Statsd. Everything in statsd.c has internal linkage.
Definition in file statsd.h.