-
Notifications
You must be signed in to change notification settings - Fork 150
feat(frontend): traces ui #4038
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
base: traces-storage
Are you sure you want to change the base?
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
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/virtual-websocket
@rivetkit/cloudflare-workers
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
@rivetkit/traces
@rivetkit/workflow-engine
@rivetkit/engine-runner
@rivetkit/engine-runner-protocol
commit: |
PR Review: Traces UIThis PR adds a comprehensive tracing UI along with a queue inspector feature. Overall, the implementation is solid with good architectural decisions. Below are my findings: ✅ StrengthsArchitecture & Design
Code Quality
🔍 Issues & Recommendations1. Performance ConcernsCritical: Unbounded recursion in trace rendering (actor-traces.tsx:247-291)function renderItemsWithGaps(items: TraceItem[], depth: number, nowNs: bigint): ReactElement[]
const MAX_DEPTH = 20;
if (depth >= MAX_DEPTH) {
return [<div key="max-depth" className="text-xs text-muted-foreground ml-4">Max nesting depth reached...</div>];
}Memory: Large trace arrays kept in memory (actor-traces.tsx:113-119)const traceTree = useMemo(() => {
if (!queryResult) return [];
const spans = extractSpans(queryResult.otlp);
return buildSpanTree(spans);
}, [queryResult]);
Sorting performance (read-range.ts:129-133)records.sort((a, b) => {
if (a.absNs < b.absNs) return -1;
if (a.absNs > b.absNs) return 1;
return a.sequence - b.sequence;
});
2. Bug: Potential race condition in queue size updatesLocation: this.#actor.inspector.updateQueueSize(this.#metadata.size);
await this.#driver.kvBatchPut(this.#actor.id, [...]);
// Only update inspector after successful write
this.#actor.inspector.updateQueueSize(this.#metadata.size);3. Code Quality IssuesMissing null checks (actor-traces.tsx:463-464)const parentId = node.span.parentSpanId;
if (parentId && byId.has(parentId)) {
byId.get(parentId)?.children.push(node); // Optional chaining after has() check is redundant
}
if (parentId) {
const parent = byId.get(parentId);
if (parent) parent.children.push(node);
}Inconsistent error handling (actor-queue.tsx:32-38)if (queueStatusQuery.isError || !queueStatusQuery.data) {
return <div>Queue data is currently unavailable.</div>;
}
Magic numbers should be constants// actor-traces.tsx:102
refetchInterval: isLive ? 1000 : false,
4. Testing ConcernsNo tests for new functionality
Test cleanup improvement needed (test/mod.ts:83-85)c.onTestFinished(async () => {
await new Promise((resolve) => server.close(() => resolve(undefined)));
});
5. DocumentationMissing JSDoc comments
Changelog/migration notes needed
🔒 Security✅ Good practices observed:
|
846c70c to
7504a0b
Compare
4189086 to
389f28e
Compare
389f28e to
3c7fabc
Compare
PR Review: Traces UIOverviewThis PR adds a comprehensive traces visualization UI and queue monitoring feature to the frontend, along with supporting infrastructure for reading and processing OTLP traces. The changes span 31 files with significant additions to the traces package and new UI components. ✅ Strengths
🔍 Code Quality Issues1. Missing error handling in CBOR decodingLocation: read-range.ts:385-388, read-range.ts:398-405 Silent failure in catch blocks could hide data corruption or protocol mismatches. Consider logging warnings in development. 2. Type safety concerns with as unknown castsLocation: actor-traces.tsx:526, read-range.ts:385 Multiple uses of as unknown bypass type checking. While CBOR decoding necessitates some dynamic typing, consider using Zod schemas or runtime validation for critical data paths. 3. Potential performance issue with BigInt conversionsLocation: actor-traces.tsx:122, 318, 400, 476-480 Repeated BigInt() conversions in render loops and sorting functions. Consider memoizing or caching these conversions. 4. Inconsistent null handlingLocation: actor-traces.tsx:308 Uses == null instead of === null, inconsistent with TypeScript best practices. 🐛 Potential Bugs1. Race condition in refetch intervalLocation: actor-traces.tsx:102 With a 1-second refetch interval and live mode, rapid state updates could cause query cache thrashing. Consider increasing the interval to 2-3 seconds or using WebSocket streaming instead of polling. 2. Unsafe array accessLocation: read-range.ts:283, 336, 359 Good use of nullish coalescing with strings array access, but consider validating string indices are in bounds to prevent subtle bugs. ⚡ Performance Considerations1. Large trace data handlingLocation: actor-traces.tsx:137-138 The buildSpanTree function processes all spans in memory. For large traces (approaching the 1000 span limit), consider implementing virtual scrolling or pagination. 2. Unnecessary sorting on every renderLocation: actor-traces.tsx:252-254 Creates a new sorted array on every render. Should be memoized with useMemo. 🔒 Security Concerns1. CBOR deserialization of untrusted dataLocation: Multiple files CBOR data is decoded from WebSocket messages and trace data without size limits or schema validation. Consider implementing size limits for decoded objects and using Zod schemas to validate structure after decoding. 🧪 Test CoverageMissing test coverage for:
Recommendation: Add unit tests for core trace processing logic, especially the span tree building and time-based filtering. ✨ Positive Patterns
📋 SummaryOverall Assessment: This is a solid implementation of a complex feature. The core logic is sound, but there are several areas for improvement around error handling, performance optimization, and type safety. Priority Fixes (before merge):
Recommended Follow-ups (post-merge):
Verdict: ✅ Approve with minor revisions recommended |

No description provided.