Skip to content

Add dogstatsd-http-serializer#298

Open
vickenty wants to merge 3 commits intomasterfrom
vickenty/dhs
Open

Add dogstatsd-http-serializer#298
vickenty wants to merge 3 commits intomasterfrom
vickenty/dhs

Conversation

@vickenty
Copy link
Contributor

@vickenty vickenty commented Mar 6, 2026

Add serializer implementation for new Dogstatsd HTTP-based protocol (for the server code, see DataDog/datadog-agent#45445).

This is more or less a verbatim translation of the intake v3 payload serializer), No compression is implemented, since payloads are expected to be sent primarily via the loopback interface. This the implementation a bit simpler, since only one payload size limit need to be observed.

The main entry point is in the PayloadBuilder class, and together with Metric, ScalarMetric and SketchMetric classes it defines the public API. PayloadConsumer is used to stream A set of Buffer classes provide growable arrays of primitives.

@vickenty vickenty force-pushed the vickenty/dhs branch 2 times, most recently from 014aa77 to e2955bd Compare March 6, 2026 12:43
@vickenty vickenty marked this pull request as ready for review March 6, 2026 12:53
@vickenty vickenty requested a review from a team as a code owner March 6, 2026 12:53
To avoid numeric stability issues when computing it as sum/cnt.
Copy link

@StephenWakely StephenWakely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Just have some very minor nits.

Another thought I had is, would it be a good idea to embed a version number into the payload. Or will we rely on the agent providing different endpoints for each version?

* @return Builder instance.
*/
public ScalarMetric count(String name) {
ScalarMetric m = new ScalarMetric(this, 1, name);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to define the type as constants. It's not immediately apparent what the number 1 means here.

}

void beginMetric(Metric m) {
endMetric();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a metric in progress at this stage, it would likely be because of a programmer error? Shouldn't we fail harder here so the error isn't overlooked?

* @param name Name of the metric.
* @return New builder instance.
*/
public SketchMetric sketch(String name) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question, histograms and distributions have gone from the code, are they replaced by Sketches? Will this be deprecating histograms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not deprecating histograms, they are just not supported in this first version.

Sketches is the data type underpin dogstatsd distributions in the agent. Much like it happens in the agent, an aggregation component will be converting distribution samples into sketches (that this code will then serialize).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants