Skip to content

Parse W3C traceparent into SpanContext#6496

Merged
mar-cf merged 1 commit into
mainfrom
mar/worker-tracing
Apr 8, 2026
Merged

Parse W3C traceparent into SpanContext#6496
mar-cf merged 1 commit into
mainfrom
mar/worker-tracing

Conversation

@mar-cf

@mar-cf mar-cf commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@ask-bonk

ask-bonk Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

TraceId(uint64_t low, uint64_t high) — so the constructor takes (low, high).

In fromTraceparent: TraceId(traceLow, traceHigh) ✓ — this matches the constructor signature.

The test verifies: result.getTraceId() == TraceId(0x9900aabbccddeeff, 0x1122334455667788) which is TraceId(low=0x9900aabbccddeeff, high=0x1122334455667788). And the input traceparent has trace-id 11223344556677889900aabbccddeeff, which has high=1122334455667788 and low=9900aabbccddeeff. This is consistent with toW3C(). Good, the byte ordering is correct.

Now let me do a final assessment. This is a well-implemented, well-tested parser. The code correctly:

  • Validates total length
  • Validates delimiter positions
  • Parses each field with proper hex validation
  • Rejects invalid versions, all-zero IDs, and unsampled traces
  • Has comprehensive tests covering edge cases

The only thing I'd consider flagging is that the function comment doesn't document the sampled-only behavior. But thinking about it more carefully — this is a minor doc improvement suggestion, not a real code issue. The function returns Maybe<SpanContext> which already signals it can return nothing, and the implementation is clear.

After thorough review, I don't find any actionable issues — no logic bugs, security issues, backward compat violations, memory safety problems, or incorrect API behavior.

LGTM

github run

@codecov-commenter

codecov-commenter commented Apr 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.49383% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.81%. Comparing base (1e952a5) to head (8269c49).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/workerd/io/trace-test.c++ 52.83% 0 Missing and 25 partials ⚠️
src/workerd/io/trace.c++ 75.00% 3 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6496      +/-   ##
==========================================
- Coverage   70.82%   70.81%   -0.01%     
==========================================
  Files         435      435              
  Lines      122491   122598     +107     
  Branches    19213    19259      +46     
==========================================
+ Hits        86753    86820      +67     
+ Misses      24373    24372       -1     
- Partials    11365    11406      +41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mar-cf mar-cf requested a review from jasnell April 7, 2026 18:03
@mar-cf mar-cf marked this pull request as ready for review April 7, 2026 18:03
@mar-cf mar-cf requested review from a team as code owners April 7, 2026 18:03
Comment thread src/workerd/io/trace.c++
Comment thread src/workerd/io/trace.c++ Outdated
Comment thread src/workerd/io/trace.h Outdated
@mar-cf mar-cf force-pushed the mar/worker-tracing branch from c71cc3c to 0974dd2 Compare April 8, 2026 14:40
@mar-cf mar-cf force-pushed the mar/worker-tracing branch from 0974dd2 to 8269c49 Compare April 8, 2026 16:14
@mar-cf mar-cf merged commit a3a29b0 into main Apr 8, 2026
22 checks passed
@mar-cf mar-cf deleted the mar/worker-tracing branch April 8, 2026 16:51
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.

3 participants