Repository navigation
[WO-1579] Support OpenTelemetry attribute arrays in user tracing spans - #7427
Conversation
|
I'm Bonk, and I've done a quick review of your PR. Adds OpenTelemetry-compatible primitive arrays to user tracing span attributes.
|
8641eb9 to
72430ce
Compare
dea622c to
2333e5a
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7427 +/- ##
==========================================
+ Coverage 67.64% 67.68% +0.04%
==========================================
Files 880 880
Lines 221875 222407 +532
Branches 33220 33357 +137
==========================================
+ Hits 150080 150540 +460
- Misses 52146 52176 +30
- Partials 19649 19691 +42 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
c0bed9e to
5b76150
Compare
There was a problem hiding this comment.
Superseded by the review of
02915b06.
This review, of 5b761503
💬 Approved with comments — The implementation is careful and well tested. One non-blocking WARNING: the change to how array inputs are handled should have its compatibility decision recorded in the commit message.
Findings: 1 warning (1 is an inline comment on the diff)
Not opened by the correctness review: 4 changed files it was meant to read
types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] Arrays passed to setAttribute/setAttributes are no longer stringified but validated or dropped; the commit message does not record the compatibility decision. Carried as a non-blocking WARNING: @jmorrell-cloudflare [author] says this cannot be observed from user code, and the code supports that apart from tail-stream output.
- **File:** src/workerd/api/tracing.c++:136
📋 Code Quality: ⚠️ 1 warning
The array attribute support looks correct; the compatibility decision for arrays that used to be stringified is not recorded.
Recommendation: 📝 Minor Comments
- [WARNING] Arrays passed to setAttribute/setAttributes are no longer stringified but validated or dropped; the commit message does not record the compatibility decision. Carried as a non-blocking WARNING: @jmorrell-cloudflare [author] says this cannot be observed from user code, and the code supports that apart from tail-stream output. (
src/workerd/api/tracing.c++:136)
View full review
Arrays that used to be stringified are now handled differently (src/workerd/api/tracing.c++:136-147)
setAttribute and setAttributes used to take jsg::Optional<TagValue>, which made Web IDL coercion turn any array into a string: ['a','b'] became "a,b" and [{}] became "[object Object]". Now every array goes through toAttributeValue():
- A valid homogeneous array is stored as a real array.
- A mixed, nested or object array is dropped with a warning.
- An array longer than 512 elements is dropped.
The author says on the thread that user code cannot see this: span attributes cannot be read back, and no public tail worker consumes spans yet. That reasoning is plausible. Still, the values do reach tail-stream output (the instrumentation tests in this pull request check them there). The repository's backward-compatibility rules ask that the decision be recorded in the commit message, as a compatibility flag or an explicit acceptance of the risk, and the commit messages here do not record it.
✅ All other checks passed
🔒 Security: ✅ LGTM
Array length is checked against the 512-element limit before the elements are walked. Non-primitive and mixed elements are rejected rather than coerced. Array contents count toward the existing per-span and per-event byte limits. Deserializing the new Cap'n Proto union members is bounded by the message size.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues.
Reviewed commit: 5b761503
5b76150 to
02915b0
Compare
There was a problem hiding this comment.
Superseded by the review of
62df0e21.
This review, of 02915b06
💬 Approved with comments — The implementation is careful and well tested. One non-blocking WARNING: the change to how array inputs are handled should have its compatibility decision recorded in the commit message.
Findings: 1 warning
Not opened by the correctness review: 4 changed files it was meant to read
types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] Arrays passed to setAttribute/setAttributes are no longer stringified but validated or dropped; the commit message does not record the compatibility decision. Carried as a non-blocking WARNING: @jmorrell-cloudflare [author] says this cannot be observed from user code, and the code supports that apart from tail-stream output.
- **File:** src/workerd/api/tracing.c++:136
📋 Code Quality: ⚠️ 1 warning
The array attribute support looks correct; the compatibility decision for arrays that used to be stringified is not recorded.
Recommendation: 📝 Minor Comments
- [WARNING] Arrays passed to setAttribute/setAttributes are no longer stringified but validated or dropped; the commit message does not record the compatibility decision. Carried as a non-blocking WARNING: @jmorrell-cloudflare [author] says this cannot be observed from user code, and the code supports that apart from tail-stream output. (
src/workerd/api/tracing.c++:136)
View full review
Arrays that used to be stringified are now handled differently (src/workerd/api/tracing.c++:136-147)
setAttribute and setAttributes used to take jsg::Optional<TagValue>, which made Web IDL coercion turn any array into a string: ['a','b'] became "a,b" and [{}] became "[object Object]". Now every array goes through toAttributeValue():
- A valid homogeneous array is stored as a real array.
- A mixed, nested or object array is dropped with a warning.
- An array longer than 512 elements is dropped.
The author says on the thread that user code cannot see this: span attributes cannot be read back, and no public tail worker consumes spans yet. That reasoning is plausible. Still, the values do reach tail-stream output (the instrumentation tests in this pull request check them there). The repository's backward-compatibility rules ask that the decision be recorded in the commit message, as a compatibility flag or an explicit acceptance of the risk, and the commit messages here do not record it.
✅ All other checks passed
🔒 Security: ✅ LGTM
Array length is checked against the 512-element limit before the elements are walked. Non-primitive and mixed elements are rejected rather than coerced. Array contents count toward the existing per-span and per-event byte limits. Deserializing the new Cap'n Proto union members is bounded by the message size.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues.
Reviewed commit: 02915b06 — same changes as 5b761503, so this is that commit's review (no new review was run; line numbers are as of 5b761503)
There was a problem hiding this comment.
Superseded by the review of
bff6cff8.
This review, of 62df0e21
💬 Approved with comments — The array-attribute implementation is careful and well tested, and the new coverage workflow change is correct. One non-blocking WARNING remains: the change in how array inputs are handled needs its compatibility decision recorded in the commit history.
Findings: 1 warning
Not opened by the correctness review: 4 changed files it was meant to read
types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] Arrays passed to setAttribute/setAttributes are no longer stringified; they are now validated, or dropped with a warning. The commit messages still don't record the compatibility decision. Carried as a non-blocking WARNING: @jmorrell-cloudflare [author] says this cannot be observed from user code, and the code supports that apart from custom toString() side effects and the changed tail output.
- **File:** src/workerd/api/tracing.c++:136
📋 Code Quality: ⚠️ 1 warning
Coverage workflow change is fine; compatibility decision for array handling still not recorded
Recommendation: 📝 Minor Comments
- [WARNING] Arrays passed to setAttribute/setAttributes are no longer stringified; they are now validated, or dropped with a warning. The commit messages still don't record the compatibility decision. Carried as a non-blocking WARNING: @jmorrell-cloudflare [author] says this cannot be observed from user code, and the code supports that apart from custom toString() side effects and the changed tail output. (
src/workerd/api/tracing.c++:136)
View full review
New since last review: .github/workflows/coverage.yml adds //src/cloudflare/internal/test/tracing/... to the coverage test_target. It uses the same folded >- form as test.yml, and _bazel.yml passes the value unquoted, so each target becomes its own argument. src/cloudflare/internal/test/tracing/ has a BUILD.bazel and .wd-test files. No issues.
Carried from the previous review: at src/workerd/api/tracing.c++:136-149, arrays used to go through Web IDL coercion and get stringified (['a','b'] became "a,b"). They are now either stored as typed arrays or dropped with a warning. The author says on the thread that user code cannot observe this: attributes cannot be read back, and no public tail worker reads spans yet. The code supports that, apart from a user-defined toString() that no longer runs, and the change to what tail output records. The repository's backward-compatibility rules ask for the decision to be recorded in the commit message, either as a compatibility flag or as an explicit acceptance of the risk. The pull request description says this is still pending.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security concerns. Array length is checked against the 512-element limit before any elements are read. Array contents count toward the existing per-span byte limits.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues.
Reviewed commit: 62df0e21
There was a problem hiding this comment.
Superseded by the review of
c2b8dcb8.
This review, of bff6cff8
💬 Approved with comments — The changes since the last review (the setAttributes() conversion order, buffering and its tests) are correct. The one remaining non-blocking WARNING is that no commit message records the compatibility decision for array inputs.
Findings: 1 warning
Not opened by the correctness review: 4 changed files it was meant to read
types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] Arrays passed to setAttribute/setAttributes are no longer stringified; they are now validated, or dropped with a warning. No commit message records the compatibility decision yet. Carried as a non-blocking WARNING: @jmorrell-cloudflare [author] says user code cannot observe this, and the code supports that apart from user-defined toString() and the change to tail output.
- **File:** src/workerd/api/tracing.c++:136
📋 Code Quality: ⚠️ 1 warning
The setAttributes() rewrite is correct; the compatibility decision for array inputs is still not recorded in a commit message.
Recommendation: 📝 Minor Comments
- [WARNING] Arrays passed to setAttribute/setAttributes are no longer stringified; they are now validated, or dropped with a warning. No commit message records the compatibility decision yet. Carried as a non-blocking WARNING: @jmorrell-cloudflare [author] says user code cannot observe this, and the code supports that apart from user-defined toString() and the change to tail output. (
src/workerd/api/tracing.c++:136)
View full review
New since last review: I checked the setAttributes() rewrite in src/workerd/api/tracing.c++ against DictWrapper::tryUnwrap in src/workerd/jsg/value.h. It enumerates properties the same way (GetOwnPropertyNames) and reads and converts each property before reading the next. It records nothing until the whole batch has converted. Scalars still go through the TagValue union handler, so their coercion is unchanged. The new tests cover conversion order, array snapshots, exceptions thrown by getters and by conversion, and all-or-nothing recording on both traced and untraced spans. No issues.
Carried from the previous review: at src/workerd/api/tracing.c++:136-149, arrays used to go through Web IDL coercion and get stringified (['a','b'] became "a,b"). Now they are either stored as typed arrays or dropped with a warning. On the thread, the author says user code cannot observe this, because attributes cannot be read back and no public tail worker reads spans yet. The code supports that, with two exceptions: a user-defined toString() on the array no longer runs, and the recorded tail output changes. The repository's backward-compatibility rules ask for the decision to be recorded in a commit message, either as a compatibility flag or as an explicit acceptance of the risk. None of the commits in this pull request records it, including the new 49c9bd9 and bff6cff.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security concerns. Arrays longer than 512 elements are rejected before any element is read, and array contents count toward the existing per-span byte limits.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
⚡ Performance: ✅ LGTM
The array conversion path is bounded: the 512-element cap is checked before any element is read, and array contents count toward the per-span and per-trace byte limits. Copying and serialization are linear in array size.
📝 Documentation: ✅ LGTM
No documentation issues.
Reviewed commit: bff6cff8
bff6cff to
c2b8dcb
Compare
There was a problem hiding this comment.
Superseded by the review of
ffeb531f.
This review, of c2b8dcb8
💬 Approved with comments — The coverage workflow change since the last review is fine. The one remaining WARNING is a process point: no commit message records the compatibility decision for array inputs.
Findings: 1 warning
Not opened by the correctness review: 4 changed files it was meant to read
types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] Arrays passed to setAttribute/setAttributes are no longer stringified; they are now validated, or dropped with a warning. No commit message records the compatibility decision. Carried as a non-blocking WARNING: @jmorrell-cloudflare [author] says user code cannot observe this, and the code supports that except for custom array toString() side effects and the changed tail output.
- **File:** src/workerd/api/tracing.c++:136
📋 Code Quality: ⚠️ 1 warning
The coverage.yml change is fine. The compatibility record for array attribute values is still missing.
Recommendation: 📝 Minor Comments
- [WARNING] Arrays passed to setAttribute/setAttributes are no longer stringified; they are now validated, or dropped with a warning. No commit message records the compatibility decision. Carried as a non-blocking WARNING: @jmorrell-cloudflare [author] says user code cannot observe this, and the code supports that except for custom array toString() side effects and the changed tail output. (
src/workerd/api/tracing.c++:136)
View full review
coverage.yml (.github/workflows/coverage.yml): the build and test targets now use a folded multi-target string that adds //src/cloudflare/internal/test/tracing/.... The two inputs match. No issues.
Still open: compatibility record for array inputs (src/workerd/api/tracing.c++:136)
Arrays used to go through Web IDL union coercion, so ['a','b'] became "a,b". Now they are stored as typed arrays or dropped with a warning.
The author says user code cannot observe this. The code supports that, with two exceptions:
- a user-defined
toString()on the array no longer runs; - the recorded tail output changes.
The repository's backward-compatibility rules ask for the decision to be recorded in a commit message, either as a compatibility flag or as an explicit acceptance of the risk. None of the commits does that yet.
✅ All other checks passed
🔒 Security: ✅ LGTM
The coverage workflow change adds no secrets, permissions or untrusted input. Array attributes stay bounded: arrays longer than 512 elements are rejected before any element is read, and array contents count toward the per-span byte limits.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues.
Reviewed commit: c2b8dcb8
There was a problem hiding this comment.
Superseded by the review of
a2464cdb.
This review, of ffeb531f
💬 Approved with comments — The changes since the last review (explicit switch arms and a removed comment) are correct. The one remaining WARNING is a process point: no commit message records the compatibility decision for array inputs.
Findings: 1 warning (1 is an inline comment on the diff)
Not opened by the correctness review: 6 changed files it was meant to read
src/workerd/api/trace.c++src/workerd/io/trace-stream.c++types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] Arrays passed to setAttribute/setAttributes are no longer stringified; they are now validated, or dropped with a warning. No commit message records the compatibility decision. Kept at WARNING: @wperron [non-author] confirms the behaviour is intended, which the code supports, but that does not record the decision as the repository's backward-compatibility rules require.
- **File:** src/workerd/api/tracing.c++:136
📋 Code Quality: ⚠️ 1 warning
One carried-over WARNING: no commit message records the compatibility decision for array inputs. No new defects in the changed code.
Recommendation: 📝 Minor Comments
- [WARNING] Arrays passed to setAttribute/setAttributes are no longer stringified; they are now validated, or dropped with a warning. No commit message records the compatibility decision. Kept at WARNING: @wperron [non-author] confirms the behaviour is intended, which the code supports, but that does not record the decision as the repository's backward-compatibility rules require. (
src/workerd/api/tracing.c++:136)
View full review
Changed since the last review
src/workerd/api/trace.c++: thedefaultarm is replaced with explicit cases for the three array alternatives. The switch covers every case, so a future alternative will trigger-Wswitch.src/workerd/io/trace-stream.c++: a redundant comment was removed. No behaviour change.
Still open: compatibility record for array inputs (src/workerd/api/tracing.c++:136)
Arrays used to go through Web IDL TagValue coercion, so ['a','b'] was recorded as "a,b". Now they are stored as typed arrays, or dropped with a warning when they are mixed, nested or longer than 512 elements. This applies on every compatibility date.
The author says user code cannot observe this, and @wperron [non-author] confirms the behaviour is intended. The code supports both, with two exceptions:
- a user-defined
toString()on the array no longer runs; - tail output for such inputs changes.
The repository's Backward Compatibility rules ask for the decision to be recorded in a commit message, either as a compatibility flag or as an explicit acceptance of the risk. None of the nine commits does that yet.
Separately, the message of 71fbfa2 says null and undefined elements "are skipped", but later commits preserve them as null. The squash message could correct that too.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security concerns. Arrays longer than 512 elements are rejected before any element is read, and array contents count toward the per-span byte limit.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues. The generated type snapshots match the hand-written definitions in types/defines/trace.d.ts and src/cloudflare/internal/tracing.d.ts.
Reviewed commit: ffeb531f
There was a problem hiding this comment.
Superseded by the review of
36c723ef.
This review, of a2464cdb
💬 Approved with comments — No new defects in the array-attribute plumbing or in the DOMException and Rust JSG changes merged in from main. One WARNING remains open: no commit message records the compatibility decision for array inputs.
Findings: 1 warning
Not opened by the correctness review: 31 changed files it was meant to read
src/node/internal/internal_inspect.tssrc/per_isolate/dom-exception.tssrc/per_isolate/eventsource/eventsource.tssrc/per_isolate/main.tssrc/per_isolate/per_isolate-env.d.tssrc/per_isolate/primordials.tssrc/per_isolate/serialization.tssrc/per_isolate/webfs/writable-file-stream.tssrc/workerd/api/BUILD.bazelsrc/workerd/api/eventsource.c++src/workerd/api/filesystem-bootstrap.c++src/workerd/api/filesystem.hsrc/workerd/api/global-scope.hsrc/workerd/api/memory-cache-api/fallback.rssrc/workerd/api/memory-cache.c++src/workerd/api/per-isolate-bootstrap.c++src/workerd/api/streams/standard.c++src/workerd/api/trace.c++src/workerd/jsg/dom-exception.c++src/workerd/jsg/dom-exception.hsrc/workerd/jsg/jsg.c++src/workerd/jsg/jsg.hsrc/workerd/jsg/ser.c++src/workerd/jsg/ser.hsrc/workerd/jsg/setup.c++src/wpt/BUILD.bazeltypes/defines/dom-exception.d.tstypes/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] Arrays passed to setAttribute/setAttributes are no longer coerced to strings on any compatibility date, and no commit message records the compatibility decision. Kept at WARNING: @wperron [non-author] confirms the behaviour is intended, which the code supports, but none of the 32 commits records the decision.
- **File:** src/workerd/api/tracing.c++:136
📋 Code Quality: ⚠️ 1 warning
No new defects. One WARNING is still open: the compatibility decision for array inputs is not recorded in a commit message.
Recommendation: 📝 Minor Comments
- [WARNING] Arrays passed to setAttribute/setAttributes are no longer coerced to strings on any compatibility date, and no commit message records the compatibility decision. Kept at WARNING: @wperron [non-author] confirms the behaviour is intended, which the code supports, but none of the 32 commits records the decision. (
src/workerd/api/tracing.c++:136)
View full review
Changed since the last review
- The branch now includes a merge of main: the TypeScript DOMException behind
TS_DOM_EXCEPTION, the Rust JSG serialization and tunneling changes, and the filesystem and memory-cache changes that go with them. I found no defects in them. trace.c++: the explicit array arms in the switch are correct.setAttributes()reads and converts each property in order, and records nothing unless the whole batch succeeds.
Still open: compatibility record for array inputs (src/workerd/api/tracing.c++:136)
- Before this change, arrays went through Web IDL
TagValuecoercion, so['a','b']was recorded as"a,b". - Now they are stored as typed arrays, or dropped with a warning when they are mixed, nested or longer than 512 elements. This applies on every compatibility date.
- A user-defined
toString()on the array no longer runs, and tail output for these inputs changes. - @wperron [non-author] confirms this is intended, and the code matches. The pull request description also says so. But the repository's Backward Compatibility rules ask for the decision to be recorded in a commit message, as either a compatibility flag or an explicit acceptance of the risk. Its own commit message does this for
QuotaExceededError. None of the 32 commits does it for array attributes. - The message of 71fbfa2 also says null and undefined elements "are skipped". Since 5be9d48 they are kept as
null, so the final commit message should be corrected.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security concerns.
- Arrays longer than 512 elements are rejected before any element is read.
- Array contents count toward the per-span byte limit and the tail event size accounting.
- The Rust JSG deserializer reads untrusted bytes with bounds checks. It resolves classes only from bootstrap exports, and it checks that JavaScript execution is allowed before it runs any
deserializefunction.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues. The generated type snapshots match the hand-written definitions.
Reviewed commit: a2464cdb
There was a problem hiding this comment.
Superseded by the review of
7af9e590.
This review, of 36c723ef
💬 Approved with comments — The array size accounting added since the last review is correct. One non-runtime WARNING remains: no commit message records the compatibility decision for array inputs.
Findings: 1 warning
Not opened by the correctness review: 5 changed files it was meant to read
src/workerd/api/trace.c++types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] Arrays passed to setAttribute/setAttributes are no longer stringified on any compatibility date, and no commit message records the compatibility decision. Kept at WARNING: @wperron [non-author] confirms the behaviour is intended, and the code supports that, but the repository's backward-compatibility rules still ask for the decision in a commit message.
- **File:** src/workerd/api/tracing.c++:136
📋 Code Quality: ⚠️ 1 warning
The new Onset size accounting for arrays is correct. The compatibility decision for array inputs is still not recorded in a commit message.
Recommendation: 📝 Minor Comments
- [WARNING] Arrays passed to setAttribute/setAttributes are no longer stringified on any compatibility date, and no commit message records the compatibility decision. Kept at WARNING: @wperron [non-author] confirms the behaviour is intended, and the code supports that, but the repository's backward-compatibility rules still ask for the decision in a commit message. (
src/workerd/api/tracing.c++:136)
View full review
Changed since the last review
attributeValueSize()insrc/workerd/io/trace.c++handles everyAttribute::Valuealternative explicitly.Onset::size()now counts array element slots and string bytes.- The new test "Onset size counts array attribute contents" in
src/workerd/io/trace-test.c++checks this against an onset with empty arrays. src/workerd/api/trace.c++: the explicit array arms make the compiler report any new alternative through-Wswitch.
Still open: compatibility record for array inputs (src/workerd/api/tracing.c++:136)
- Before this change, arrays went through Web IDL
TagValuecoercion and were stringified. - Now they are recorded as typed arrays, or dropped with a warning, on every compatibility date. A user-defined array
toString()no longer runs. - @wperron confirms this is intended, and the code matches. The repository's backward-compatibility rules ask for the decision to be recorded in a commit message, as a compatibility flag or an explicit acceptance of the risk.
- The message of 71fbfa2 also says null and undefined elements "are skipped". Since 5be9d48 they are kept as
null.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security concerns. Arrays longer than 512 elements are rejected before any element is read. Array contents count toward the per-span byte limit and the onset size.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
⚡ Performance: ✅ LGTM
Size accounting is linear in array length, and arrays are capped at 512 elements.
📝 Documentation: ✅ LGTM
The generated type snapshots match the hand-written definitions.
Reviewed commit: 36c723ef
36c723e to
7af9e59
Compare
There was a problem hiding this comment.
Superseded by the review of
cc6a5a73.
This review, of 7af9e590
🛑 Significant concerns — One BLOCKING item: arrayToAttributeValue() copies up to 512 strings into native memory before any byte limit is checked. If the elements reference one large JS string, a single call can allocate hundreds of times that string's size outside the V8 heap. One WARNING remains open: no commit message records the compatibility decision for array inputs.
Findings: 1 blocking · 1 warning (1 is an inline comment on the diff)
Not opened by the correctness review: 5 changed files it was meant to read
src/workerd/api/trace.c++types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## BLOCKING (1)
### [Security] arrayToAttributeValue() copies up to 512 string elements into native memory before the per-span byte limit is checked. An array of repeated references to one large string forces a native allocation of hundreds of times that string's size, outside the V8 heap limit, and can exhaust process memory.
- **File:** src/workerd/api/tracing.c++:100
## WARNING (1)
### [Code Quality] Arrays passed to setAttribute/setAttributes are no longer stringified on any compatibility date, and no commit message records the compatibility decision. Kept at WARNING: @wperron [non-author] confirms the behaviour is intended and the code supports that, but the repository's backward-compatibility rule asks for the decision to be recorded in a commit message. The d8114818 message also still says null and undefined elements are skipped.
- **File:** src/workerd/api/tracing.c++:139
🔒 Security: 🛑 1 blocking
Array conversion copies every string element into native memory before the per-span byte limit is checked, so a small array can force a very large native allocation.
Recommendation: 🔴 Serious Concerns
- [BLOCKING] arrayToAttributeValue() copies up to 512 string elements into native memory before the per-span byte limit is checked. An array of repeated references to one large string forces a native allocation of hundreds of times that string's size, outside the V8 heap limit, and can exhaust process memory. (
src/workerd/api/tracing.c++:100)
View full review
Unbounded native copies during array conversion (src/workerd/api/tracing.c++:100)
arrayToAttributeValue()bounds an array only by its element count (512). For each string element it builds an ownedkj::ConstString(line 100), and returns only after copying all of them.- The 64 KiB per-span limit is applied later, in
SpanState::setAttribute().setAttributes()also buffers the whole converted batch before recording. - A Worker can fill an array with 512 references to one large JS string. The string costs V8 heap only once, but the conversion makes 512 native copies of it, outside the isolate's heap limit. With a string of tens of megabytes, that is tens of gigabytes of native allocation in one call, which can exhaust memory for the whole process, not just the Worker.
- The scalar path copies at most one string per attribute, so the array path multiplies that cost by up to 512.
- Fix: keep a running byte total during conversion and stop as soon as it exceeds the span's remaining budget (or
MAX_SPAN_BYTES). Check each string's length (for examplev8::String::Utf8LengthorLength) before copying it.
📋 Code Quality: ⚠️ 1 warning
One WARNING remains: no commit message records the compatibility decision for array inputs. The OTLP export, invocation-span and size-accounting changes look correct.
Recommendation: 📝 Minor Comments
- [WARNING] Arrays passed to setAttribute/setAttributes are no longer stringified on any compatibility date, and no commit message records the compatibility decision. Kept at WARNING: @wperron [non-author] confirms the behaviour is intended and the code supports that, but the repository's backward-compatibility rule asks for the decision to be recorded in a commit message. The d811481 message also still says null and undefined elements are skipped. (
src/workerd/api/tracing.c++:139)
View full review
Compatibility decision not recorded for array inputs (src/workerd/api/tracing.c++:139)
- Before this change, an array passed to
setAttribute/setAttributeswent through Web IDLTagValuecoercion and was stringified, so['a','b']was recorded as'a,b'. - Now every array is recorded as a typed array or dropped with a warning, on every compatibility date. A user-defined array
toString()no longer runs. - @wperron [non-author] confirmed this is intended, and the code matches that. The repository's backward-compatibility rules still ask for the decision to be recorded in a commit message, either as a compatibility flag or as an explicit acceptance of the risk. None of the commits does this.
- The d811481 message also still says null and undefined elements "are skipped". Since 7b68268 they are kept as
nullslots.
I found no defects in the code changed since the last review:
- The Rust OTLP bridge writes each null slot as an empty
AnyValue, and tests cover null, singleton and empty arrays. tracer.c++handles everyAttribute::Valuealternative.setAttributes()converts the whole batch before it records anything.
✅ All other checks passed
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
⚡ Performance: ✅ LGTM
Size accounting is linear in array length, and arrays are capped at 512 elements.
📝 Documentation: ✅ LGTM
The type definitions and generated snapshots match the new array support.
Reviewed commit: 7af9e590
7af9e59 to
cc6a5a7
Compare
There was a problem hiding this comment.
Superseded by the review of
fd89a100.
This review, of cc6a5a73
🛑 Significant concerns — One BLOCKING item: arrayToAttributeValue() copies up to 512 strings into native memory before any byte limit is checked. If the elements reference one large JS string, a single call can allocate hundreds of times that string's size outside the V8 heap. One WARNING remains open: no commit message records the compatibility decision for array inputs.
Findings: 1 blocking · 1 warning
Not opened by the correctness review: 5 changed files it was meant to read
src/workerd/api/trace.c++types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## BLOCKING (1)
### [Security] arrayToAttributeValue() copies up to 512 string elements into native memory before the per-span byte limit is checked. An array of repeated references to one large string forces a native allocation of hundreds of times that string's size, outside the V8 heap limit, and can exhaust process memory.
- **File:** src/workerd/api/tracing.c++:100
## WARNING (1)
### [Code Quality] Arrays passed to setAttribute/setAttributes are no longer stringified on any compatibility date, and no commit message records the compatibility decision. Kept at WARNING: @wperron [non-author] confirms the behaviour is intended and the code supports that, but the repository's backward-compatibility rule asks for the decision to be recorded in a commit message. The d8114818 message also still says null and undefined elements are skipped.
- **File:** src/workerd/api/tracing.c++:139
🔒 Security: 🛑 1 blocking
Array conversion copies every string element into native memory before the per-span byte limit is checked, so a small array can force a very large native allocation.
Recommendation: 🔴 Serious Concerns
- [BLOCKING] arrayToAttributeValue() copies up to 512 string elements into native memory before the per-span byte limit is checked. An array of repeated references to one large string forces a native allocation of hundreds of times that string's size, outside the V8 heap limit, and can exhaust process memory. (
src/workerd/api/tracing.c++:100)
View full review
Unbounded native copies during array conversion (src/workerd/api/tracing.c++:100)
arrayToAttributeValue()bounds an array only by its element count (512). For each string element it builds an ownedkj::ConstString(line 100), and returns only after copying all of them.- The 64 KiB per-span limit is applied later, in
SpanState::setAttribute().setAttributes()also buffers the whole converted batch before recording. - A Worker can fill an array with 512 references to one large JS string. The string costs V8 heap only once, but the conversion makes 512 native copies of it, outside the isolate's heap limit. With a string of tens of megabytes, that is tens of gigabytes of native allocation in one call, which can exhaust memory for the whole process, not just the Worker.
- The scalar path copies at most one string per attribute, so the array path multiplies that cost by up to 512.
- Fix: keep a running byte total during conversion and stop as soon as it exceeds the span's remaining budget (or
MAX_SPAN_BYTES). Check each string's length (for examplev8::String::Utf8LengthorLength) before copying it.
📋 Code Quality: ⚠️ 1 warning
One WARNING remains: no commit message records the compatibility decision for array inputs. The OTLP export, invocation-span and size-accounting changes look correct.
Recommendation: 📝 Minor Comments
- [WARNING] Arrays passed to setAttribute/setAttributes are no longer stringified on any compatibility date, and no commit message records the compatibility decision. Kept at WARNING: @wperron [non-author] confirms the behaviour is intended and the code supports that, but the repository's backward-compatibility rule asks for the decision to be recorded in a commit message. The d811481 message also still says null and undefined elements are skipped. (
src/workerd/api/tracing.c++:139)
View full review
Compatibility decision not recorded for array inputs (src/workerd/api/tracing.c++:139)
- Before this change, an array passed to
setAttribute/setAttributeswent through Web IDLTagValuecoercion and was stringified, so['a','b']was recorded as'a,b'. - Now every array is recorded as a typed array or dropped with a warning, on every compatibility date. A user-defined array
toString()no longer runs. - @wperron [non-author] confirmed this is intended, and the code matches that. The repository's backward-compatibility rules still ask for the decision to be recorded in a commit message, either as a compatibility flag or as an explicit acceptance of the risk. None of the commits does this.
- The d811481 message also still says null and undefined elements "are skipped". Since 7b68268 they are kept as
nullslots.
I found no defects in the code changed since the last review:
- The Rust OTLP bridge writes each null slot as an empty
AnyValue, and tests cover null, singleton and empty arrays. tracer.c++handles everyAttribute::Valuealternative.setAttributes()converts the whole batch before it records anything.
✅ All other checks passed
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
⚡ Performance: ✅ LGTM
Size accounting is linear in array length, and arrays are capped at 512 elements.
📝 Documentation: ✅ LGTM
The type definitions and generated snapshots match the new array support.
Reviewed commit: cc6a5a73 — same changes as 7af9e590, so this is that commit's review (no new review was run; line numbers are as of 7af9e590)
cc6a5a7 to
fd89a10
Compare
There was a problem hiding this comment.
Superseded by the review of
178c9b64.
This review, of fd89a100
🛑 Significant concerns — One BLOCKING item: array attribute conversion copies up to 512 strings into native memory before any byte limit applies, so one call can allocate far more memory outside the V8 heap than the JS values cost. The other note is a non-blocking process item.
Findings: 1 blocking · 1 info (2 are inline comments on the diff)
Not opened by the correctness review: 4 changed files it was meant to read
types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## BLOCKING (1)
### [Security] arrayToAttributeValue() copies up to 512 string elements into native memory before any byte limit is checked. Repeated references to one large JS string cause native allocation far larger than the JS heap cost. Kept at BLOCKING: @wperron [non-author] notes that the scalar setAttributes() dict path has the same pre-limit copying (tracing.c++:154-164), which is true but does not bound this path.
- **File:** src/workerd/api/tracing.c++:100
## INFO (1)
### [Code Quality] The compatibility decision for typed array attributes was accepted in the discussion (@wperron [non-author]) but is not recorded in any commit message, as the repository's backward-compatibility rules ask. Lowered from WARNING because it is a process item with no runtime impact.
- **File:** src/workerd/api/tracing.c++:139
🔒 Security: 🛑 1 blocking
Array string elements are copied natively before the span byte limit applies.
Recommendation: 🔴 Serious Concerns
- [BLOCKING] arrayToAttributeValue() copies up to 512 string elements into native memory before any byte limit is checked. Repeated references to one large JS string cause native allocation far larger than the JS heap cost. Kept at BLOCKING: @wperron [non-author] notes that the scalar setAttributes() dict path has the same pre-limit copying (tracing.c++:154-164), which is true but does not bound this path. (
src/workerd/api/tracing.c++:100)
View full review
Unbounded native copies during array conversion (src/workerd/api/tracing.c++:100)
arrayToAttributeValue()bounds an array only by its element count (512, checked at line 141).- Each string element is copied into an owned
kj::ConstString(line 100) beforeSpanState::setAttribute()applies the 64 KiB per-span limit.setAttributes()also buffers the whole converted batch before it records anything. - An array of 512 references to one large JS string costs V8 heap only once, but conversion makes 512 native copies of it. Those copies sit outside the isolate's heap limit and can exhaust memory for the whole process.
- Kept at BLOCKING: @wperron [non-author] notes that the scalar
setAttributes()path also converts each dict value (lines 154-164) before the limit is checked. That is true, but it means the exposure already existed. It does not bound the new array path. - Fix: keep a running byte total during conversion and stop once it exceeds
MAX_SPAN_BYTESor the span's remaining budget. Check each string's length (for example withv8::String::Utf8Length) before copying it.
📋 Code Quality: 💬 1 info
No code defects. The compatibility decision for array inputs is not recorded in a commit message.
Recommendation: 💬 Optional Nits
- [INFO] The compatibility decision for typed array attributes was accepted in the discussion (@wperron [non-author]) but is not recorded in any commit message, as the repository's backward-compatibility rules ask. Lowered from WARNING because it is a process item with no runtime impact. (
src/workerd/api/tracing.c++:139)
View full review
- Arrays used to go through
TagValuestring coercion. Now they are recorded as typed arrays, or dropped with a warning, on every compatibility date. @wperron [non-author] explicitly accepted this compatibility risk in the discussion, and the code matches. The repository's backward-compatibility rules ask for that acceptance to be recorded in a commit message, and none of the commits does so. One earlier commit message also still says null and undefined elements are skipped, but they are now kept as null slots. - I found no defects in the array plumbing: every
Attribute::Valuealternative is handled, the OTLP bridge writes null slots as emptyAnyValues, and batch conversion records nothing until the whole batch succeeds.
✅ All other checks passed
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
⚡ Performance: ✅ LGTM
Size accounting, the clones and the OTLP array builders are all linear in array length, and arrays are capped at 512 elements. The native-copy concern is covered in the security section.
📝 Documentation: ✅ LGTM
The type definitions and generated snapshots match the new array support.
Reviewed commit: fd89a100
fd89a10 to
178c9b6
Compare
There was a problem hiding this comment.
Superseded by the review of
856d810f.
This review, of 178c9b64
🛑 Significant concerns — One BLOCKING security item is still open: array attribute conversion makes up to 512 native copies of string elements before any byte limit applies, so a single call can allocate far more memory outside the V8 heap than the JS values cost. No other defects were found in the array plumbing.
Findings: 1 blocking
Not opened by the correctness review: 4 changed files it was meant to read
types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## BLOCKING (1)
### [Security] arrayToAttributeValue() copies up to 512 string elements into native memory before any byte limit is checked. Repeated references to one large JS string cause native allocation far larger than the JS heap cost. Kept at BLOCKING: @wperron [non-author] notes the scalar setAttributes() path (lines 154-164) has the same pattern. That is true, but it does not bound the new array path, which multiplies the exposure by up to 512 for each key.
- **File:** src/workerd/api/tracing.c++:100
🔒 Security: 🛑 1 blocking
Native string copies during array conversion are still not bounded by the per-span byte limit.
Recommendation: 🔴 Serious Concerns
- [BLOCKING] arrayToAttributeValue() copies up to 512 string elements into native memory before any byte limit is checked. Repeated references to one large JS string cause native allocation far larger than the JS heap cost. Kept at BLOCKING: @wperron [non-author] notes the scalar setAttributes() path (lines 154-164) has the same pattern. That is true, but it does not bound the new array path, which multiplies the exposure by up to 512 for each key. (
src/workerd/api/tracing.c++:100)
View full review
Array conversion copies strings natively before any byte limit (src/workerd/api/tracing.c++:100)
arrayToAttributeValue()bounds an array only by its element count, which is capped at 512 (line 141).- Each string element is copied into an owned
kj::ConstString(line 100).SpanState::setAttribute()applies the 64 KiBMAX_SPAN_BYTESlimit only after that, at lines 290-298, andsetAttributes()converts and buffers the whole batch before recording any of it. - An array of 512 references to one large JS string costs the V8 heap only once, but conversion makes 512 native copies of it. Those copies sit outside the isolate's heap limit, so one call can exhaust memory for the whole process.
- Kept at BLOCKING despite the replies from @wperron [non-author]. They point out that scalar
setAttributes()values are also converted before the limit, and they plan to fix both paths in a separate change. Re-reading lines 154-164 confirms the scalar path has the same pattern. That shows the exposure already existed, but it does not bound the new array path, which multiplies it by up to 512 for each key. - Fix: keep a running byte total during conversion and stop once it passes
MAX_SPAN_BYTESor the span's remaining budget. Check each string's length (for example withv8::String::Utf8Length) before copying it. The same check could cover the scalar path.
I found no other security issues. Oversized arrays are rejected before any index is read, mixed or nested arrays are dropped, and array contents count toward the per-span size estimate.
✅ All other checks passed
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
📋 Code Quality: ✅ LGTM
Every Attribute::Value alternative is handled explicitly in each switch, so a new alternative will trigger -Wswitch. The switches cover size accounting, clone, Cap'n Proto serialization, SpanBuilder::setTag, TraceContext::setTag, user and invocation spans, tail-stream conversion, OTLP export and the test fixture. setAttributes() converts the whole batch before it records anything, so a conversion error leaves the span unchanged.
The compatibility change (arrays are no longer stringified) has been accepted explicitly in the discussion. As the repository's backward-compatibility rules ask, the commit message at merge should record that acceptance and describe nulls as kept as null slots.
⚡ Performance: ✅ LGTM
Size accounting, cloning, serialization, async-trace rendering and OTLP array building are all linear in array length, and arrays are capped at 512 elements. The native-copy concern is covered in the security section.
📝 Documentation: ✅ LGTM
The hand-written definitions in types/defines/trace.d.ts and src/cloudflare/internal/tracing.d.ts match the generated snapshots and the new array behaviour.
Reviewed commit: 178c9b64
Extend the `SpanValue` type accepted by `span.setAttribute()` and `span.setAttributes()` to homogeneous arrays of strings, numbers or booleans, matching OpenTelemetry's `AttributeValue`. Arrays are carried as a single `tracing::Attribute::Value` alternative (`kj::Array<kj::ConstString>`, `kj::Array<bool>`, `kj::Array<double>`) and as new `rpc::TagValue` union members, so a one-element array is never collapsed into a scalar on its way to the streaming tail worker and an empty array stays an empty array. This covers both the SpanBuilder path used by user-created spans and the `BaseTracer::addSpanAttribute()` path used by the invocation span. Array inputs are validated by hand rather than through JSG coercion: null and undefined elements are skipped, and arrays that mix primitive types or contain non-primitives are ignored with a warning, mirroring the OpenTelemetry SDK. Array elements count toward the existing 64 KiB per-span data limit. Refs WO-1579.
Represent null and undefined array slots as optional elements through the tracing wire format, normalizing both to null in tail output to match OTLP empty AnyValues. Account for nullable slots in span limits and expose them in tail-stream types.
TraceContext::setTag() annotates the span's async trace operation with a text rendering of each tag (added in 73d36fc). SpanBuilder::TagInitValue now also carries attribute arrays, which fell through that switch and annotated an empty string. Render them as [a, null, b] instead.
Preserve the span-recording fixture support from the previous merge while rebasing the array-attribute changes onto current main. Focused tracing, serialization, fixture, and RPC type targets pass five runs each. Generated type snapshots match.
Read and convert each property before reading the next so later getters cannot affect earlier values. Buffer converted attributes until the entire batch succeeds to avoid partial recording on conversion errors.
List the array alternatives instead of using a default arm. A new Attribute::Value alternative then triggers -Wswitch here, which CI's -Werror builds reject, rather than silently reaching the failure arm.
The single-value branch already shows that a value, including an array, is emitted as-is.
Onset::size() counted only scalar string values, so an array attribute added just its fixed-size variant. Count each array's element slots and its strings' bytes too, handling every Attribute::Value alternative explicitly.
Main added two switches over span attribute values that predate array attributes: invocation-span attributes set by the embedder, and the OTLP span exporter. Both now handle string, boolean and number arrays. The OTLP exporter writes them as an ArrayValue, with each null slot as an AnyValue that has no value set, as the log exporter already does for nested JSON arrays. The OTLP tracing test now covers arrays with null slots, singleton and empty arrays. Refs WO-1579. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
178c9b6 to
856d810
Compare
There was a problem hiding this comment.
🛑 Significant concerns — One BLOCKING security item is still open: array attribute conversion makes up to 512 native copies of string elements before any byte limit applies, so a single call can allocate far more memory outside the V8 heap than the JS values cost. No other defects were found in the array plumbing.
Findings: 1 blocking
Not opened by the correctness review: 4 changed files it was meant to read
types/generated-snapshot/experimental/index.d.tstypes/generated-snapshot/experimental/index.tstypes/generated-snapshot/index.d.tstypes/generated-snapshot/index.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #7427.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## BLOCKING (1)
### [Security] arrayToAttributeValue() copies up to 512 string elements into native memory before any byte limit is checked. Repeated references to one large JS string cause native allocation far larger than the JS heap cost. Kept at BLOCKING: @wperron [non-author] notes the scalar setAttributes() path (lines 154-164) has the same pattern. That is true, but it does not bound the new array path, which multiplies the exposure by up to 512 for each key.
- **File:** src/workerd/api/tracing.c++:100
🔒 Security: 🛑 1 blocking
Native string copies during array conversion are still not bounded by the per-span byte limit.
Recommendation: 🔴 Serious Concerns
- [BLOCKING] arrayToAttributeValue() copies up to 512 string elements into native memory before any byte limit is checked. Repeated references to one large JS string cause native allocation far larger than the JS heap cost. Kept at BLOCKING: @wperron [non-author] notes the scalar setAttributes() path (lines 154-164) has the same pattern. That is true, but it does not bound the new array path, which multiplies the exposure by up to 512 for each key. (
src/workerd/api/tracing.c++:100)
View full review
Array conversion copies strings natively before any byte limit (src/workerd/api/tracing.c++:100)
arrayToAttributeValue()bounds an array only by its element count, which is capped at 512 (line 141).- Each string element is copied into an owned
kj::ConstString(line 100).SpanState::setAttribute()applies the 64 KiBMAX_SPAN_BYTESlimit only after that, at lines 290-298, andsetAttributes()converts and buffers the whole batch before recording any of it. - An array of 512 references to one large JS string costs the V8 heap only once, but conversion makes 512 native copies of it. Those copies sit outside the isolate's heap limit, so one call can exhaust memory for the whole process.
- Kept at BLOCKING despite the replies from @wperron [non-author]. They point out that scalar
setAttributes()values are also converted before the limit, and they plan to fix both paths in a separate change. Re-reading lines 154-164 confirms the scalar path has the same pattern. That shows the exposure already existed, but it does not bound the new array path, which multiplies it by up to 512 for each key. - Fix: keep a running byte total during conversion and stop once it passes
MAX_SPAN_BYTESor the span's remaining budget. Check each string's length (for example withv8::String::Utf8Length) before copying it. The same check could cover the scalar path.
I found no other security issues. Oversized arrays are rejected before any index is read, mixed or nested arrays are dropped, and array contents count toward the per-span size estimate.
✅ All other checks passed
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
📋 Code Quality: ✅ LGTM
Every Attribute::Value alternative is handled explicitly in each switch, so a new alternative will trigger -Wswitch. The switches cover size accounting, clone, Cap'n Proto serialization, SpanBuilder::setTag, TraceContext::setTag, user and invocation spans, tail-stream conversion, OTLP export and the test fixture. setAttributes() converts the whole batch before it records anything, so a conversion error leaves the span unchanged.
The compatibility change (arrays are no longer stringified) has been accepted explicitly in the discussion. As the repository's backward-compatibility rules ask, the commit message at merge should record that acceptance and describe nulls as kept as null slots.
⚡ Performance: ✅ LGTM
Size accounting, cloning, serialization, async-trace rendering and OTLP array building are all linear in array length, and arrays are capped at 512 elements. The native-copy concern is covered in the security section.
📝 Documentation: ✅ LGTM
The hand-written definitions in types/defines/trace.d.ts and src/cloudflare/internal/tracing.d.ts match the generated snapshots and the new array behaviour.
Reviewed commit: 856d810f — same changes as 178c9b64, so this is that commit's review (no new review was run; line numbers are as of 178c9b64)
Summary
Adds OpenTelemetry attribute arrays to
span.setAttribute()andspan.setAttributes()(WO-1579).Companion: https://gitlab.cfdata.org/cloudflare/ew/edgeworker/-/merge_requests/15345
Current pair — 2026-11-25 (afternoon)
Rebased onto main
aea9e5c84. Public head856d810f1f534cb2541607be06deade02f558a9e; companion head1507411162e7eaf4c6ab7d0708174adb0ff77908is rebased onto edgeworker masterac0d830430and pins that exact public commit. Master's own workerd pin,6eb888c52, is an ancestor of the public head; beyond it, the pin adds six main commits and the public tracing commits.deps/workerdgitlink. None of main's new commits touches tracing code or types.178c9b64a) failed edgeworker's global-scope golden test because it pinned WebSocketon*attributes (Give WebSocket onopen, onmessage, onclose and onerror attributes #8851) and UDP ingress (Enable UDP ingress on compatibility date 2026-12-16 #8827) ahead of edgeworker master. Master has since taken both, with their golden updates, so this pair was rebased after them.Verification
@gc-stressand ESLint),trace-test,trace-stream-test,async-trace-io-test,test-fixture-test, the JS RPC trace tests, the OTLP crate tests,otlp-tracing-test, andotlp-export-queue-test. The regenerated//typesoutput matches the checked-in snapshot.@ephemeral-isolates, passed five runs each; 18 integration targets passed, including everyjaeger.ew-test,jaeger-trace.ew-test, andotlp-export.ew-testvariant; andglobal-scope-snapshot.ew-testpassed in all six variants.r2-test@timeouts and a memory-cache bench smoke failure; both are unrelated to tracing. Internal pipeline 5592616 passed with no retries, andinternal-buildpassed once it observed that pipeline. The companion adds one commit for this pair, givinguser-trace.ew-testa 60 s test size because loaded runners pushed it past the 15 s limit.Review follow-ups
toString()side effects, and are recorded as typed arrays or rejected by array validation.setAttributes()with many keys sharing one large string, or a large concatenated string). A fix should cover both paths together, outside this PR.