-
Notifications
You must be signed in to change notification settings - Fork 26
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
Adds OTelTraceIdRatioBasedSampler #131
base: main
Are you sure you want to change the base?
Conversation
Package.swift
Outdated
.package(url: "https://github.com/slashmo/swift-w3c-trace-context.git", from: "1.0.0-beta.1"), | ||
//.package(url: "https://github.com/slashmo/swift-w3c-trace-context.git", from: "1.0.0-beta.1"), | ||
//.package(name: "swift-w3c-trace-context", path: "../swift-w3c-trace-context"), | ||
.package(url: "https://github.com/t089/swift-w3c-trace-context.git", branch: "trace-id-bytes"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see slashmo/swift-w3c-trace-context#18 for details on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR 🙏 It's a good addition to the package, thanks for also adding benchmarks 👍 I'll do a final review pass once we get the breaking change in W3C Trace Context merged. My comments so far have mostly been around formatting.
Sources/OTel/Tracing/Sampling/OTelTraceIdRatioBasedSampler.swift
Outdated
Show resolved
Hide resolved
Sources/OTel/Tracing/Sampling/OTelTraceIdRatioBasedSampler.swift
Outdated
Show resolved
Hide resolved
Tests/OTelTests/Tracing/Sampling/OTelTraceIdRatioBasedSamplerTests.swift
Outdated
Show resolved
Hide resolved
Tests/OTelTests/Tracing/Sampling/OTelTraceIdRatioBasedSamplerTests.swift
Outdated
Show resolved
Hide resolved
Sources/OTel/Tracing/Sampling/OTelTraceIdRatioBasedSampler.swift
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #131 +/- ##
==========================================
+ Coverage 99.00% 99.01% +0.01%
==========================================
Files 65 68 +3
Lines 1800 1831 +31
==========================================
+ Hits 1782 1813 +31
Misses 18 18 ☔ View full report in Codecov by Sentry. |
This adds a
OTelTraceIdRatioBasedSampler
(see Spec).The sampler takes the last 8 bytes of the
TraceID
and interprets them as a singleUInt64
value which is then used for the sampling decision. As long as those bytes are randomly distributed, this gives a deterministic, but random sampling decision.