RUM-8051: Implement Head-based sampling for network instrumentation #2483
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 does this PR do?
This PR implements Head-based sampling for the network instrumentation to align with default sampling existing in other Datadog tracers.
In short, Head-based sampling (HBS) allows to have a single sampling decision for the whole trace: it is kept or dropped, instead of the individual spans.
This also aligns with the following changes in iOS SDK done in the past:
Now, if there is a parent span (propagated through the headers or via request tag; OpenTracing or OpenTelemetry), then its sampling decision will be taken into account instead of the sampling decision made by the network instrumentation.
If there is no parent tracing context for the incoming request, then sampling decision will be made by interceptor.
The necessary integration tests are added, they uncovered some issues we had with trace propagation.
Also this PR bring the following change: spans with
DROP
sampling decision are not written, they are rejected by the intake anyway, so it makes no sense to send them.Review checklist (to be filled by reviewers)