feat(sampling): OTel consistent-probability rv/th derivation (APMAPI-2181) - #2276
Draft
MilanGarnier wants to merge 5 commits into
Draft
feat(sampling): OTel consistent-probability rv/th derivation (APMAPI-2181)#2276MilanGarnier wants to merge 5 commits into
MilanGarnier wants to merge 5 commits into
Conversation
Contributor
📚 Documentation Check Results📦
|
Contributor
🔒 Cargo Deny Results📦
|
Contributor
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 84414e8 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksComparisonCandidateCandidate benchmark detailsBaselineBaseline benchmark details |
Contributor
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
Compute th as round(2^56*(1-rate)) via 2^56 - round(2^56*rate) (exact, avoids the single-shot IEEE-754 rounding the RFC warns against), and return None from otel_consistent_sampling when a probability keep was overturned by the trace rate limiter (rl_effective_rate set).
Use exact integer arithmetic over the canonical 6-decimal rate (the form format_sampling_rate / dd= already use) so th reproduces the RFC imprecision-appendix's decimal table (0.2 -> cccccccccccccd, 0.99 -> 028f5c28f5c28f), which an f64 pipeline cannot represent.
…consistent_sampling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the public API dd-trace-* tracers (and libdatadog's own OTLP path) need to
emit OpenTelemetry consistent-probability-sampling tracestate (
ot.th/ot.rv).Part of APMAPI-2170 (OTel consistent probability sampling across dd-trace-*).
First consumer: APMAPI-2181 (dd-trace-rs
ot.th/ot.rvwire support);libdatadog's OTLP export (APMAPI-2182) will reuse the same derivation.
Changes
SamplingMechanism::is_probability()— classifies rate-driven mechanisms(DEFAULT, AGENT_RATE_BY_SERVICE, REMOTE_RATE{,_USER,_DATADOG}, the three
*_TRACE_SAMPLING_RULErules) as probability; MANUAL / APPSEC /SPAN_SAMPLING_RULE / DATA_JOBS_MONITORING / OTLP_INGEST_PROBABILISTIC_SAMPLING
as non-probability.
OtelConsistentSampling { rv, th }+TraceRootSamplingInfo::otel_consistent_sampling(trace_id)— returnsSomeonly for a probability decision:
rv = (!(trace_id_low64 * KNUTH_FACTOR)) >> 8(56-bit),th = round(2^56 * (1 - rate_micros / 1_000_000))(56-bit), computed inexact
u128integer arithmetic on the rate rounded to 6 decimals so itmatches the RFC appendix's imprecision table rather than a float
(1.0 - rate) * 2^56. ReturnsNone— erasingthon the wire — both fora non-probability mechanism and for a probability mechanism whose keep was
overturned by the rate limiter (
rl_effective_rate.is_some()); the callerstill forwards an inherited
rvin the latter case. Wire/hex formattingstays tracer-side.
Tests
Golden vectors from system-tests #7372 (rv per trace id; th per the RFC's
exact decimal table at several rates, e.g. 0.01/0.1/0.2/0.5/0.99/1.0;
non-probability -> None; rate-limiter-dropped probability decision -> None).
cargo test -p libdd-sampling: 106 lib + 2 doctests pass. Draft pending thecrate release that dd-trace-rs will pin to.