Skip to content

Conversation

@Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Jan 26, 2026

This should result in Sentry displaying a link from the task execution trace (where 'await_event' is called) back to the trace that performed the 'emit_event' call

This is stored in a new 'metadata' json column in the events table, which we can use to add additional per-event information in the future (without needing to wrap the user-provided payload)


Note

Adds first-class event metadata for system data (e.g., tracing) and wires it through emit/await paths.

  • Schema: Event tables now include metadata jsonb; ensure_queue_tables creates it with comments
  • Migration: Alters all existing e_* tables, drops/recreates emit_event (now (queue, name, payload, metadata)) and await_event (now returns (should_suspend, payload, metadata))
  • SQL logic: await_event fetches and returns metadata; checkpoint returns omit metadata; emit_event upserts metadata along with payload
  • Rust client/context: emit_event_with injects trace context into event metadata (when telemetry enabled); await_event/join receive metadata and link traces; AwaitEventResult updated
  • Errors/tests: New TaskError::EmitEventFailed; tests and queries updated to new function signatures

Written by Cursor Bugbot for commit 88c631f. This will update automatically on new commits. Configure here.

This should result in Sentry displaying a link from the task
execution trace (where 'await_event' is called) back to the trace
that performed the 'emit_event' call

This is stored in a new 'metadata' json column in the events table,
which we can use to add additional per-event information in the future
(without needing to wrap the user-provided payload)
@Aaron1011 Aaron1011 marked this pull request as ready for review January 26, 2026 18:18
@Aaron1011 Aaron1011 closed this Jan 26, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


// Check cache for already-received event
if let Some(cached) = self.checkpoint_cache.get(&checkpoint_name) {
// No trace linking needed - already done on original receipt
Copy link

Choose a reason for hiding this comment

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

Trace linking fails when task wakes from suspension

High Severity

The trace context metadata is never linked when a task resumes after being woken by emit_event. When emit_event wakes a sleeping task, it creates a checkpoint containing only the payload (not the metadata). On resume, TaskContext::create loads this checkpoint into checkpoint_cache. When await_event is called, it hits the cache at line 353 and returns directly, bypassing the SQL query that would fetch metadata from the events table. The trace linking code at lines 392-395 is never reached, breaking the PR's stated goal of linking traces from await_event to emit_event.

Additional Locations (1)

Fix in Cursor Fix in Web

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