-
Notifications
You must be signed in to change notification settings - Fork 5
feat(studio): link trace detail to test case row click (FP-185) #341
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
934f260
feat(studio): link trace detail panel to test case row click (FP-185)
walston de8cd90
refactor(studio): extract IntakeTraceDetailBody to components dir (FP…
walston 71e2342
fix(studio): import order and test assertions after IntakeTraceDetail…
walston 6ebb6f6
fix(studio): prettier format IntakeTraceDetailRoute spec
walston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
222 changes: 222 additions & 0 deletions
222
web/packages/studio/src/components/IntakeTraceDetailBody/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { KVPair } from '@nemo/common/src/components/KVPair'; | ||
| import { formatAbsoluteTimestamp } from '@nemo/common/src/components/RelativeTime/util'; | ||
| import { useGetTrace } from '@nemo/sdk/generated/platform/api'; | ||
| import { Grid, Panel, Stack, StatusMessage, Text } from '@nvidia/foundations-react-core'; | ||
| import { IntakeSpansTable } from '@studio/components/IntakeSpansTable'; | ||
| import { IntakeTelemetryStatusBadge } from '@studio/components/IntakeTelemetryStatusBadge'; | ||
| import { Loading } from '@studio/components/Layouts/Loading'; | ||
| import { NotFound } from '@studio/components/Layouts/NotFound'; | ||
| import { useWorkspaceFromPath } from '@studio/hooks/useWorkspaceFromPath'; | ||
| import { getIntakeSpanRoute } from '@studio/routes/utils'; | ||
| import { | ||
| EMPTY_VALUE, | ||
| formatCost, | ||
| formatDurationMs, | ||
| formatInteger, | ||
| formatMaybe, | ||
| } from '@studio/util/intakeTelemetry'; | ||
| import { Activity, CircleAlert, Hash } from 'lucide-react'; | ||
| import { type FC } from 'react'; | ||
| import { Link } from 'react-router-dom'; | ||
|
|
||
| const TRACE_SPANS_PAGE_SIZE = 1000; | ||
|
|
||
| export interface IntakeTraceDetailBodyProps { | ||
| traceId: string; | ||
| filterTogglePortalTargetId?: string; | ||
| showSpans?: boolean; | ||
| } | ||
|
|
||
| export const IntakeTraceDetailBody: FC<IntakeTraceDetailBodyProps> = ({ | ||
| traceId, | ||
| filterTogglePortalTargetId, | ||
| showSpans = true, | ||
| }) => { | ||
| const workspace = useWorkspaceFromPath(); | ||
|
|
||
| const { | ||
| data: trace, | ||
| error, | ||
| isLoading, | ||
| } = useGetTrace(workspace, traceId, { | ||
| mode: 'detailed', | ||
| }); | ||
|
|
||
| if (error?.response?.status === 404) { | ||
| return ( | ||
| <NotFound | ||
| subheader="Trace Not Found" | ||
| message="The trace does not exist or you do not have permission to view it." | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| if (isLoading) { | ||
| return <Loading description="Loading trace..." />; | ||
| } | ||
|
|
||
| if (error) { | ||
| return ( | ||
| <StatusMessage | ||
| className="mx-auto mt-density-2xl" | ||
| size="medium" | ||
| slotMedia={<CircleAlert width={65} height={65} />} | ||
| slotHeading="Error loading trace" | ||
| slotSubheading={error.message} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| if (!trace) { | ||
| return null; | ||
| } | ||
|
|
||
| const showExperimentContext = Boolean( | ||
| trace.experiment_context?.experiment_id || trace.experiment_context?.test_case_id | ||
| ); | ||
| const showSpanLimitMessage = | ||
| trace.span_count !== undefined && trace.span_count > TRACE_SPANS_PAGE_SIZE; | ||
| const wrappingValueAttributes = { | ||
| value: { | ||
| className: 'block min-w-0 max-w-full break-all', | ||
| }, | ||
| }; | ||
|
|
||
| const summaryPanels = ( | ||
| <Stack gap="density-2xl" className="min-w-0"> | ||
| <Panel | ||
| elevation="high" | ||
| slotIcon={<Activity />} | ||
| slotHeading="Trace Summary" | ||
| className="min-w-0 overflow-hidden" | ||
| > | ||
| <Stack gap="density-xl"> | ||
| <Grid className="grid-cols-2 gap-density-lg"> | ||
| <KVPair | ||
| label="Started" | ||
| value={formatAbsoluteTimestamp(trace.started_at)} | ||
| orientation="vertical" | ||
| /> | ||
| <KVPair | ||
| label="Ended" | ||
| value={trace.ended_at ? formatAbsoluteTimestamp(trace.ended_at) : EMPTY_VALUE} | ||
| orientation="vertical" | ||
| /> | ||
| <KVPair | ||
| label="Duration" | ||
| value={formatDurationMs(trace.duration_ms)} | ||
| orientation="vertical" | ||
| /> | ||
| <KVPair label="Spans" value={formatInteger(trace.span_count)} orientation="vertical" /> | ||
| <KVPair | ||
| label="Errors" | ||
| value={formatInteger(trace.error_count)} | ||
| orientation="vertical" | ||
| /> | ||
| <KVPair label="Total Cost" value={formatCost(trace.cost_usd)} orientation="vertical" /> | ||
| </Grid> | ||
| <Grid className="grid-cols-1 gap-density-lg min-w-0"> | ||
| <KVPair | ||
| label="Trace ID" | ||
| value={trace.id} | ||
| orientation="vertical" | ||
| attributes={wrappingValueAttributes} | ||
| /> | ||
| <KVPair | ||
| label="Root Span" | ||
| value={ | ||
| trace.root_span_id ? ( | ||
| <Link | ||
| to={getIntakeSpanRoute(workspace, trace.root_span_id)} | ||
| className="break-all" | ||
| > | ||
| {trace.root_span_id} | ||
| </Link> | ||
| ) : ( | ||
| EMPTY_VALUE | ||
| ) | ||
| } | ||
| orientation="vertical" | ||
| attributes={wrappingValueAttributes} | ||
| /> | ||
| <KVPair | ||
| label="Status" | ||
| value={<IntakeTelemetryStatusBadge status={trace.status} />} | ||
| orientation="vertical" | ||
| /> | ||
| <KVPair | ||
| label="Session ID" | ||
| value={trace.session_id} | ||
| orientation="vertical" | ||
| attributes={wrappingValueAttributes} | ||
| /> | ||
| </Grid> | ||
| </Stack> | ||
| </Panel> | ||
| {showExperimentContext && ( | ||
| <Panel | ||
| elevation="high" | ||
| slotIcon={<Hash />} | ||
| slotHeading="Experiment Context" | ||
| className="min-w-0 overflow-hidden" | ||
| > | ||
| <Stack gap="density-lg" className="min-w-0"> | ||
| <KVPair | ||
| label="Summary" | ||
| value={formatMaybe( | ||
| trace.experiment_context?.experiment_id || trace.experiment_context?.test_case_id | ||
| )} | ||
| orientation="vertical" | ||
| attributes={wrappingValueAttributes} | ||
| /> | ||
| <KVPair | ||
| label="Experiment ID" | ||
| value={formatMaybe(trace.experiment_context?.experiment_id)} | ||
| orientation="vertical" | ||
| attributes={wrappingValueAttributes} | ||
| /> | ||
| <KVPair | ||
| label="Test Case ID" | ||
| value={formatMaybe(trace.experiment_context?.test_case_id)} | ||
| orientation="vertical" | ||
| attributes={wrappingValueAttributes} | ||
| /> | ||
| </Stack> | ||
| </Panel> | ||
| )} | ||
| </Stack> | ||
| ); | ||
|
|
||
| if (!showSpans) { | ||
| return summaryPanels; | ||
| } | ||
|
|
||
| return ( | ||
| <Grid className="grid-cols-1 xl:grid-cols-[minmax(0,2fr)_minmax(320px,1fr)] gap-density-2xl items-start"> | ||
| <Stack gap="density-md" className="min-w-0 min-h-[420px]"> | ||
| {showSpanLimitMessage && ( | ||
| <Text kind="body/regular/sm" className="text-secondary"> | ||
| Showing first {TRACE_SPANS_PAGE_SIZE.toLocaleString()} of{' '} | ||
| {trace.span_count?.toLocaleString()} spans. Parent spans outside this page are marked in | ||
| the hierarchy. | ||
| </Text> | ||
| )} | ||
| <IntakeSpansTable | ||
| workspace={workspace} | ||
| filterTogglePortalTargetId={filterTogglePortalTargetId} | ||
| fixedFilter={{ trace_id: trace.id }} | ||
| defaultPageSize={TRACE_SPANS_PAGE_SIZE} | ||
| mode="summary" | ||
| showTraceColumn={false} | ||
| showHierarchy | ||
| emptyHeader="No Spans" | ||
| emptyMessage="No spans were found for this trace." | ||
| /> | ||
| </Stack> | ||
| {summaryPanels} | ||
| </Grid> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.