Repository navigation
Add a DDSketch-compatible distribution for telemetry - #401
Conversation
BenchmarksBenchmark execution time: 2026-11-24 11:16:04 Comparing candidate commit 14bdff6 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 8 metrics, 0 unstable metrics.
|
4073956 to
0e9a6be
Compare
Raw distribution payloads grow with traffic. Like libdatadog, telemetry will send DDSketches instead. This adds the sketch; it is not wired in.
0e9a6be to
38c49d5
Compare
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
More details
The static review identified no actionable defects in bin mapping, range collapsing, or DDSketch protobuf encoding. Syntax checks passed, but runtime behavior remains unverified by test execution.
🤖 Bits Code Review · Commit 38c49d5
xlamorlette-datadog
left a comment
There was a problem hiding this comment.
Impressive work!
Review showed three parts that cost something and gave nothing back. The sketch's own mutex was redundant: its only user, a distribution handle's store, already locks around every call. The clamp for values below a full range only helps when one series spans more than a factor of 6e13, which no metric does, and it slowed the usual case on x86. The empty negative store was copied from libdatadog, but neither the DDSketch protobuf definition nor the intake needs it. The other changes are for readability: full names, a single copy of the bit-cast helpers, named protobuf wire types and a const count_at(). The tests now cover a negative bin, and the exactness checks on random values run ten times fewer values, since a separate test already checks every bin edge.
There was a problem hiding this comment.
Reusing a moved-from sketch can access an empty bin array. If a higher sample triggers both bin collapse and window growth, an allocation failure can silently discard samples that were already recorded.
🤖 Bits Code Review · Commit 0ee78e0
Removes the lookup table.
The class was renamed to LogBinnedDistribution in review, to use full words. The files kept the short log_binned_distr name, so they no longer matched the class they hold. They now do.
The implicit move took the counts vector but left the source's range behind. Recording into the source or encoding it then read past the end of an empty vector. The move now takes every member and resets the source to an empty sketch, as review suggested. Making a move fall back to a copy would also have kept the source valid, but every move would then allocate and copy up to 32 KiB of counts, and could throw. The move constructor goes through the move assignment, so the members are listed only once.
When a high value merged the lowest bins and also needed a larger window, the merged bins were zeroed before the new window was allocated. If that allocation threw and the caller caught it, the counts were gone, and later encodes silently left them out. Now the merged counts are summed first, the window grows, and only then are the merged bins cleared. The window growth is the only step that can throw, and it changes nothing until its new vector exists, so a failed record() leaves the sketch as it was. The test replaces the global operator new to fail on demand, only while a flag is set.
|
@xlamorlette-datadog the only open thread is now #401 (comment) PTAL |
There was a problem hiding this comment.
The global delete overrides in the test allocator are mismatched with how Catch2 allocates (e.g., new(std::nothrow)), causing both an ASan alloc-dealloc-mismatch at runtime and a -Wmismatched-new-delete build failure under GCC at -O2 with -Werror; matching nothrow overrides or scoping the injection are needed to fix both.
🤖 Bits Code Review · Commit dcf0478
Overview
Adds
LogBinnedDistr, a DDSketch-compatible distribution, and its protobuf encoding. Nothing uses it yet.Motivation
The goal is to let nginx-datadog send some AppSec distribution metrics, such as
appsec.waf.durationandappsec.instrum.body_size. The AppSec telemetry spec asks for these only through sketches. A rawdistributionspayload carries every point, so its size grows with traffic.libdatadog made the same change in DataDog/libdatadog#268: it removed the
distributionspayload in favor ofsketches("Distributions should be replaced by sketches"). This class is meant to replacedistributionshere too. A follow-up PR will maketelemetry::distribution::addrecord into a sketch and send asketchespayload.Additional Notes
binCountsform. libdatadog usescontiguousBinCounts. Both are valid DDSketch protobuf../build/test/tests '[log_binned_distr]': all 13 test cases pass; so does the full suite.References
Jira ticket: APPSEC-70954
Contributor Checklist