Skip to content

Aggregated metrics can exceed WithMaxBytesPerPayload because extraSize omits trailing DogStatsD fields #368

@skang-figma

Description

@skang-figma

For aggregated metrics we do some calculation to determine how many values we can fit by calculating how much of the buffer would be occupied by metadata.

However, this calculation ignores additional metadata that can be appended on the metric:

appendContainerID — if getContainerID() is non‑empty: \|c: plus the full container ID length.
appendExternalEnv — if origin detection is on and env is set: \|e: plus env string length.
appendTagCardinality — if cardinality is set: \|card: plus e.g. low / high.
writeSeparator() — the trailing \n (1 byte).

As a result, the buffer length can exceed maxBytesPerPayload even though the per-float loop believed there was room. The client still sends the full UDP payload; the DogStatsd agent may only read the first N bytes (e.g. 8192), truncating the datagram and causing parse errors (e.g. malformed |c: / inode segments)

Non-aggregated metrics use validateNewElement and do not have this gap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions