Repository navigation
feat(tracing): declare 100% sampling (ot=th:0) on every span - #52
Merged
Merged
Conversation
Every span now carries the OpenTelemetry sampling threshold th:0 in its tracestate, so a backend can tell a complete trace stream from a sampled one. A consumer that is deliberately missing then reads as missing, not unsampled. AB#3317 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… (errcheck) AB#3317 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ETWOYA
approved these changes
Sep 18, 2026
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 changed
Every span Snowglobe emits now carries the W3C tracestate entry
ot=th:0: the OpenTelemetry probability-sampling threshold of zero, which means nothing was sampled away.declaredFullSampler(cmd/snowglobe/sampler.go): records and samples every span, which is what the default sampler already did, and writesot=th:0into the span's tracestate. It starts from the parent's tracestate, keeps otherotsub-keys (such asrv) and every other vendor's entry, and movesotto the front as W3C requires for a modified member.newProvider(cmd/snowglobe/main.go): each service instance's tracer provider uses the new sampler.Why
A backend cannot tell a complete trace stream from a sampled one unless the stream says so. With the threshold declared, a span that is missing on purpose (for example, a consumer that never ran) reads as genuinely missing rather than as possibly unsampled.
Tests
New tests cover root spans, child spans (including a child started from a different tracer provider using the parent's context), existing vendor entries (
foo=barbecomesot=th:0,foo=bar), existingotvalues (rv:abc123becomesth:0;rv:abc123,th:8becomesth:0), and that every span in a run is still recorded and sampled.go vet ./...is clean andgo test ./...passes.AB#3317
🤖 Generated with Claude Code