-
Notifications
You must be signed in to change notification settings - Fork 129
chore(tracing-utils): add tracing utils for custom instrument #3293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(tracing-utils): add tracing utils for custom instrument #3293
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
More templates
@rivetkit/actor
@rivetkit/cloudflare-workers
@rivetkit/core
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
@rivetkit/engine-runner
@rivetkit/engine-runner-protocol
commit: |
Code ReviewSummaryThis PR extracts tracing utilities from rivet-util into a new dedicated package rivet-tracing-utils. The refactoring improves modularity and allows other packages like universaldb to use these utilities without circular dependencies. Positive AspectsGood refactoring: Extracting the tracing utilities into a separate package is a clean architectural decision that reduces coupling. Consistent usage: The custom_instrument pattern is already extensively used throughout the codebase with 30+ usages in gasoline alone. Proper re-export: The rivet-util/src/future.rs correctly re-exports the utilities maintaining backward compatibility. Issues and Concerns1. Unsafe Code Requires Careful ReviewLocation: engine/packages/tracing-utils/src/lib.rs:51-52 The use of get_unchecked_mut and Pin::new_unchecked relies on invariants that should be documented. Recommendation: Add safety comments explaining why these operations are safe. This is likely copied from existing patterns but explicit safety documentation is important for maintainability. 2. Metadata Cloning May Be UnnecessaryLocation: engine/packages/tracing-utils/src/lib.rs:54 The Metadata type is typically &static so cloning may be unnecessary. Consider using a reference instead to avoid an unnecessary allocation. 3. Potential Metric Recording OverheadLocation: engine/packages/tracing-utils/src/lib.rs:57-68 The metric is only recorded on Poll::Ready which is good. However every polled future records a metric which could create high cardinality with the location and name attributes. Questions:
4. Missing DocumentationThe new package lacks:
5. Meter Name InconsistencyLocation: engine/packages/tracing-utils/src/lib.rs:83 The meter is named rivet-util-core but this is now in the rivet-tracing-utils package. Consider updating to meter rivet-tracing-utils to ensure metrics are properly attributed. 6. No TestsThe new package has no tests. While the code is extracted from existing working code having unit tests would help ensure the custom instrumentation works correctly and the unsafe code maintains Pin guarantees. Minor Observations
Recommendations Summary
Overall this is a solid refactoring that improves the codebase structure. The main concerns are around documentation and ensuring the unsafe code is well-justified. |
1183a0d to
f6e4232
Compare
83e6a47 to
d41caab
Compare
PR Review: Add tracing utils for custom instrumentSummaryThis PR extracts tracing instrumentation utilities from Code Quality & Best Practices ✅Positives:
Minor Suggestions:
Potential Bugs or Issues
|
Code ReviewThis PR refactors tracing instrumentation utilities into a new dedicated package. Overall, the refactoring is well-structured, but I've identified several issues that should be addressed. 🔴 Critical Issues1. Unsafe Code Without Safety Documentation // engine/packages/tracing-utils/src/lib.rs:51-52
let this = unsafe { self.get_unchecked_mut() };
let inner = unsafe { Pin::new_unchecked(&mut this.inner) };Issue: The use of Recommendation: Add SAFETY comments above each unsafe block explaining:
This is especially important for Pin-related unsafe code, which has subtle correctness requirements. 2. Incorrect Meter Name // engine/packages/tracing-utils/src/lib.rs:83
static ref METER: Meter = meter("rivet-util-core");Issue: The meter name is Recommendation: Change to: static ref METER: Meter = meter("rivet-tracing-utils");
|

No description provided.