Skip to content

feat(rivetkit): actor tracing, invocation metrics, and log correlation with otel - #5674

Open
eersnington wants to merge 13 commits into
rivet-dev:mainfrom
eersnington:stack/feat-rivetkit-actor-telemetry
Open

feat(rivetkit): actor tracing, invocation metrics, and log correlation with otel#5674
eersnington wants to merge 13 commits into
rivet-dev:mainfrom
eersnington:stack/feat-rivetkit-actor-telemetry

Conversation

@eersnington

Copy link
Copy Markdown

People of Rivet, this change adds built-in support for OpenTelemetry to Rivetkit for making it easy for users to observe every actor action, scheduled actor action, actor to actor calls, and SQLite operations with relevant trace context and ray identifier.

More in depth:

  • Added enriched trace context like rayId, trace_id, and span_id to c.log
  • Added opentelemetry, opentelemetry_sdk, opentelemetry-otlp, tracing-opentelemetry to rivetkit-napi
  • Added support for OTEL_* environment configurations (separate from RIVET_OTEL_* engine configs) to control trace endpoints, Batch Span Processor (its queue size, export batch size, and delay between exports), and sampling methods
  • Added native export to support OTLP over http/protobuf, http/json, and grpc
  • Added telemetry metrics such as Invocation counts and durations. They follow standard Prometheus format (https://prometheus.io/docs/instrumenting/exposition_formats/)
  • Rivetkit Otel SDK warnings passes down into pino logs for cases like when the BSP overflows and drops spans.

(To maintain the sanctity of this codebase's contribution guidelines)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Passes 345 rivetkit-core tests
  • Added e2e NAPI integration tests for action spans and scheduled trace origins
  • Added an e2e test for concurrent actions on the same actor to ensure each keeps its own trace context and not see each other's context.
  • Added e2e test for failure paths like OTel collector being unreachable, or accepts requests but never responds. In both cases, action still succeeds as normal.
  • Overhead measured with tracing off and on, with Rust and JS profiles too (shared in Discord).
  • These changes have been tested on a self hosted GKE cluster with an OTLP collector and Jaeger configured.
  • Changes have been independently reviewed by me, and with the help of Fable 5.1

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@eersnington

Copy link
Copy Markdown
Author

at the behest of the living tribunal of code reviews, a codiff walkthrough has been bestowed upon you

https://codiff.eers.dev/w/JRyyW8zaCbTaFzZuW2l2lHu_

@eersnington
eersnington marked this pull request as ready for review September 5, 2026 20:16
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.

1 participant