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

tracer: Refactor span context's TraceID to be a full [16]byte #1822

Merged
merged 5 commits into from
Mar 24, 2023

Conversation

ajgajg1134
Copy link
Contributor

@ajgajg1134 ajgajg1134 commented Mar 22, 2023

What does this PR do?

Refactor the spancontext traceID to be a [16]byte instead of a uint64. This is a marginal memory gain over storing the upper bits as a hex string at a slight cost of possibly needing to hex-encode more frequently.

Motivation

It's confusing to have the trace id split up across fields and as different types, it led to odd looking code occasionally where some bits of the ID would need to be encoded or decoded for the use-case at hand. I believe this refactor is an improvement in readability, although admittedly this code is still a bit confusing. Notably newContext as the span type can't be changed as it's exactly marshalled to the agent in its current form.

Describe how to test/QA your changes

The unit tests, system tests, parametric tests should sufficiently cover this refactor I believe, but given this touches a critical component of the tracer we may want to be extra diligent during release testing to ensure there's no breakages here.

Reviewer's Checklist

  • If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • Changed code has unit tests for its functionality.
  • If this interacts with the agent in a new way, a system test has been added.

@ajgajg1134 ajgajg1134 changed the title Andrew.glaude/trace id type tracer: Refactor span context's TraceID to be a full [16]byte Mar 22, 2023
@ajgajg1134 ajgajg1134 changed the base branch from main to shared/128-bit March 22, 2023 19:33
@ajgajg1134
Copy link
Contributor Author

I verified the failing parametric test is also failing for shared/128 branch so is unrelated to this refactor (and seems like a known bug in W3C textmap parsing?)

context.trace = parent.trace
context.origin = parent.origin
context.errors = parent.errors
parent.ForeachBaggageItem(func(k, v string) bool {
context.setBaggageItem(k, v)
return true
})
} else if sharedinternal.BoolEnv("DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED", false) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This happens in tracer.go StartSpan now

@ajgajg1134 ajgajg1134 marked this pull request as ready for review March 23, 2023 20:00
@ajgajg1134 ajgajg1134 requested a review from a team March 23, 2023 20:00
ddtrace/tracer/spancontext.go Outdated Show resolved Hide resolved
ddtrace/tracer/textmap.go Show resolved Hide resolved
ddtrace/tracer/textmap_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/textmap_test.go Outdated Show resolved Hide resolved
ddtrace/tracer/textmap_test.go Outdated Show resolved Hide resolved
ajgajg1134 and others added 2 commits March 23, 2023 16:51
Co-authored-by: Katie Hockman <katie@hockman.dev>
@katiehockman katiehockman modified the milestones: Triage, v1.49.0 Mar 24, 2023
Copy link
Contributor

@knusbaum knusbaum left a comment

Choose a reason for hiding this comment

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

🥇

@ajgajg1134 ajgajg1134 merged commit cc19fcf into shared/128-bit Mar 24, 2023
@ajgajg1134 ajgajg1134 deleted the andrew.glaude/TraceIDType branch March 24, 2023 17:22
katiehockman pushed a commit that referenced this pull request Mar 27, 2023
* WIP: more refactoring, still broken tests though
* Even more bug fixes
* Update ddtrace/tracer/spancontext.go
* PR Comments: use strconv.ParseUint instead of hex.Decode since it can handle odd length strings
Co-authored-by: Katie Hockman <katie@hockman.dev>
katiehockman pushed a commit that referenced this pull request Mar 28, 2023
* WIP: more refactoring, still broken tests though
* Even more bug fixes
* Update ddtrace/tracer/spancontext.go
* PR Comments: use strconv.ParseUint instead of hex.Decode since it can handle odd length strings
Co-authored-by: Katie Hockman <katie@hockman.dev>
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.

None yet

3 participants