Skip to content

[miniflare] Capture local observability spans over OTLP - #17061

Open
wperron wants to merge 3 commits into
cloudflare:mainfrom
wperron:wperron/observability-otlp
Open

wperron wants to merge 3 commits into
cloudflare:mainfrom
wperron:wperron/observability-otlp

Conversation

@wperron

@wperron wperron commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Supersedes #16204 by @danlapid, rebased onto main and 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.otlp config setting. This moves Miniflare's local observability (unsafeObservability) onto it:

  • Spans over OTLP. Miniflare sets tracing.otlp to the observability collector. Its new POST /v1/traces decodes 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.
  • Logs stay on the streaming tail. The tail handler now handles only logs, exceptions, and the per-invocation log. tail_worker_user_spans is no longer enabled. Logs still reference spans correctly: the tail events carry the same span IDs workerd exports.
  • Only the user's spans are kept. tracing.otlp traces 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-tail props that used to carry the worker name.
  • Roots stay roots. Dropping Miniflare's spans would leave, for example, an invocation that came through the entry Worker pointing at a parent that is never stored. The store keeps a span whose parent is missing as a root and parks the parent in a pending_parents table. 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.otlp is 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 receives spanOpen/spanClose. That's intended: spans on streaming tail workers are being deprecated in local dev and production alike.

A failed span's error column is its last exception (workerd records uncaught exceptions on the invocation span), else its status message, else its error.type, so a span that failed without an exception, such as a 5xx fetch, still counts as an error.

Changes since #16204

  • Rebased onto main: tailConsumers is now experimental.streamingTailConsumers, and the collector's entry no longer needs streaming: true.
  • src/runtime/config/generated/workerd.ts adds tracing from the merged workerd schema. Since main added the cluster field, tracing is pointer 7, not 6. Only the tracing delta is applied, so the rest of the file is unchanged.
  • workerd 🐛 BUG: TypeError: This ReadableStream did not return bytes when using a trpc with SSE #7686 merged without the http_request span it used to open for each request on a socket, so invocation spans are the roots; a comment that mentioned it is gone.
  • The parent re-linking test now consumes its dispatchFetch() bodies.

Changes since review

  • No workerd bump needed any more: main now bundles workerd 1.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.ts is regenerated from it with capnp:workerd instead of edited by hand. Its tracing types match the earlier hand edit (pointer 7); the rest of that diff is other schema changes since the file was last generated.
  • Large OTLP exports no longer lose spans. Each export arrives as one request, so a big one could fill both of the trace writer's batches before the first save finished. The rest were dropped while the endpoint still reported success. The handler now waits for room instead (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.
  • Unit tests for the OTLP decoder (test/workers/otlp-to-store.spec.ts): attribute types, int64 values beyond the safe range, service filtering, the order used for the error column, and truncated or malformed input.
  • The changeset now describes what users see, and notes that locally configured streaming tail workers no longer receive span events.

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: unsafeObservability is 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 with X_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-date and check:package-deps pass.


Devin Review

@changeset-bot

changeset-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 66f5879

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
miniflare Minor
@cloudflare/deploy-helpers Patch
@cloudflare/dev-helpers Patch
@cloudflare/pages-shared Patch
@cloudflare/remote-bindings Patch
@cloudflare/runtime-types Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin Patch
wrangler Patch

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

@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Nov 19, 2026
@github-actions github-actions Bot closed this Nov 19, 2026
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Nov 19, 2026
@workers-devprod
workers-devprod requested review from a team and dario-piotrowicz and removed request for a team November 19, 2026 18:32
@workers-devprod

workers-devprod commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/local-observability-otlp.md: [@cloudflare/wrangler]
  • packages/miniflare/src/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/plugins/core/constants.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/plugins/core/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/plugins/core/observability.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/plugins/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/plugins/workflows/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/runtime/config/generated/workerd.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/runtime/config/workerd.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/workers/observability/collector.worker.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/workers/observability/otlp-to-store.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/workers/observability/tail-to-store.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/workers/observability/trace-store.ts: [@cloudflare/wrangler]
  • packages/miniflare/src/workers/observability/trace-writer.ts: [@cloudflare/wrangler]
  • packages/miniflare/test/plugins/core/observability.spec.ts: [@cloudflare/wrangler]
  • packages/miniflare/test/workers/otlp-to-store.spec.ts: [@cloudflare/wrangler]
  • packages/miniflare/test/workers/trace-writer.spec.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@wperron wperron reopened this Nov 19, 2026
@github-project-automation github-project-automation Bot moved this from Done to Untriaged in workers-sdk Nov 19, 2026

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 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/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 / tracedServices filtering,
  • error precedence: exception, then status message, then error.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 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. (packages/miniflare/src/index.ts:2640)
View full review

Pinned workerd lacks tracing.otlp.

  • Miniflare now sets tracing.otlp at packages/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 ignores tracing.
  • The change also removes tail_worker_user_spans from 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.ts fail on main.
  • The scheduled test in test/plugins/local-explorer/scheduled.spec.ts fails on main.

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_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. (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/traces endpoint 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛑 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 @@
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ 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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ 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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ 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.

@pkg-pr-new

pkg-pr-new Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@17061

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@17061

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@17061

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@17061

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@17061

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@17061

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@17061

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@17061

miniflare

npm i https://pkg.pr.new/miniflare@17061

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@17061

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@17061

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@17061

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@17061

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@17061

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@17061

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@17061

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@17061

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@17061

wrangler

npm i https://pkg.pr.new/wrangler@17061

commit: 66f5879

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the PR @wperron 🙂

Could you please address the various AI review comments? 🙏

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 with tracing.otlp, and the lockfile is updated to match.
  • Compatibility date: DEFAULT_COMPAT_DATE moves 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/traces endpoint: 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.ts now tests the OTLP decoder directly. It covers attribute types, int64 values beyond the safe range, service filtering, the error order, unknown fields, and truncated or malformed input.
  • Generated types: src/runtime/config/generated/workerd.ts is now regenerated from the workerd 1.20261120.1 schema 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 #startBatch or by clear. Each waiter checks again for room before it continues, and the three new tests cover the waiting cases.
  • /v1/traces in collector.worker.ts: the try/finally releases the batch owner on every path.
  • Parent re-linking in trace-store.ts: every statement matches on trace_id as well as the span ID.

⚡ Performance: ✅ LGTM

  • pending_parents growth: the table gets at most one row per stored span, the same rate as the spans and logs, which are also kept until clear(). clear() now empties pending_parents too, 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

@wperron
wperron force-pushed the wperron/observability-otlp branch from 5743090 to 951c951 Compare November 20, 2026 19:17

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

wperron and others added 3 commits November 23, 2026 13:38
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>
@wperron
wperron force-pushed the wperron/observability-otlp branch from 951c951 to 66f5879 Compare November 23, 2026 18:43

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 0 new potential issues.

Devin Review

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

3 participants