Skip to content

STOR-5760: Let embedders set an onHibernate handler's trace - #8871

Merged
apeacock1991 merged 1 commit into
mainfrom
apeacock/do-on-hibernate-otlp-export
Nov 24, 2026
Merged

apeacock1991 merged 1 commit into
mainfrom
apeacock/do-on-hibernate-otlp-export

Conversation

@apeacock1991

@apeacock1991 apeacock1991 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Worker::Actor::runOnHibernate() always started the handler's invocation in a trace that workerd chose. An embedder that starts a trace for the handler, as it does for the actor's other events, couldn't pass it in. The handler's spans and logs then carried a different trace ID from the one that its subrequests propagate.

runOnHibernate() now takes the trace for the handler to run in, which it passes to the handler's IoContext::IncomingRequest as its trigger context. The handler still runs outside any request, so the embedder gives it a trace of its own; it isn't nested under the request or alarm that last ran. The local server passes none, so its handlers start their own traces as before.

The new incoming-request-test case checks that the handler's invocation uses the trace it's given, and fails without the change. Embedders that call runOnHibernate() need updating for the new parameter.

@apeacock1991
apeacock1991 requested review from a team as code owners November 24, 2026 11:18

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

Copy link
Copy Markdown

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 d1529da8.

This review, of 475fd79b

✅ Approved — No issues found: the trigger context is passed through to the handler's IncomingRequest correctly, callers that pass none behave as before, and the new test covers the change.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No security concerns. The change only passes in trace context that the embedder supplies.


📋 Code Quality: ✅ LGTM

  • triggerContext is passed through runOnHibernate() and runOnHibernateImpl() to the IoContext::IncomingRequest constructor, in the slot that used to hold kj::none /* maybeTriggerInvocationSpan */.
  • InvocationSpanContext::newForInvocation() takes the trace ID from the trigger context when one is passed. With kj::none it behaves as before.
  • The local server's caller (worker-factory.c++) passes kj::none.
  • The new test passes a trigger context with a known trace ID and checks that the handler's invocation uses it.

📝 Documentation: ✅ LGTM

The updated header comment for runOnHibernate() describes the new parameter accurately.


Reviewed commit: 475fd79b

@apeacock1991
apeacock1991 force-pushed the apeacock/do-on-hibernate-otlp-export branch from 475fd79 to d1529da Compare November 24, 2026 11:38
@apeacock1991 apeacock1991 changed the title STOR-5760: Let onHibernate handlers continue an embedder's trace STOR-5760: Let embedders set an onHibernate handler's trace Nov 24, 2026

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

Copy link
Copy Markdown

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 25b19676.

This review, of d1529da8

✅ Approved — No issues found. triggerContext is passed through to the handler's IoContext::IncomingRequest correctly, the local server passes kj::none and behaves as before, and the updated test and header comment match the code.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No security concerns. The change only passes in trace context that the embedder supplies. No trust boundary is crossed and no check is removed.


📋 Code Quality: ✅ LGTM

No issues found in the four changed files.

  • Call sites: Both callers of runOnHibernate() pass the new triggerContext argument in the right position. The local server (worker-factory.c++) passes kj::none, and the test helper forwards the value it is given.
  • Trace ID path: worker.c++ passes triggerContext to IoContext::IncomingRequest in the slot that used to hold kj::none. When a trigger context is given, InvocationSpanContext::newForInvocation() takes its trace ID from it. With kj::none it generates a fresh trace ID, as before.
  • Test: The updated test passes a known TraceId, records the trace ID of the handler's invocation and checks that it matches.

📝 Documentation: ✅ LGTM

The updated header comment for runOnHibernate() in worker.h describes the triggerContext parameter accurately.


Reviewed commit: d1529da8

@apeacock1991
apeacock1991 force-pushed the apeacock/do-on-hibernate-otlp-export branch from d1529da to 25b1967 Compare November 24, 2026 14:49

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

Copy link
Copy Markdown

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 954e9dfd.

This review, of 25b19676

✅ Approved — No issues found. triggerContext reaches the handler's IncomingRequest, the local server behaves as before, and the test covers the change.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No security concerns. The change only passes along trace context that the embedder supplies.


📋 Code Quality: ✅ LGTM

No issues found.

  • Call sites: Every caller of runOnHibernate() passes the new argument. The local server passes kj::none, and the test helper forwards the context it is given.
  • Trace path: worker.c++ forwards triggerContext to IoContext::IncomingRequest in the maybeTriggerInvocationSpan slot. The types match.
  • Test: The new case passes a known trace ID and checks it against the trace ID recorded at setEventInfo(), which runs on the code path this change touches.

📝 Documentation: ✅ LGTM

The runOnHibernate() header comment in worker.h describes the triggerContext parameter accurately.


Reviewed commit: 25b19676

Worker::Actor::runOnHibernate() always started the handler's
invocation in a trace that workerd chose. An embedder that starts a
trace for the handler, as it does for the actor's other events,
couldn't pass it in. The handler's spans and logs then carried a
different trace ID from the one that its subrequests propagate.

runOnHibernate() now takes the trace for the handler to run in, which
it passes to the handler's IoContext::IncomingRequest as its trigger
context. The handler still runs outside any request, so the embedder
gives it a trace of its own. The local server passes none, so its
handlers start their own traces as before.
@apeacock1991
apeacock1991 force-pushed the apeacock/do-on-hibernate-otlp-export branch from 25b1967 to 954e9df Compare November 24, 2026 16:08

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — No issues found. triggerContext reaches the handler's IncomingRequest, the local server behaves as before, and the test covers the change.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No security concerns. The change only passes along trace context that the embedder supplies.


📋 Code Quality: ✅ LGTM

No issues found.

  • Call sites: Every caller of runOnHibernate() passes the new argument. The local server passes kj::none, and the test helper forwards the context it is given.
  • Trace path: worker.c++ forwards triggerContext to IoContext::IncomingRequest in the maybeTriggerInvocationSpan slot. The types match.
  • Test: The new case passes a known trace ID and checks it against the trace ID recorded at setEventInfo(), which runs on the code path this change touches.

📝 Documentation: ✅ LGTM

The runOnHibernate() header comment in worker.h describes the triggerContext parameter accurately.


Reviewed commit: 954e9dfd — same changes as 25b19676, so this is that commit's review (no new review was run; line numbers are as of 25b19676)

@apeacock1991
apeacock1991 merged commit 9576f64 into main Nov 24, 2026
23 checks passed
@apeacock1991
apeacock1991 deleted the apeacock/do-on-hibernate-otlp-export branch November 24, 2026 16:38
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.

2 participants