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

Prototype for W3C Trace Context Level 2 support in TraceIDRatioBased sampler #5645

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

jmacd
Copy link
Contributor

@jmacd jmacd commented Jul 25, 2024

This is a prototype implementation for changes to the TraceIDRatioBased sampler based on W3C Trace Context Level 2 which includes support for trace randomness.

This is a combined prototype for the SDK-relevant portions of open-telemetry/opentelemetry-specification#4162 and open-telemetry/opentelemetry-specification#4166.

Copy link

codecov bot commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.5%. Comparing base (2a454a7) to head (36a41d9).
Report is 9 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff           @@
##            main   #5645    +/-   ##
======================================
  Coverage   84.4%   84.5%            
======================================
  Files        272     272            
  Lines      22506   22679   +173     
======================================
+ Hits       19017   19166   +149     
- Misses      3153    3172    +19     
- Partials     336     341     +5     

see 8 files with indirect coverage changes

// 0x1.ffffffffffffe0p-01
// 0x0.fffffffffffff0p+00
// math.Nextafter(1.0, 0.0)
maxSupportedProbability float64 = 1 - 0x1p-52
Copy link

Choose a reason for hiding this comment

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

The name maxSupportedProbability could be misleading here, as consistent sampling naturally also supports sampling with a probability of 1.

@pellared
Copy link
Member

pellared commented Aug 1, 2024

Do we have some benchmarks that would demonstrate the overhead of the added randomness support? Can we add benchstat results?

Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

just a couple of very small comments


// The update is expected to be a single key-value of the form
// `XX:value` for with two-character key.
upkey := updated[:colonOffset]
Copy link
Member

Choose a reason for hiding this comment

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

I see that this is guaranteed to have a th: prefix in the current code, but do you think it would be worth having a sanity check to future-proof it?

// in `otts` which is the OTel tracestate value (i.e., the top-level "ot" value).
func tracestateHasRandomness(otts string) (randomness uint64, hasRandom bool) {
var low int
if has := strings.HasPrefix(otts, "rv:"); has {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if has := strings.HasPrefix(otts, "rv:"); has {
if strings.HasPrefix(otts, "rv:") {

if incoming == "" {
return updated
}
var out strings.Builder
Copy link
Member

Choose a reason for hiding this comment

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

this might be clearer later, but can the final size be determined at this point already?

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

Successfully merging this pull request may close these issues.

4 participants