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 tail-based sampling discarding low throughput and low sample rate traces #11642

Merged
merged 5 commits into from
Sep 14, 2023

Conversation

carsonip
Copy link
Member

@carsonip carsonip commented Sep 13, 2023

Motivation/summary

In tail-based sampling, use math.ceil instead of math.Round when computing desired total such that on low throughput and low sample rate traces e.g. throughput=1, sample rate = 0.4, desired total = math.Ceil(1 * 0.4) = 1 as opposed to 0 when using math.Round. This will fix cases where these traces were missing before the fix.

Checklist

For functional changes, consider:

  • Is it observable through the addition of either logging or metrics?
  • Is its use being published in telemetry to enable product improvement?
  • Have system tests been added to avoid regression?

How to test these changes

Enable TBS, set sample rate to 0.4, send 1 trace. Check if the trace shows up.

Related issues

Closes #11372

@carsonip carsonip added the backport-8.10 Automated backport with mergify label Sep 13, 2023
@@ -224,7 +224,7 @@ func (g *traceGroup) finalizeSampledTraces(traceIDs []string, ingestRateDecayFac

// Resize the reservoir, so that it can hold the desired fraction of
// the observed ingest rate.
newReservoirSize := int(math.Round(g.samplingFraction * g.ingestRate))
newReservoirSize := int(math.Ceil(g.samplingFraction * g.ingestRate))
Copy link
Member Author

Choose a reason for hiding this comment

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

[For reviewer] I don't think this is needed for the fix to work, and that we have a min size. But might be good to be consistent and use math.Ceil in all samplingFraction multiplication.

@carsonip carsonip requested a review from axw September 13, 2023 16:48
@carsonip carsonip marked this pull request as ready for review September 13, 2023 16:49
@carsonip carsonip requested a review from a team as a code owner September 13, 2023 16:49
Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

LGTM, thank you

@carsonip carsonip merged commit b0e8925 into elastic:main Sep 14, 2023
15 checks passed
mergify bot pushed a commit that referenced this pull request Sep 14, 2023
… traces (#11642)

In tail-based sampling, use math.ceil instead of math.Round when computing desired total such that on low throughput and low sample rate traces e.g. throughput=1, sample rate = 0.4, desired total = math.Ceil(1 * 0.4) = 1 as opposed to 0 when using math.Round. This will fix cases where these traces were missing before the fix.

(cherry picked from commit b0e8925)

# Conflicts:
#	changelogs/head.asciidoc
mergify bot added a commit that referenced this pull request Sep 14, 2023
… traces (#11642) (#11644)

In tail-based sampling, use math.ceil instead of math.Round when computing desired total such that on low throughput and low sample rate traces e.g. throughput=1, sample rate = 0.4, desired total = math.Ceil(1 * 0.4) = 1 as opposed to 0 when using math.Round. This will fix cases where these traces were missing before the fix.

(cherry picked from commit b0e8925)

# Conflicts:
#	changelogs/head.asciidoc

Co-authored-by: Carson Ip <carsonip@users.noreply.github.com>
@lahsivjar lahsivjar self-assigned this Oct 24, 2023
@lahsivjar
Copy link
Contributor

lahsivjar commented Oct 24, 2023

Tested successfully on BC3 by enabling TBS with a low sample rate and sending a single trace, the trace was indexed successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tail-based sampling discards all traces when sampling rate and throughput are low
4 participants