Skip to content

Add DirectHttpClient - #328

Merged
vickenty merged 4 commits into
masterfrom
vickenty/dhc
Aug 11, 2026
Merged

Add DirectHttpClient#328
vickenty merged 4 commits into
masterfrom
vickenty/dhc

Conversation

@vickenty

@vickenty vickenty commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

DirectHttpClient is a simple, single-threaded interface for sending pre-aggregated metrics, an equivalent of gaugeWithTimestamp and countWithTimestamp from regular dogstatsd, but also supports distributions.

To avoid data corruption when moving from one client to another, we still need to apply count to rate translation.

Main role for the client is to own separation between series and sketches, build payloads and route them to their respective endpoints in the core agent.

Users of this class are expected to have unique timeseries and submit one point per time series per payload (an iteration of user's reporting loop). For this reason we do not do any de-duplication or grouping of metrics, keeping the code simpler and faster. Duplicates and multiple points are not a correctness issue, and simply result in less efficient payloads.

DirectHttpClient is a simple, single-threaded interface for sending
pre-aggregated metrics, an equivalent of gaugeWithTimestamp and
countWithTimestamp from regular dogstatsd, but also supports
distributions.

To avoid data corruption when moving from one client to another, we
still need to apply count to rate translation.

Main role for the client is to own separation between series and
sketches, build payloads and route them to their respective endpoints
in the core agent.

Users of this class are expected to have unique timeseries and submit
one point per time series per payload (an iteration of user's
reporting loop). For this reason we do not do any de-duplication or
grouping of metrics, keeping the code simpler and faster. Duplicates
and multiple points are not a correctness issue, and simply result in
less efficient payloads.
@vickenty
vickenty marked this pull request as ready for review August 7, 2026 13:04
@vickenty
vickenty requested a review from a team as a code owner August 7, 2026 13:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1eb2b5f45

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +58 to +60
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Propagate interrupted sends instead of dropping payloads

When the supplied forwarder blocks and is interrupted, this catch makes PayloadBuilder.flushPayload() believe the send succeeded; it then clears the buffered payload, so flush() or an auto-flush can return with the thread interrupted but with metrics permanently dropped. This is reachable with the provided HTTP forwarder configured with WhenFull.BLOCK, where send() waits for queue space and throws InterruptedException; let the failure propagate or preserve the payload for retry instead of swallowing it here.

Useful? React with 👍 / 👎.

try {
forwarder.send(seriesUri, payload);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The codex comment seems valid. Is it intentional to continue with clearing the payload in the case that send() is interrupted and the payload is never enqueued?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Current behavior is definitely sub-optimal, although I'm not sure if propagating the exception to the caller would be any more helpful. Fortunately, thread interruption is not something that happens by itself, it has to be coded in, and isn't that common. I'll leave a note about this behavior and will revisit blocking mode later.

Base automatically changed from vickenty/dhu to master August 7, 2026 19:10
@vickenty
vickenty merged commit 5eec751 into master Aug 11, 2026
19 of 21 checks passed
@vickenty
vickenty deleted the vickenty/dhc branch August 11, 2026 10:35
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