7
7
useRef ,
8
8
useState ,
9
9
} from 'react' ;
10
+ import { formatDate } from 'date-fns' ;
10
11
import {
11
12
AlertTriangle ,
12
13
ArrowUp ,
@@ -994,6 +995,31 @@ export function TraceSheet(props: TraceSheetProps) {
994
995
) ;
995
996
}
996
997
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
+
997
1023
function TargetInsightsNewPageContent ( props : {
998
1024
organizationSlug : string ;
999
1025
projectSlug : string ;
@@ -1003,7 +1029,7 @@ function TargetInsightsNewPageContent(props: {
1003
1029
activeSpanTab : string | null ;
1004
1030
} ) {
1005
1031
const [ result ] = useQuery ( {
1006
- query : TargetTraceQuery ,
1032
+ query : TargetInsightsNewPageContent_TraceQuery ,
1007
1033
variables : {
1008
1034
targetSelector : {
1009
1035
organizationSlug : props . organizationSlug ,
@@ -1014,6 +1040,8 @@ function TargetInsightsNewPageContent(props: {
1014
1040
} ,
1015
1041
} ) ;
1016
1042
1043
+ const trace = result . data ?. target ?. trace ;
1044
+
1017
1045
return (
1018
1046
< div className = "flex h-full flex-col space-y-4 pt-6" >
1019
1047
< Meta title = { `Trace ${ props . traceId } ` } />
@@ -1031,30 +1059,65 @@ function TargetInsightsNewPageContent(props: {
1031
1059
Traces
1032
1060
</ Link > { ' ' }
1033
1061
< 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
+ </ >
1036
1069
) : (
1037
1070
< Skeleton className = "inline-block h-5 w-[150px]" />
1038
1071
) }
1039
1072
</ span >
1040
1073
}
1041
1074
description = {
1042
1075
< >
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
+ ) }
1044
1107
</ >
1045
1108
}
1046
1109
/>
1047
- { result . data ?. target ?. trace && (
1110
+ { trace && (
1048
1111
< TraceSheet
1049
1112
organizationSlug = { props . organizationSlug }
1050
1113
projectSlug = { props . projectSlug }
1051
1114
targetSlug = { props . targetSlug }
1052
- trace = { result . data . target . trace }
1115
+ trace = { trace }
1053
1116
activeSpanId = { props . activeSpanId }
1054
1117
activeSpanTab = { props . activeSpanTab }
1055
1118
/>
1056
1119
) }
1057
- { ! result . data ?. target ?. trace && ! result . fetching && (
1120
+ { ! trace && ! result . fetching && (
1058
1121
< >
1059
1122
< Meta title = "Trace Not found" />
1060
1123
< NotFoundContent heading = "Trace not found." subheading = "This trace does not exist." />
@@ -1095,24 +1158,6 @@ export function TargetTracePage(props: {
1095
1158
) ;
1096
1159
}
1097
1160
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
-
1116
1161
const SpanFragment = graphql ( /* GraphQL */ `
1117
1162
fragment SpanFragment on Span {
1118
1163
id
0 commit comments