Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tracing): ensure sampling rate applies to whole trace #11135

Merged
merged 2 commits into from
Jun 29, 2023

Conversation

samugi
Copy link
Contributor

@samugi samugi commented Jun 27, 2023

Summary

This commit fixes a bug where the sampling rate was applied to individual spans.

Problem: when sampling_rate is < 1 and the root span is not sampled, children (that are sampled) are reported without a parent so traces are split (producing multiple traces with different trace IDs for a single request).

The fix ensures that the sampled flag that is calculated by the sampler for the root span is propagated to all children in the same trace.

Checklist

Full changelog

  • [Implement ...]

Issue reference

KAG-1926

@samugi samugi force-pushed the fix/sampling-rate-individual-spans branch from f8f1246 to 125eb3a Compare June 28, 2023 07:43
Copy link
Contributor

@StarlightIbuki StarlightIbuki left a comment

Choose a reason for hiding this comment

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

Basically OK.

kong/pdk/tracing.lua Outdated Show resolved Hide resolved
kong/pdk/tracing.lua Show resolved Hide resolved
spec/02-integration/14-tracing/03-tracer-pdk_spec.lua Outdated Show resolved Hide resolved
This commit fixes a bug where the sampling rate was applied to
individual spans, so configuring values of sampling_rate < 1 would
sometimes result in split traces being reported.

The fix ensures that the sampled flag that is calculated by the sampler
for the root span is propagated to all children within the same trace.
@samugi samugi force-pushed the fix/sampling-rate-individual-spans branch from 49040b7 to 9d45e72 Compare June 29, 2023 09:45
@samugi samugi merged commit cee8965 into master Jun 29, 2023
20 checks passed
@samugi samugi deleted the fix/sampling-rate-individual-spans branch June 29, 2023 13:54
@team-gateway-bot
Copy link
Collaborator

The backport to release/3.3.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-release/3.3.x release/3.3.x
# Navigate to the new working tree
cd .worktrees/backport-release/3.3.x
# Create a new branch
git switch --create backport-11135-to-release/3.3.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 cee8965e3e270e481d390f64a4960dcb5824ff63
# Push it to GitHub
git push --set-upstream origin backport-11135-to-release/3.3.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-release/3.3.x

Then, create a pull request where the base branch is release/3.3.x and the compare/head branch is backport-11135-to-release/3.3.x.

kikito pushed a commit that referenced this pull request Sep 26, 2023
* fix(tracing): ensure sampling rate applies to whole trace

This commit fixes a bug where the sampling rate was applied to
individual spans, so configuring values of sampling_rate < 1 would
sometimes result in split traces being reported.

The fix ensures that the sampled flag that is calculated by the sampler
for the root span is propagated to all children within the same trace.

* fix(tracing): suggestions + propagation test
samugi added a commit that referenced this pull request Sep 27, 2023
* fix(tracing): ensure sampling rate applies to whole trace

This commit fixes a bug where the sampling rate was applied to
individual spans, so configuring values of sampling_rate < 1 would
sometimes result in split traces being reported.

The fix ensures that the sampled flag that is calculated by the sampler
for the root span is propagated to all children within the same trace.

* fix(tracing): suggestions + propagation test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants