Repository navigation
Enrich Sentry events with diagnostic context for workflows, cron, MCP, and connectors - #938
Conversation
Attach user/package/export coordinates on workflow auto-captures, tag scheduled lane failures, and copy conversationId/storageId/detail into MCP and remote-connector Sentry scopes so recent production issues are diagnosable without digging through truncated breadcrumbs. Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
📝 WalkthroughWalkthroughThe PR enriches Sentry reporting across scheduled lanes, MCP operations, dynamic workflows, and remote connector sessions with structured scope metadata, identifiers, source details, errors, and connected users. Tests update mocks and assertions for the scoped instrumentation. ChangesScheduled lane observability
MCP observability context
Dynamic workflow observability
Remote connector observability
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant WorkflowRuntime
participant ScopeHelper
participant Sentry
WorkflowRuntime->>ScopeHelper: Apply validated workflow payload and instanceId
ScopeHelper->>Sentry: Set workflow user, tags, and context
WorkflowRuntime->>WorkflowRuntime: Continue scheduling and step execution
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🔎 Preview deployed: https://kody-pr-938.kody-a99.workers.dev Worker: Mocks:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/worker/src/index.workers.test.ts`:
- Around line 342-348: Update the setContext assertion in the scheduled test to
also verify the cron property, using the exact cron value defined by the test
controller fixture. Keep the existing lane and scheduledTime assertions
unchanged so removing or renaming cron causes the test to fail.
In `@packages/worker/src/package-runtime/package-workflows-sentry.node.test.ts`:
- Line 28: Remove the unsupported version: 2 fields from the fresh
WorkflowSentryPayload fixture object literals in the package-workflows-sentry
tests, leaving the remaining payload properties unchanged so they satisfy the
WorkflowSentryPayload type.
In `@packages/worker/src/remote-connector/session.ts`:
- Around line 118-145: Update captureSessionMessage and its socket-originated
callers to accept and pass the triggering websocket’s loadIngressUserId(ws)
result, rather than resolving the first connected socket via
resolveConnectedIngressUserId; keep null for socket-independent events. Add a
test with two sockets and distinct users verifying each captured Sentry event is
attributed to its originating socket’s user.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9318de15-8ab2-4585-8d9f-8e28ff85d8ae
📒 Files selected for processing (12)
packages/worker/src/index.tspackages/worker/src/index.workers.test.tspackages/worker/src/mcp/capabilities/define-capability.tspackages/worker/src/mcp/observability.node.test.tspackages/worker/src/mcp/observability.tspackages/worker/src/mcp/tools/execute.tspackages/worker/src/mcp/tools/search-tool-runner.tspackages/worker/src/package-runtime/package-workflows-sentry.node.test.tspackages/worker/src/package-runtime/package-workflows-sentry.tspackages/worker/src/package-runtime/package-workflows.tspackages/worker/src/remote-connector/session.node.test.tspackages/worker/src/remote-connector/session.ts
Pass the originating websocket ingress user into remote-connector Sentry captures, assert scheduled cron context, and drop excess version fields from workflow sentry fixtures. Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Summary
Recent production Sentry issues (workflow timeouts, scheduled Analytics Engine failures, MCP storage_query errors, remote-connector session noise) were hard to triage because auto-captures only had environment/release/IP. This PR attaches the coordinates we already have in-process onto Sentry scopes.
workflow.source_type/workflow.kody_idtags and aworkflowcontext (package/export/instance/idempotency) at the start ofDynamicCallableWorkflowsoinstrumentWorkflowWithSentryauto-captures are diagnosable.scheduled.laneand include cron/scheduledTime context on lanecaptureException.conversationId,storageId, and call-sitedetailinto the Sentrymcpcontext (kept off tags to avoid high cardinality).connectorIdto a tag, attribute captures to the originating socket's ingress user, and move extras into aremote_connectorcontext.Test plan
npm run typecheck/npm run lint/ focused vitestSystem recap — extends existing primitives (medium risk)
Mode: recap · Base:
main@7d88928a· Head:59f252c0Classification: extends — observability capture sites gain richer tags/contexts; no new primitives and no behavior changes outside Sentry reporting.
Primitives touched
workflowsscheduled-cronmcp-servercapability-registrypackage-runtimeremote-connectors/connector-ingressSystem map
How failures reach Sentry, and which coordinates this PR attaches at each capture site.
Legend: green = composes · amber = extended · gray = context
flowchart LR subgraph surfaces["surfaces"] MCP["mcp-server"] CRON["scheduled-cron"] ING["connector-ingress"] end subgraph assistant["assistant"] WF["workflows"] CAP["capability-registry"] RC["remote-connectors"] end subgraph runtime["runtime"] PR["package-runtime"] end Sentry[(Sentry)] CAP -->|storageId on logMcpEvent| MCP MCP -->|mcp context + detail| Sentry WF -->|user + workflow context| Sentry PR -.->|helper| WF CRON -->|scheduled.lane tag| Sentry ING --> RC RC -->|remote_connector.id + socket user| Sentry style WF fill:#f5c542,stroke:#333,color:#000 style CRON fill:#f5c542,stroke:#333,color:#000 style MCP fill:#f5c542,stroke:#333,color:#000 style RC fill:#f5c542,stroke:#333,color:#000 style ING fill:#f5c542,stroke:#333,color:#000 style CAP fill:#8fd19e,stroke:#333,color:#000 style PR fill:#8fd19e,stroke:#333,color:#000 style Sentry fill:#c8c8c8,stroke:#333,color:#000Risk and invariants
user.idis set (no email/PII);sendDefaultPiiremains false.conversationId,storageId, workflow instance ids) stay on contexts, not tags.Docs
No docs updates — contributor-facing observability detail only.
Summary by CodeRabbit
Observability
Bug Fixes