Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 66f5879 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Hi @wperron. Thanks for taking the time to contribute to Workers SDK. This PR has been automatically closed because you are not currently a registered (vouched) collaborator for this repository. AI tools now let our team generate proposed code changes quickly. Reviewing changes, checking that they solve the right problem, and maintaining code quality over time still take substantial care and effort. We therefore limit PRs to registered collaborators so we can focus that effort where it is most useful. For the majority of external contributors, the most effective way to help is through issues: describing a problem or use case, providing a minimal reproduction, investigating its cause, or helping us verify a fix. Those contributions help us understand what needs to change and are very welcome. We will take an initial look at this PR and decide whether it is something we want to invest time in reviewing and maintaining. We may reopen it if we decide to proceed, but we cannot guarantee that it will be reopened or receive a full review. |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
There was a problem hiding this comment.
Superseded by the review of
5743090d.
This review, of 329f1afa
🛑 Significant concerns — 1 BLOCKING item: the workerd dependency is still pinned to 1.20261119.1, which ignores tracing.otlp. This pull request also turns off tail_worker_user_spans, so merging it as it stands means local observability captures no spans and the capture tests fail on the target branch. Bump workerd before merging. The other notes are informational.
Findings: 1 blocking · 3 info (4 are inline comments on the diff)
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 #17061.
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)
### [Release] workerd is still pinned to 1.20261119.1 (`pnpm-workspace.yaml:164`), which ignores `tracing.otlp`. `tail_worker_user_spans` is also removed, so merging as is leaves local observability with no spans and the capture tests failing on `main`.
- **File:** packages/miniflare/src/index.ts:2640
## INFO (3)
### [Code Quality] The new protobuf decoder has no direct unit tests. Truncation, int64 overflow, service filtering and error precedence are only covered end to end, and those tests need a newer workerd.
- **File:** packages/miniflare/src/workers/observability/otlp-to-store.ts:1
### [Code Quality] The `tracing` delta was applied by hand to the generated Cap'n Proto types. Regenerate the file from the workerd schema after the workerd bump.
- **File:** packages/miniflare/src/runtime/config/generated/workerd.ts:212
### [Performance] `pending_parents` rows for parents that are filtered out (for example the entry Worker's spans) are never removed, so the table grows linearly with request count until `clear()` runs.
- **File:** packages/miniflare/src/workers/observability/trace-store.ts:151
📋 Code Quality: 💬 2 info
The OTLP field numbers and the parent re-linking look correct. The protobuf decoder has no direct unit tests, and the generated config types were edited by hand.
Recommendation: 💬 Optional Nits
- [INFO] The new protobuf decoder has no direct unit tests. Truncation, int64 overflow, service filtering and error precedence are only covered end to end, and those tests need a newer workerd. (
packages/miniflare/src/workers/observability/otlp-to-store.ts:1) - [INFO] The
tracingdelta was applied by hand to the generated Cap'n Proto types. Regenerate the file from the workerd schema after the workerd bump. (packages/miniflare/src/runtime/config/generated/workerd.ts:212)
View full review
I checked the decoder's field numbers against the OTLP proto, and they match. The parent re-linking statements in trace-store.ts all match on trace_id as well as span IDs.
No direct tests for the decoder. otlp-to-store.ts is a new 442-line hand-written protobuf reader. Only the end-to-end tests exercise it, and those need a newer workerd. These paths would be cheap to pin in a plain Vitest spec with a hand-encoded ExportTraceServiceRequest:
- truncated input or an unknown wire type throws,
- int64 values beyond the safe-integer range are handled,
service.name/tracedServicesfiltering,errorprecedence: exception, then status message, thenerror.type.
Generated file edited by hand. src/runtime/config/generated/workerd.ts gets only the tracing delta, applied by hand. packages/miniflare/AGENTS.md says this file is generated and should not be edited directly. Regenerate it from the workerd schema once the workerd bump lands, so it doesn't drift.
🚀 Release: 🛑 1 blocking
The pinned workerd version doesn't support tracing.otlp, so with the bundled runtime the new capture path delivers no spans.
Recommendation: 🔴 Serious Concerns
- [BLOCKING] workerd is still pinned to 1.20261119.1 (
pnpm-workspace.yaml:164), which ignorestracing.otlp.tail_worker_user_spansis also removed, so merging as is leaves local observability with no spans and the capture tests failing onmain. (packages/miniflare/src/index.ts:2640)
View full review
Pinned workerd lacks tracing.otlp.
- Miniflare now sets
tracing.otlpatpackages/miniflare/src/index.ts:2640-2646. - The workspace catalog still pins
workerd: "1.20261119.1"(pnpm-workspace.yaml:164). As the description says, that release ignorestracing. - The change also removes
tail_worker_user_spansfrom the observability compatibility flags. So with the bundled runtime, spans arrive neither over OTLP nor through the streaming tail.
If this merges as it stands:
- Local observability (on by default) shows no spans.
- The four capture tests in
test/plugins/core/observability.spec.tsfail onmain. - The scheduled test in
test/plugins/local-explorer/scheduled.spec.tsfails onmain.
The description already lists the bump as a precondition. It needs to be met in this pull request, or merged first, before this lands.
⚡ Performance: 💬 1 info
pending_parents rows for parents that never arrive are never pruned.
Recommendation: 💬 Optional Nits
- [INFO]
pending_parentsrows for parents that are filtered out (for example the entry Worker's spans) are never removed, so the table grows linearly with request count untilclear()runs. (packages/miniflare/src/workers/observability/trace-store.ts:151)
View full review
A span whose parent isn't stored gets a pending_parents row. Parents in Miniflare's own services, such as the entry Worker, are filtered out and never arrive, so each such invocation leaves a permanent row until clear() runs.
The rows are small and indexed, so growth over a long dev session is minor. To bound it, prune the table together with spans, or skip parents whose service is known not to be traced.
✅ All other checks passed
🔒 Security: ✅ LGTM
No exploitable issues in the changed code.
- The new
/v1/tracesendpoint is served by the internal collector service, the same service that already serves/query. - The protobuf reader throws on truncated input.
- The span store's SQL is parameterised through
json_each(?)bindings.
📖 AGENTS.md: ✅ LGTM
The repository guidance applies to two things here: the missing workerd bump, covered under release, and the hand-edited generated config types, covered under code quality.
📝 Documentation: ✅ LGTM
The changeset describes the change accurately. unsafeObservability is undocumented, so no public docs need updating.
Reviewed commit: 329f1afa
| structuredLogging: true, | ||
| // workerd exports the spans of every invocation to the observability | ||
| // collector, which keeps those of the user's workers. | ||
| tracing: sharedOpts.unsafeObservability |
There was a problem hiding this comment.
🛑 BLOCKING · Release
workerd is still pinned to 1.20261119.1 (pnpm-workspace.yaml:164), which ignores tracing.otlp. tail_worker_user_spans is also removed, so merging as is leaves local observability with no spans and the capture tests failing on main.
This turns on tracing.otlp, but the workspace catalog still pins workerd: "1.20261119.1" (pnpm-workspace.yaml:164), and that release ignores tracing. This change also removes tail_worker_user_spans, so with the bundled runtime no spans reach the collector by either path. Local observability shows no spans, and the capture tests in observability.spec.ts and local-explorer/scheduled.spec.ts fail on main. Bump workerd to a release that includes cloudflare/workerd#7686, in this pull request or in one merged before it.
| @@ -0,0 +1,442 @@ | |||
| /** | |||
There was a problem hiding this comment.
ℹ️ INFO · Code Quality
The new protobuf decoder has no direct unit tests. Truncation, int64 overflow, service filtering and error precedence are only covered end to end, and those tests need a newer workerd.
This hand-written decoder is only exercised through the workerd integration tests, which can't pass until workerd is bumped. A small Vitest spec could feed a hand-encoded ExportTraceServiceRequest to decodeExportTraceServiceRequest and assert truncation errors, int64-to-string conversion, tracedServices filtering and the exception/status/error.type precedence.
| set cluster(value: ClusterConfig) { | ||
| $.utils.copyFrom(value, $.utils.getPointer(6, this)); | ||
| } | ||
| _adoptTracing(value: $.Orphan<TracingOptions>): void { |
There was a problem hiding this comment.
ℹ️ INFO · Code Quality
The tracing delta was applied by hand to the generated Cap'n Proto types. Regenerate the file from the workerd schema after the workerd bump.
packages/miniflare/AGENTS.md marks this file as generated and says not to edit it directly. Applying the tracing delta by hand (pointer 7) is understandable while the schema is unreleased. Once workerd is bumped, regenerate the file so it matches the schema exactly.
| .slice(offset, offset + SQL_WRITE_CHUNK_ROWS) | ||
| .map(({ traceId, spanId }) => ({ traceId, spanId })) | ||
| ); | ||
| this.sql.exec( |
There was a problem hiding this comment.
ℹ️ INFO · Performance
pending_parents rows for parents that are filtered out (for example the entry Worker's spans) are never removed, so the table grows linearly with request count until clear() runs.
Every invocation that comes through Miniflare's entry Worker inserts a pending_parents row whose parent is never exported. Nothing prunes these rows except clear(). The impact is small, but consider pruning them together with spans, or capping the table.
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
dario-piotrowicz
left a comment
There was a problem hiding this comment.
Thank you for the PR @wperron 🙂
Could you please address the various AI review comments? 🙏
There was a problem hiding this comment.
Superseded by the review of
951c9519.
This review, of 5743090d
✅ Approved — The earlier blocking issue is fixed: workerd is now pinned to 1.20261120.1 (pnpm-workspace.yaml:164), the first release with tracing.otlp. The earlier notes are also resolved: the decoder has unit tests, the generated types were regenerated, and clear() now empties pending_parents. Nothing new was found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🚀 Release: ✅ LGTM
- workerd version: the catalog now pins
workerd: "1.20261120.1"(pnpm-workspace.yaml:164), the first release withtracing.otlp, and the lockfile is updated to match. - Compatibility date:
DEFAULT_COMPAT_DATEmoves to 2026-11-20 along with the bump. - Changesets: they cover the Miniflare feature, the dependency bump and the compatibility-date change.
🔒 Security: ✅ LGTM
/v1/tracesendpoint: it is served by the internal collector service, which only workerd inside Miniflare can reach.- Protobuf reader: it checks bounds and throws on truncated input.
- SQL changes: they use bound parameters.
📖 AGENTS.md: ✅ LGTM
The generated config types are now regenerated instead of edited by hand, and the workerd dependency is bumped in both the catalog and the lockfile, as the repository guidelines require.
📋 Code Quality: ✅ LGTM
Both earlier notes are resolved:
- Decoder tests:
test/workers/otlp-to-store.spec.tsnow tests the OTLP decoder directly. It covers attribute types, int64 values beyond the safe range, service filtering, theerrororder, unknown fields, and truncated or malformed input. - Generated types:
src/runtime/config/generated/workerd.tsis now regenerated from the workerd1.20261120.1schema instead of edited by hand.
New code since the last review:
TraceWriter.enqueueCompletedSpans: waiters are released wherever the full batch is swapped out, by a save in#startBatchor byclear. Each waiter checks again for room before it continues, and the three new tests cover the waiting cases./v1/tracesincollector.worker.ts: thetry/finallyreleases the batch owner on every path.- Parent re-linking in
trace-store.ts: every statement matches ontrace_idas well as the span ID.
⚡ Performance: ✅ LGTM
pending_parentsgrowth: the table gets at most one row per stored span, the same rate as the spans and logs, which are also kept untilclear().clear()now emptiespending_parentstoo, so the table adds no growth of its own.- Parent-settling SQL: it runs in chunks and uses indexed lookups, so its cost scales with the batch size.
📝 Documentation: ✅ LGTM
The changeset accurately describes what users see, including the change to streaming tail workers configured locally.
Reviewed commit: 5743090d
5743090 to
951c951
Compare
There was a problem hiding this comment.
Superseded by the review of
66f5879a.
This review, of 951c9519
✅ Approved — No issues found. The only change since the last approved review is the lockfile, and it now matches the workerd 1.20261120.1 pin in the catalog.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🚀 Release: ✅ LGTM
The changesets, the compatibility date and the workerd pin all agree. The pull request changes how local observability spans are captured; that path is only used with unsafeObservability.
🔒 Security: ✅ LGTM
No security issues in the lockfile update.
📖 AGENTS.md: ✅ LGTM
The workerd bump is in both the catalog and the lockfile, and the generated types are regenerated, as the repository guidelines require.
📋 Code Quality: ✅ LGTM
Every workerd and @cloudflare/workerd-* entry in the lockfile is now 1.20261120.1, matching pnpm-workspace.yaml:164. DEFAULT_COMPAT_DATE is 2026-11-20 to match that release.
⚡ Performance: ✅ LGTM
No performance issues.
📝 Documentation: ✅ LGTM
The changesets still match the behaviour.
Reviewed commit: 951c9519
Spans are going away from streaming tail events: workerd now exports each invocation's spans itself, as OTLP (`tracing.otlp`, from cloudflare/workerd#7686). With `unsafeObservability`, Miniflare makes the observability collector workerd's OTLP collector. Its new `/v1/traces` endpoint decodes the protobuf export with a small reader for the fields workerd sets and stores the spans. The streaming tail now supplies only logs and exceptions, so `tail_worker_user_spans` is no longer enabled. `tracing.otlp` traces every service in the config, including Miniflare's own Workers. The collector keeps only the spans of the services Miniflare passes it (user workers and the Workflows services that run their workflows, with the worker names the tail props used to carry) and drops the rest. An invocation started by one of those dropped spans, such as the entry Worker's, would then point at a parent that is never stored, so the store keeps a span whose parent is missing as a root and parks the parent in `pending_parents`. If the parent arrives later, as a calling user worker's span does after its callee has been exported, the span is attached to it again. The config types add `tracing` from the merged workerd schema, so this needs a workerd release that includes cloudflare/workerd#7686. Co-Authored-By: Dan Lapid <dlapid@cloudflare.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Wait for room instead of dropping spans when an OTLP export fills the trace writer. Each export arrives in one request, so a large one could fill both batches before the first save finished and lose the rest while still reporting success. Waiters are woken when the full batch is swapped out, by a save or a clear. Waiting on the save in progress instead hangs in workerd: the next save is started by a continuation registered from another request's context, which runs on a later event-loop turn. - Add unit tests for the OTLP decoder, which run without a workerd that supports `tracing.otlp`. - Rewrite the changeset around what users see, and note that locally configured streaming tail workers no longer receive span events. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Regenerate `src/runtime/config/generated/workerd.ts` from the bundled workerd 1.20261123.1 schema with `capnp:workerd`, replacing the `tracing` delta that was applied by hand. The `tracing` types match it (pointer 7); the rest of the diff is other schema changes since the file was last generated, such as new `ClusterConfig` fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
951c951 to
66f5879
Compare
There was a problem hiding this comment.
✅ Approved — No issues found. The generated workerd config types are now regenerated from the bundled schema, and the OTLP capture path, writer back-pressure and parent re-linking look correct and are tested.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🚀 Release: ✅ LGTM
The change is limited to Miniflare's local observability path (unsafeObservability). The changeset discloses the behaviour change for streaming tail workers configured locally, and tests cover decoding, capture and buffering.
🔒 Security: ✅ LGTM
The protobuf reader checks bounds before every read. The new pending_parents statements bind every value as a parameter. The service filter is not open to prototype keys. A malformed export only affects local development data.
📖 AGENTS.md: ✅ LGTM
The generated workerd types are now regenerated instead of edited by hand, as the repository guidelines require.
📋 Code Quality: ✅ LGTM
TraceWriter.enqueueCompletedSpans always has a waker while the batch is full: it is released from #startBatch or clear. TraceStore.persist settles pending parents only after the whole batch has been upserted, so a span whose parent is in the same batch is not wrongly parked. The decoder rejects truncated input and unknown wire types, and it uses Object.hasOwn for the service lookup. Tests cover the decoder, the back-pressure, the re-linking and end-to-end capture.
⚡ Performance: ✅ LGTM
Decoding makes one pass over the request without copying nested messages. The parent-settling statements are chunked, run inside the existing transaction and use indexed keys. A capacity wait only happens while a save is in progress.
📝 Documentation: ✅ LGTM
The changeset describes what users will see, including that streaming tail workers configured locally lose span events.
Reviewed commit: 66f5879a
Supersedes #16204 by @danlapid, rebased onto
mainand updated for cloudflare/workerd#7686 as merged. Dan is co-author of the commit.Spans are going away from streaming tail events. cloudflare/workerd#7686 lets workerd export each invocation's spans itself, as OTLP, through a new
tracing.otlpconfig setting. This moves Miniflare's local observability (unsafeObservability) onto it:tracing.otlpto the observability collector. Its newPOST /v1/tracesdecodes workerd's protobuf export (a small reader for the fields workerd sets, no new dependency) and stores the spans. They carry precise timestamps instead of the coarse I/O time tail events report.tail_worker_user_spansis no longer enabled. Logs still reference spans correctly: the tail events carry the same span IDs workerd exports.tracing.otlptraces every service in the config, including Miniflare's own Workers (the entry Worker, simulators, queue brokers, …). The collector receives a map from workerd service name to worker name: user workers, plus the Workflows services that run their workflows. It keeps only those services' spans. This map replaces the per-tailpropsthat used to carry the worker name.pending_parentstable. If the parent arrives later, the span is attached to it again. That happens when one user worker calls another, because the callee usually finishes and is exported first. So distributed traces across user workers still join up.While
tracing.otlpis set, workerd exports user spans over OTLP instead of delivering them to streaming tail workers, so with local observability on (the default) a streaming tail worker configured locally no longer receivesspanOpen/spanClose. That's intended: spans on streaming tail workers are being deprecated in local dev and production alike.A failed span's
errorcolumn is its last exception (workerd records uncaught exceptions on the invocation span), else its status message, else itserror.type, so a span that failed without an exception, such as a 5xx fetch, still counts as an error.Changes since #16204
main:tailConsumersis nowexperimental.streamingTailConsumers, and the collector's entry no longer needsstreaming: true.src/runtime/config/generated/workerd.tsaddstracingfrom the merged workerd schema. Sincemainadded theclusterfield,tracingis pointer 7, not 6. Only thetracingdelta is applied, so the rest of the file is unchanged.http_requestspan it used to open for each request on a socket, so invocation spans are the roots; a comment that mentioned it is gone.dispatchFetch()bodies.Changes since review
mainnow bundles workerd1.20261123.1(Bump the workerd-and-workers-types group across 1 directory with 2 updates #17070), which includes Export Workers user spans over OTLP workerd#7686.src/runtime/config/generated/workerd.tsis regenerated from it withcapnp:workerdinstead of edited by hand. Itstracingtypes match the earlier hand edit (pointer 7); the rest of that diff is other schema changes since the file was last generated.TraceWriter.enqueueCompletedSpans). Waiters are woken when the full batch is swapped out by a save or a clear. Waiting on the save in progress instead hangs in workerd: the next save is started by a continuation registered from another request's context, which runs on a later event-loop turn.test/workers/otlp-to-store.spec.ts): attribute types, int64 values beyond the safe range, service filtering, the order used for theerrorcolumn, and truncated or malformed input.unsafeObservabilityis an unsafe, undocumented option, and the Local Explorer's views are unchanged apart from more precise span timings.Tested with the bundled workerd
1.20261123.1: the full Miniflare test suite passes. The OTLP capture tests also pass withX_LOCAL_OBSERVABILITY_BATCH_SIZE=1, which forces every export to overflow the writer, except one log assertion: at that size the tail path drops logs by design. Type check,oxlint,oxfmt,check:catalog,check:pinned-deps,check:compat-dateandcheck:package-depspass.