Improve observability stream previews#1525
Conversation
Summary by CodeRabbitRelease Notes
WalkthroughThis PR adds profile-aware preview formatting for stream events. It introduces EVLOG and OTEL profile-aware preview builders (compact HTTP-style request summaries for evlog, concise span summaries for otel-traces) and integrates them into normalizeStreamEvents, normalizeStandaloneRoutingKeyEvents, and normalizeStreamSearchHits by passing stream.profile into createPreview. The stream input type now includes profile. Unit tests and documentation/changeset updates accompany the implementation. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Comment |
|
Compute preview deployed. Branch: |
There was a problem hiding this comment.
Warning
CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.
Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ui/hooks/use-stream-events.ts`:
- Around line 260-264: The parsePreviewStatus wrapper is redundant; remove the
parsePreviewStatus function and update its call sites to use parsePreviewString
directly (e.g., replace parsePreviewStatus(...) with parsePreviewString(...));
ensure types remain string | null and behavior unchanged since
parsePreviewString already returns null for empty/compacted strings.
- Line 16: Duplicate constant STREAM_PROFILE_EVLOG is defined in
use-stream-events.ts; remove that local definition and import
STREAM_PROFILE_EVLOG from the module that already exports it
(use-stream-observe-request.ts). Update the top of use-stream-events.ts to
import { STREAM_PROFILE_EVLOG } and delete the const STREAM_PROFILE_EVLOG =
"evlog" declaration so the file uses the shared exported symbol.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 390c7635-b122-4d86-b167-44b077c39e82
📒 Files selected for processing (5)
.changeset/quiet-evlog-preview.mdArchitecture/stream-event-view.mdFEATURES.mdui/hooks/use-stream-events.test.tsxui/hooks/use-stream-events.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ui/hooks/use-stream-events.ts (1)
1077-1131:⚠️ Potential issue | 🟠 Major | ⚡ Quick winInclude
stream.profilein event-query identity to avoid stale preview formats.
previewnow depends onstream.profile(Line 1077, Line 1104, Line 1130), but the collection/query identity still excludes profile. If profile changes without a name/epoch change,getOrCreateRowsCollection(...)can reuse rows normalized under the old profile, so previews remain stale until a hard invalidation.♻️ Suggested fix
export function getStreamEventsQueryScopeKey( streamsUrl: string | undefined, stream: StudioStream | null | undefined, routingKey: string, pageSize: number, pageCount: number, visibleEventCount: bigint, ): string { @@ return [ streamsUrl?.trim() ?? "", stream.name, String(stream.epoch), + String(stream.profile ?? ""), visibleEventCount.toString(), routingKey, String(pageSize), String(pageCount), ].join("::"); } function getStreamSearchEventsQueryScopeKey(args: { @@ return [ streamsUrl?.trim() ?? "", stream.name, String(stream.epoch), + String(stream.profile ?? ""), "search", searchQuery, searchSort.join(","), resolvedVisibleSearchResultCount.toString(), String(pageSize), ].join("::"); }if (isSearchActive) { return [ "streams", streamsUrl, "stream", stream.name, "epoch", stream.epoch, + "profile", + stream.profile ?? "", "search", normalizedSearchQuery, @@ if (isStandaloneRoutingKeyReadActive) { return [ "streams", streamsUrl, "stream", stream.name, "epoch", stream.epoch, + "profile", + stream.profile ?? "", "routingKeyRead", normalizedRoutingKey, @@ return [ "streams", streamsUrl, "stream", stream.name, "epoch", stream.epoch, + "profile", + stream.profile ?? "", "visibleEventCount", resolvedVisibleEventCount.toString(),🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui/hooks/use-stream-events.ts` around lines 1077 - 1131, The preview generation in normalizeStreamEvents, normalizeStandaloneRoutingKeyEvents, and normalizeStreamSearchHits uses stream.profile but the collection/query identity used by getOrCreateRowsCollection(...) (and any cache/key used for storing normalized rows) does not include profile, causing stale previews when profile changes; fix by including stream.profile as part of the identity/key passed to getOrCreateRowsCollection (and any related cache keys) so collections are namespaced per profile, and update any where collection names or cache key builders are created to incorporate the stream.profile value so normalized rows and previews are regenerated when profile changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@ui/hooks/use-stream-events.ts`:
- Around line 1077-1131: The preview generation in normalizeStreamEvents,
normalizeStandaloneRoutingKeyEvents, and normalizeStreamSearchHits uses
stream.profile but the collection/query identity used by
getOrCreateRowsCollection(...) (and any cache/key used for storing normalized
rows) does not include profile, causing stale previews when profile changes; fix
by including stream.profile as part of the identity/key passed to
getOrCreateRowsCollection (and any related cache keys) so collections are
namespaced per profile, and update any where collection names or cache key
builders are created to incorporate the stream.profile value so normalized rows
and previews are regenerated when profile changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 212d206e-a245-494b-bcbd-9dbe1fc9cb8e
📒 Files selected for processing (5)
.changeset/quiet-evlog-preview.mdArchitecture/stream-event-view.mdFEATURES.mdui/hooks/use-stream-events.test.tsxui/hooks/use-stream-events.ts
Summary
Verification