Skip to content

docs(rivetkit): add actor tracing docs - #5734

Merged
NathanFlurry merged 7 commits into
stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzzfrom
stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl
Sep 23, 2026
Merged

NathanFlurry merged 7 commits into
stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzzfrom
stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl

Conversation

@eersnington

@eersnington eersnington commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

this stack is a bit chonky to review so I've scoped down a lot of things.

a rundown of what i'm shipping with this otel stack:

  • changes to how ray ID gets passed on within guard service
  • traces for actions, http handlers and sqlite operations
  • traces for actor-to-actor calls
  • linked scheduled actions and queue messages
  • actor logs with ray and trace IDs (pino)
  • otel sdk warnings and errors through from core to pino
  • export to an OTLP backend

not within this stack

  • workflows support (will be up next if this looks good cause it's another 800+ loc PR)
  • rust sdk support
  • websocket traces support (req another migration too to ActionRequest type)
  • wasm runtime support
  • native effect tracing support

and regarding this pr, i'm hosting the docs here (@NathanFlurry made a lot of changes as per our last call). lmk if you're picky about anything and want more things changed.

https://docs-otel-e2e.eers.dev/actors/docs/general/tracing/

diagrams added
image

image

notes for @MasterPtato or anyone puling this to staging.
tracing is feature flagged with the traces endpoint env var. if that's not set, it's disabled.

OTEL_SERVICE_NAME=<val>
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://collector:4318/v1/traces
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf 
# or grpc

you can technically read the "Quickstart" within the docs and should be able to configure it within the cloud. if anything is unclear in that, lmk, I'll fix things up.

and also this #5729 bumps the internal schema version from 1 to 2 to store ray ID and tracecontext to the schedules and queues table.

@the-company-company the-company-company 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.

🟠 2 medium · 🔵 1 low

Reviewed commit 5d35d78.

Comment thread docs/content/docs/general/tracing.mdx
Comment thread docs/content/docs/general/tracing.mdx
Comment thread examples/docs/general-tracing/caller-ray-id.ts Outdated
@claude

claude Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Review (updated for latest push through commit 4d34551)

This is a substantial, well-executed feature. The trace-context propagation logic (invocation to application span to workflow run/step, ray-id handoff via queue messages, otel.status_code/error.type conventions) is careful and consistently applied across the Rust core, NAPI bridge, and TypeScript layers, and it's backed by a genuinely thorough integration test (actor-telemetry.test.ts, the workflow describe block) plus a query-efficiency test for the new _rivet_wf_kv read, per this repo's SQLite testing policy. The workflow trace-context key ([6, 1, 0x15, 5]) correctly reuses the fdb-tuple encoding of 5, which is reserved in workflow-engine/src/keys.ts's KEY_PREFIX, so Core's direct write can't collide with the workflow engine's own KV keys.

Bug: driver.test.ts will throw with the new ActorWorkflowDriver code path

rivetkit-typescript/packages/rivetkit/src/workflow/driver.ts's #untraced helper (added in this PR) now does:

#untraced<T>(run: () => Promise<T>): Promise<T> {
	return this.#runCtx.internalKeepAwake(
		this.#runCtx.run.runOutsideWorkflowSpan(run),
	);
}

get, set, delete, batchDelete, deletePrefix, deleteRange, list, and batch all route through #untraced, so they now dereference this.#runCtx.run.

src/workflow/driver.test.ts (unmodified by this PR) constructs:

const runCtx = {
	sql,
	internalKeepAwake: async <T>(promise: Promise<T>) => await promise,
};
const driver = new ActorWorkflowDriver(actor as never, runCtx as never);

This mock has no run field at all - the as never cast is what lets it slip past the type checker even though RunContext.run: ActorRun is required. The test "delegates actor state and the whole workflow batch to one atomic runtime call" then calls driver.batch(writes) with a non-empty writes array, which will hit #untraced -> this.#runCtx.run.runOutsideWorkflowSpan -> TypeError: Cannot read properties of undefined (reading 'runOutsideWorkflowSpan').

Before this PR, batch() called internalKeepAwake directly on the write promise and never touched runCtx.run, so the test passed. This looks like a genuine regression that CI should catch; the fix is to add run: { runOutsideWorkflowSpan: (body) => body(), startWorkflowSpan: async () => ({ ... }) } (or at least runOutsideWorkflowSpan) to the test's runCtx mock.

Minor / non-blocking observations

  • docs-internal/engine/rivetkit-telemetry.md and docs/content/docs/general/tracing.mdx are thorough and the "Gaps"/"Known limitations" sections are honest about what isn't covered yet (WebSocket handlers, .connect() actions starting new traces, wasm). Good practice, nothing to fix.
  • WorkflowRunOutcome::is_error() treats Evicted as non-error (otel.status_code = OK), same as Sleeping. That matches the "known limitation" framing (mid-flight interruption isn't a workflow failure), but worth double-checking that's the intended semantics for dashboards/alerting built on this span, since "evicted" sounds alarm-worthy at first glance.
  • runOutsideWorkflowSpan's reliance on AsyncLocalStorage.exit() in NapiCoreRuntime.runOutsideActorInvocationContext to keep workflow-history KV writes out of the run's trace is a subtle mechanism (context is captured per-async-resource at creation time, not at the call site). It's exercised by the new driver test ("puts a queue send made inside a step in that step's trace" et al.), so it's not unverified, but it's worth a short inline comment given how easy this pattern is to get subtly wrong in a future refactor.

No security concerns: the new correlation data (ray IDs, W3C trace headers) is documented as "correlation, not identity or authorization," and the data-policy section explicitly excludes SQL text/bindings, actor state, and raw error messages from spans.

@eersnington
eersnington force-pushed the stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz branch from a550f80 to e34c47e Compare September 16, 2026 01:18
@eersnington
eersnington force-pushed the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch from 5d35d78 to 6c2a881 Compare September 16, 2026 01:18

@the-company-company the-company-company 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.

✅ No issues found

Reviewed commit 6c2a881.

@eersnington
eersnington force-pushed the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch from 6c2a881 to d18e8f9 Compare September 16, 2026 17:51
@eersnington
eersnington force-pushed the stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz branch from e34c47e to 0f3841f Compare September 16, 2026 17:51

@the-company-company the-company-company 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.

🟠 1 medium-severity finding

Reviewed commit d18e8f9.

Comment thread docs-internal/engine/rivetkit-telemetry.md
@eersnington
eersnington force-pushed the stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz branch from 0f3841f to c2a3397 Compare September 16, 2026 18:08
@eersnington
eersnington force-pushed the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch from d18e8f9 to 45ae99c Compare September 16, 2026 18:08

@the-company-company the-company-company 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.

✅ No issues found

Reviewed commit 45ae99c.

@eersnington
eersnington force-pushed the stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz branch from c2a3397 to e10de14 Compare September 16, 2026 18:16
@eersnington
eersnington force-pushed the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch 2 times, most recently from 4976b3e to 5aa5975 Compare September 16, 2026 18:24
@eersnington
eersnington force-pushed the stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz branch from e10de14 to 5fd3076 Compare September 16, 2026 18:24
@eersnington
eersnington force-pushed the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch from 5aa5975 to 67deba1 Compare September 16, 2026 18:34
@eersnington
eersnington force-pushed the stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz branch 2 times, most recently from 2c70404 to a78f5c5 Compare September 16, 2026 18:42
@eersnington
eersnington force-pushed the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch from 67deba1 to 63b46d5 Compare September 16, 2026 18:42
@eersnington
eersnington force-pushed the stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz branch from a78f5c5 to 8443f5d Compare September 16, 2026 19:13
@eersnington
eersnington force-pushed the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch 2 times, most recently from 50b6370 to abe4606 Compare September 16, 2026 20:28
@eersnington
eersnington force-pushed the stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz branch 2 times, most recently from 39bc2f6 to 403bbe7 Compare September 17, 2026 15:14
@eersnington
eersnington force-pushed the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch from abe4606 to 261c750 Compare September 17, 2026 15:14
@eersnington
eersnington force-pushed the stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz branch from 403bbe7 to a249107 Compare September 18, 2026 22:40
@eersnington
eersnington force-pushed the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch from 261c750 to 53f1337 Compare September 18, 2026 22:40
@eersnington
eersnington force-pushed the stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz branch from a249107 to 86c5005 Compare September 19, 2026 01:01
@eersnington
eersnington force-pushed the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch 2 times, most recently from 061c0ec to a182e43 Compare September 21, 2026 22:56
@eersnington
eersnington force-pushed the stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz branch from 86c5005 to 80a413c Compare September 21, 2026 22:56
@eersnington
eersnington force-pushed the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch from a182e43 to 465da0d Compare September 22, 2026 15:28
feat(rivetkit): otel trace workflow runs and steps
@NathanFlurry
NathanFlurry merged commit 4538fe3 into stack/feat-rivetkit-forward-otel-sdk-warnings-to-the-pino-logger-vmosovzz Sep 23, 2026
6 of 10 checks passed
@NathanFlurry
NathanFlurry deleted the stack/docs-rivetkit-add-actor-tracing-docs-mqqwnuwl branch September 23, 2026 08:01
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