Skip to content

Add observation for serde_bare - #5321

Open
MasterPtato wants to merge 1 commit into
stack/add-observation-and-ser-de-metrics-for-serde-calls-ztnuwvtsfrom
stack/add-observation-for-serde_bare-oskoutmw
Open

Add observation for serde_bare#5321
MasterPtato wants to merge 1 commit into
stack/add-observation-and-ser-de-metrics-for-serde-calls-ztnuwvtsfrom
stack/add-observation-for-serde_bare-oskoutmw

Conversation

@MasterPtato

@MasterPtato MasterPtato commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@MasterPtato

MasterPtato commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Stack for rivet-dev/rivet

Get stack: forklift get 5321
Push local edits: forklift submit
Merge when ready: forklift merge 5321

change oskoutmw

@claude

claude Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Code Review

Summary

This PR adds observability (latency timing + serialize/deserialize size histograms) to raw serde_bare call sites by routing them through the rivet_util::serde::bare_from_slice! / bare_to_vec! macros, and does the same for one serde_json::from_str call in gasoline via json_from_str!. Mechanical, wide-reaching, but low risk in intent.

Issues Found

Build-breaking: rivet-depot-protocol is missing the rivet-util dependency

engine/sdks/rust/depot-protocol/src/versioned.rs now calls rivet_util::serde::bare_from_slice!(payload) and rivet_util::serde::bare_to_vec!(&data) (lines 24 and 31), but engine/sdks/rust/depot-protocol/Cargo.toml was not updated to add rivet-util.workspace = true. Every other crate touched by this PR (depot, engine, epoxy, gasoline, pegboard-runner, pegboard, runner-protocol, data, envoy-protocol, epoxy-protocol, ups-protocol) already has rivet-util as a dependency, and Cargo.lock confirms rivet-depot-protocol's dependency list still has no rivet-util entry:

```
[[package]]
name = "rivet-depot-protocol"
...
dependencies = [
"anyhow",
"rivet-vbare-compiler",
"serde",
"serde_bare",
"vbare",
]
```

Since rivet_util::... is invoked by its crate path directly in versioned.rs, this needs rivet-util declared in that crate's own Cargo.toml, not just transitively available -- cargo check -p rivet-depot-protocol should fail to resolve the rivet_util crate name. Fix: add rivet-util.workspace = true to engine/sdks/rust/depot-protocol/Cargo.toml (and regenerate the corresponding Cargo.lock entry).

Minor: doc-comment copy/paste error in engine/packages/util/src/serde.rs

Lines 81 and 96 both now read /// Wraps \rivet_util::serde::bare_to_vec!` with observability.Line 81 correctly documentsbare_to_vec!, but line 96 documents bare_from_slice!and should referencebare_from_slice!(or the underlyingserde_bare::from_slice), not bare_to_vec!`.

What Looks Good

  • Every other OwnedVersionedData impl and FormalKey impl in the touched protocol/depot/pegboard crates is consistently migrated, including the version-specific match arms (each version keeps its own deserialize/serialize path, no accidental collapsing of variants).
  • The rivet-util-serde to rivet-util dependency swap in envoy-protocol/Cargo.toml (and the pegboard-runner/Cargo.toml addition) is consistent with the macros living in rivet_util::serde.
  • The compat_ack_tunnel_message change in pegboard-runner/src/ws_to_tunnel_task.rs correctly adds an explicit : protocol_v2::ToServer type annotation since the macro doesn't support a turbofish.
  • The gasoline StateGuard::new change from rivet_util::observe!(serde_json::from_str::<T>(guard.0.get())?) to rivet_util::serde::json_from_str!(guard.0.get())? is semantically equivalent: type inference still resolves T from the surrounding Self { ... inner: value } struct literal, and json_from_str! already wraps with observe! plus adds a size histogram.
  • The engine/packages/engine/src/commands/udb/cli.rs changelog-entry roundtrip check preserves its original early-continue fallback behavior on both the deserialize and reserialize failure paths.
  • No unbounded metric labels introduced -- the location label on SERIALIZE_SIZE/DESERIALIZE_SIZE is a compile-time file:line:column, bounded by call-site count.
  • No wire-format/schema changes; this is purely instrumentation at existing call sites.

Suggestion

Given cargo check -p rivet-depot-protocol (and anything depending on it, e.g. depot) should currently fail, it would be worth confirming CI actually ran a full workspace build/check on this PR before merge.

@MasterPtato
MasterPtato force-pushed the stack/add-observation-and-ser-de-metrics-for-serde-calls-ztnuwvts branch from 7988eba to a0c66b8 Compare June 23, 2026 20:34
@MasterPtato
MasterPtato force-pushed the stack/add-observation-for-serde_bare-oskoutmw branch from 974f99c to c006abf Compare June 23, 2026 20:34
@MasterPtato
MasterPtato changed the base branch from stack/add-observation-and-ser-de-metrics-for-serde-calls-ztnuwvts to main August 7, 2026 00:39
@MasterPtato
MasterPtato force-pushed the stack/add-observation-for-serde_bare-oskoutmw branch from c006abf to 885cd03 Compare August 7, 2026 01:27
@MasterPtato
MasterPtato changed the base branch from main to stack/add-observation-and-ser-de-metrics-for-serde-calls-ztnuwvts August 7, 2026 01:27
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