Skip to content

Commit 7d2f820

Browse files
committed
improve trace detail view header
1 parent 30d393b commit 7d2f820

File tree

3 files changed

+80
-32
lines changed

3 files changed

+80
-32
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { cn } from '@/lib/utils';
22

33
function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
4-
return <div className={cn('bg-primary/10 animate-pulse rounded-md', className)} {...props} />;
4+
return (
5+
<div
6+
className={cn('bg-primary/10 animate-pulse rounded-md align-middle', className)}
7+
{...props}
8+
/>
9+
);
510
}
611

712
export { Skeleton };

packages/web/app/src/index.css

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@
5252

5353
--chart-1: 173 58% 39%;
5454
--chart-2: 12 76% 61%;
55-
--chart-3: 197 37% 24%;
56-
--chart-4: 43 74% 66%;
57-
--chart-5: 27 87% 67%;
5855
}
5956

6057
.dark {
@@ -102,9 +99,6 @@
10299
--sidebar-ring: 217.2 91.2% 59.8%;
103100

104101
--chart-1: 220 70% 50%;
105-
--chart-5: 160 60% 45%;
106-
--chart-3: 30 80% 55%;
107-
--chart-4: 280 65% 60%;
108102
--chart-2: 340 75% 55%;
109103
}
110104
}
@@ -114,6 +108,10 @@
114108
@apply border-border;
115109
}
116110

111+
html {
112+
@apply bg-[#030711];
113+
}
114+
117115
body {
118116
@apply text-foreground bg-[#030711];
119117
font-feature-settings:

packages/web/app/src/pages/target-trace.tsx

Lines changed: 70 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
useRef,
88
useState,
99
} from 'react';
10+
import { formatDate } from 'date-fns';
1011
import {
1112
AlertTriangle,
1213
ArrowUp,
@@ -994,6 +995,31 @@ export function TraceSheet(props: TraceSheetProps) {
994995
);
995996
}
996997

998+
const TargetInsightsNewPageContent_TraceQuery = graphql(/* GraphQL */ `
999+
query TargetInsightsNewPageContent_TraceQuery(
1000+
$targetSelector: TargetSelectorInput!
1001+
$traceId: ID!
1002+
) {
1003+
target(reference: { bySelector: $targetSelector }) {
1004+
id
1005+
trace(traceId: $traceId) {
1006+
...TraceSheet_TraceFragment
1007+
id
1008+
operationName
1009+
duration
1010+
success
1011+
timestamp
1012+
spans {
1013+
id
1014+
name
1015+
parentId
1016+
...SpanFragment
1017+
}
1018+
}
1019+
}
1020+
}
1021+
`);
1022+
9971023
function TargetInsightsNewPageContent(props: {
9981024
organizationSlug: string;
9991025
projectSlug: string;
@@ -1003,7 +1029,7 @@ function TargetInsightsNewPageContent(props: {
10031029
activeSpanTab: string | null;
10041030
}) {
10051031
const [result] = useQuery({
1006-
query: TargetTraceQuery,
1032+
query: TargetInsightsNewPageContent_TraceQuery,
10071033
variables: {
10081034
targetSelector: {
10091035
organizationSlug: props.organizationSlug,
@@ -1014,6 +1040,8 @@ function TargetInsightsNewPageContent(props: {
10141040
},
10151041
});
10161042

1043+
const trace = result.data?.target?.trace;
1044+
10171045
return (
10181046
<div className="flex h-full flex-col space-y-4 pt-6">
10191047
<Meta title={`Trace ${props.traceId}`} />
@@ -1031,30 +1059,65 @@ function TargetInsightsNewPageContent(props: {
10311059
Traces
10321060
</Link>{' '}
10331061
<span className="inline-block px-2 italic text-gray-500">/</span>{' '}
1034-
{result.data?.target?.trace ? (
1035-
result.data.target.trace.id
1062+
{trace ? (
1063+
<>
1064+
{trace.operationName ?? <span className="text-gray-400">{'<unknown>'}</span>}
1065+
<span className="text-muted-foreground ml-2 font-mono font-normal">
1066+
{trace.id.substring(0, 4)}
1067+
</span>
1068+
</>
10361069
) : (
10371070
<Skeleton className="inline-block h-5 w-[150px]" />
10381071
)}
10391072
</span>
10401073
}
10411074
description={
10421075
<>
1043-
<CardDescription>Insights into the requests made to your GraphQL API.</CardDescription>
1076+
<CardDescription>
1077+
Trace ID:{' '}
1078+
{trace?.id ? (
1079+
<>
1080+
<span className="font-mono"> {trace.id}</span>
1081+
<CopyIconButton value={trace.id} label="Copy Trace ID" />
1082+
</>
1083+
) : (
1084+
<Skeleton className="inline-block h-4 w-[200px]" />
1085+
)}
1086+
</CardDescription>
1087+
{trace && (
1088+
<div className="mt-2 flex items-center gap-3 text-xs">
1089+
<div className="flex items-center gap-1">
1090+
<Clock className="size-3 text-gray-400" />
1091+
<span className="text-gray-300">{formatNanoseconds(BigInt(trace.duration))}</span>
1092+
</div>
1093+
<Badge
1094+
variant="outline"
1095+
className={cn(
1096+
'rounded-sm border-0 px-1 font-medium uppercase',
1097+
trace.success ? 'bg-green-900/30 text-green-400' : 'bg-red-900/30 text-red-400',
1098+
)}
1099+
>
1100+
{trace.success ? 'Ok' : 'Error'}
1101+
</Badge>
1102+
<span className="font-mono uppercase text-gray-300">
1103+
{formatDate(trace.timestamp, 'MMM dd HH:mm:ss')}
1104+
</span>
1105+
</div>
1106+
)}
10441107
</>
10451108
}
10461109
/>
1047-
{result.data?.target?.trace && (
1110+
{trace && (
10481111
<TraceSheet
10491112
organizationSlug={props.organizationSlug}
10501113
projectSlug={props.projectSlug}
10511114
targetSlug={props.targetSlug}
1052-
trace={result.data.target.trace}
1115+
trace={trace}
10531116
activeSpanId={props.activeSpanId}
10541117
activeSpanTab={props.activeSpanTab}
10551118
/>
10561119
)}
1057-
{!result.data?.target?.trace && !result.fetching && (
1120+
{!trace && !result.fetching && (
10581121
<>
10591122
<Meta title="Trace Not found" />
10601123
<NotFoundContent heading="Trace not found." subheading="This trace does not exist." />
@@ -1095,24 +1158,6 @@ export function TargetTracePage(props: {
10951158
);
10961159
}
10971160

1098-
const TargetTraceQuery = graphql(/* GraphQL */ `
1099-
query TargetTraceQuery($targetSelector: TargetSelectorInput!, $traceId: ID!) {
1100-
target(reference: { bySelector: $targetSelector }) {
1101-
id
1102-
trace(traceId: $traceId) {
1103-
...TraceSheet_TraceFragment
1104-
id
1105-
spans {
1106-
id
1107-
name
1108-
parentId
1109-
...SpanFragment
1110-
}
1111-
}
1112-
}
1113-
}
1114-
`);
1115-
11161161
const SpanFragment = graphql(/* GraphQL */ `
11171162
fragment SpanFragment on Span {
11181163
id

0 commit comments

Comments
 (0)