feat(rivetkit): trace sqlite operations - #5727
Conversation
| args, | ||
| conn, | ||
| scheduled_fire, | ||
| invocation_telemetry: _, |
There was a problem hiding this comment.
🟠 Medium · Preserve telemetry for Rust action SQLite calls
The Rust event adapter explicitly discards the telemetry attached by ActorTask here. Rust actors obtain their long-lived Ctx independently of RuntimeEvent, so no call path binds that invocation to Ctx::sql(); its SqliteDb consequently retains invocation_telemetry: None. A traced Rust actor action that executes SQL will emit only rivet.actor.invoke, without the SQLite child spans this change adds.
Carry the invocation telemetry through the Rust action execution boundary (or bind it task-locally while handling the event) so the action's SQLite handle is invocation-bound.
| /// Returns the SQLite handle bound to this handle's invocation. | ||
| pub fn invocation_sql(&self) -> SqliteDb { | ||
| self.0.sql.clone().with_invocation_telemetry(self.1.clone()) |
There was a problem hiding this comment.
🟠 Medium · Trace state transaction SQLite operations
begin_state_transaction still calls self.sql().begin_transaction(...), and ActorStateTransaction retains that resulting transaction. sql() returns the unbound database from the shared inner context, whereas this new helper is the only place that applies the action's telemetry. Thus TypeScript actions using c.db.transaction(..., { experimental: { includeState: true } }) do not emit spans for their begin, execute, commit, or rollback calls.
Use the invocation-bound database when opening a state transaction (and add coverage for the includeState path).
|
Code Review Reviewed with the repo's Findings 1. Queue, schedule, and legacy-KV SQL paths bypass the new tracing ( 2. Scheduled/cron-fired actions never get an invocation span at all ( 3. The Rust flagship SDK ( 4. Performance regression: the NAPI SQL wrapper is rebuilt on every SQL call ( 5. Summary No security concerns identified (SQL execution paths are unchanged; this PR only adds tracing spans around existing calls). Test coverage for the new spans wasn't visible in the diff context reviewed, consider adding an assertion that 🤖 Generated with Claude Code |
4a9bbf0 to
eabdcd1
Compare
| args, | ||
| conn, | ||
| scheduled_fire, | ||
| invocation_telemetry: _, |
There was a problem hiding this comment.
🟠 Medium · Preserve telemetry for Rust action SQLite calls
The Rust event adapter still discards the telemetry attached by ActorTask here. Rust actors obtain their long-lived Ctx independently of RuntimeEvent, so no execution path binds that invocation to Ctx::sql(); its SqliteDb retains invocation_telemetry: None. A traced Rust actor action that executes SQL therefore emits only rivet.actor.invoke, without the SQLite child spans this change adds.
Carry the invocation telemetry through the Rust action execution boundary (or bind it task-locally while handling the event) so the action's SQLite handle is invocation-bound.
bad bot. im testing exported behavior through a real collector
intentional. each operation needs the current invocation's context. the underlying db is still shared
hpa go brrrrr
schedules followed up in #5729, http stuff in #5731, queues in #5730
followed up in#5729
execute_batch intentionally gets one span, including its internal transaction |
eabdcd1 to
5347b7a
Compare
5347b7a to
4959860
Compare
4959860 to
030a7da
Compare
030a7da to
2d19537
Compare
2d19537 to
00f657d
Compare
00f657d to
9f70d0d
Compare
3ba9516 to
701bd58
Compare
701bd58 to
7493eb7
Compare
7493eb7 to
9b37630
Compare
NathanFlurry
left a comment
There was a problem hiding this comment.
Reviewed as part of the tracing stack.
execute_batchgets one span for the whole batch.