Skip to content

Tankcorn/preview observability streaming#6411

Open
Ankcorn wants to merge 6 commits intocloudflare:mainfrom
Ankcorn:tankcorn/preview-observability-streaming
Open

Tankcorn/preview observability streaming#6411
Ankcorn wants to merge 6 commits intocloudflare:mainfrom
Ankcorn:tankcorn/preview-observability-streaming

Conversation

@Ankcorn
Copy link
Copy Markdown
Member

@Ankcorn Ankcorn commented Mar 25, 2026

This PR adds preview metadata to the streaming tail worker onset event.

It follows the same pattern already used for scriptVersion: the metadata is attached to Onset::WorkerInfo, serialized through the onset RPC
payload, and exposed in the JS event delivered to streaming tail workers.

What changed

Streaming tail onset events now include:

preview: {
     id,
     slug,
     name
}

@Ankcorn Ankcorn requested review from a team as code owners March 25, 2026 10:58
@Ankcorn Ankcorn force-pushed the tankcorn/preview-observability-streaming branch from 9722d3a to c848ed4 Compare March 25, 2026 12:12
Comment on lines +79 to +84

JSG_MEMORY_INFO(Preview) {
tracker.trackField("id", id);
tracker.trackField("slug", slug);
tracker.trackField("name", name);
}
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.

Suggested change
JSG_MEMORY_INFO(Preview) {
tracker.trackField("id", id);
tracker.trackField("slug", slug);
tracker.trackField("name", name);
}

Not needed

Copy link
Copy Markdown
Member Author

@Ankcorn Ankcorn Mar 30, 2026

Choose a reason for hiding this comment

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

When I removed these I think it broke the build

Error while processing /home/runner/.cache/bazel/_bazel_runner/be54bd8ac890d1817c772d91eb8f6cb4/sandbox/linux-sandbox/7561/execroot/_main/src/workerd/api/trace.c++.
bazel-out/k8-fastbuild/bin/src/workerd/jsg/_virtual_includes/memory-tracker/workerd/jsg/memory.h:234:8: note: candidate template ignored: could not match 'const kj::Table<T, Indexes...>' against 'const workerd::api::TracePreviewInfo'
234 | void trackField(kj::StringPtr edgeName,
| ^

I have kept them in for now but if there is something I should be doing instead please lmk

@Ankcorn Ankcorn force-pushed the tankcorn/preview-observability-streaming branch 3 times, most recently from 7bf88e0 to d65f6ca Compare March 30, 2026 18:58
@Ankcorn Ankcorn force-pushed the tankcorn/preview-observability-streaming branch from d65f6ca to eba5d79 Compare March 30, 2026 19:13
@Ankcorn Ankcorn requested a review from anonrig March 31, 2026 09:22
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 31, 2026

Merging this PR will improve performance by 15.28%

⚡ 1 improved benchmark
✅ 69 untouched benchmarks
⏩ 129 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
Encode_ASCII_32[TextEncoder][0/0/32] 3 ms 2.6 ms +15.28%

Comparing Ankcorn:tankcorn/preview-observability-streaming (a1dfdeb) with main (866c9c7)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@danlapid
Copy link
Copy Markdown
Collaborator

/bonk review

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

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

Clean, well-structured change. The preview metadata is threaded through all the right layers (capnp schema, C++ serialization/deserialization, clone, streaming tail JS serialization) following the same pattern as scriptVersion. Tests cover the capnp round-trip and clone for the Onset path.

One minor nit (not blocking): The comment on TracePreview in src/workerd/io/trace.h:434 says "Describes a buffered tail worker request" which doesn't accurately describe what it represents. Since it holds preview deployment metadata (id, slug, name), something like "Describes preview deployment metadata associated with a worker" would be clearer. This predates your PR but worth fixing while you're touching this area.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 31, 2026

Review submitted. Here's a summary of my findings:

Verdict: Approved

The PR cleanly adds preview deployment metadata (id, slug, name) to the streaming tail worker onset event. It touches all the right layers:

  1. worker-interface.capnp - Adds preview @10 :TracePreviewInfo to the Onset struct with the correct next ordinal
  2. trace.h - Adds kj::Maybe<TracePreview> preview to Onset::WorkerInfo
  3. trace.c++ - Adds deserialization (getPreviewFromReader), serialization (copyTo), and clone() support
  4. tracer.c++ - Copies preview from Trace into the WorkerInfo when constructing the onset event
  5. trace-stream.c++ - Serializes preview to JS object with id, slug, name fields (the ToJs path for streaming tail workers)
  6. trace-test.c++ - Tests capnp round-trip and clone for the Onset path

The implementation follows the exact same pattern as scriptVersion, which is the right approach. One minor nit about an inaccurate pre-existing comment on TracePreview.

github run

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants