Skip to content

Commit 210319a

Browse files
committed
WIP on waitpoint inspector
1 parent cd158f6 commit 210319a

File tree

5 files changed

+123
-10
lines changed

5 files changed

+123
-10
lines changed

apps/webapp/app/presenters/v3/SpanPresenter.server.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,41 @@ export class SpanPresenter extends BasePresenter {
423423
},
424424
});
425425

426-
return {
426+
const data = {
427427
...span,
428428
events: span.events,
429429
properties: span.properties ? JSON.stringify(span.properties, null, 2) : undefined,
430430
triggeredRuns,
431431
showActionBar: span.show?.actions === true,
432432
};
433+
434+
switch (span.entity.type) {
435+
case "waitpoint":
436+
const waitpoint = await this._replica.waitpoint.findFirst({
437+
where: {
438+
friendlyId: span.entity.id,
439+
},
440+
select: {
441+
friendlyId: true,
442+
type: true,
443+
status: true,
444+
idempotencyKey: true,
445+
userProvidedIdempotencyKey: true,
446+
idempotencyKeyExpiresAt: true,
447+
output: true,
448+
outputType: true,
449+
outputIsError: true,
450+
},
451+
});
452+
453+
return {
454+
...data,
455+
entityType: "waitpoint" as const,
456+
waitpoint,
457+
};
458+
459+
default:
460+
return { ...data, entityType: "span" as const };
461+
}
433462
}
434463
}

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam.spans.$spanParam/route.tsx

Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function SpanBody({
188188
className="h-4 min-h-4 w-4 min-w-4"
189189
/>
190190
<Header2 className={cn("overflow-x-hidden")}>
191-
<SpanTitle {...span} size="large" />
191+
<SpanTitle {...span} size="large" hideAccessory />
192192
</Header2>
193193
</div>
194194
{runParam && closePanel && (
@@ -385,14 +385,7 @@ function SpanBody({
385385
)}
386386
</Property.Table>
387387
{span.events.length > 0 && <SpanEvents spanEvents={span.events} />}
388-
{span.properties !== undefined && (
389-
<CodeBlock
390-
rowTitle="Properties"
391-
code={span.properties}
392-
maxLines={20}
393-
showLineNumbers={false}
394-
/>
395-
)}
388+
<SpanEntity span={span} />
396389
</div>
397390
)}
398391
</div>
@@ -1217,3 +1210,81 @@ function SpanLinkElement({ link }: { link: SpanLink }) {
12171210

12181211
return null;
12191212
}
1213+
1214+
function SpanEntity({ span }: { span: Span }) {
1215+
switch (span.entityType) {
1216+
case "waitpoint": {
1217+
if (!span.waitpoint) {
1218+
return <Paragraph>No waitpoint found: {span.entity.id}</Paragraph>;
1219+
}
1220+
1221+
return (
1222+
<>
1223+
<Property.Table>
1224+
<Property.Item>
1225+
<Property.Label>Waitpoint ID</Property.Label>
1226+
<Property.Value className="whitespace-pre-wrap">
1227+
{span.waitpoint?.friendlyId}
1228+
</Property.Value>
1229+
</Property.Item>
1230+
<Property.Item>
1231+
<Property.Label>Waitpoint status</Property.Label>
1232+
<Property.Value>
1233+
<TaskRunAttemptStatusCombo
1234+
status={
1235+
span.waitpoint.status === "PENDING"
1236+
? "EXECUTING"
1237+
: span.waitpoint.outputIsError
1238+
? "FAILED"
1239+
: "COMPLETED"
1240+
}
1241+
className="text-sm"
1242+
/>
1243+
</Property.Value>
1244+
</Property.Item>
1245+
<Property.Item>
1246+
<Property.Label>Waitpoint idempotency key</Property.Label>
1247+
<Property.Value>
1248+
{span.waitpoint.userProvidedIdempotencyKey ? span.waitpoint.idempotencyKey : "–"}
1249+
</Property.Value>
1250+
</Property.Item>
1251+
<Property.Item>
1252+
<Property.Label>Waitpoint idempotency key expires at</Property.Label>
1253+
<Property.Value>
1254+
{span.waitpoint.idempotencyKeyExpiresAt ? (
1255+
<DateTime date={span.waitpoint.idempotencyKeyExpiresAt} />
1256+
) : (
1257+
"–"
1258+
)}
1259+
</Property.Value>
1260+
</Property.Item>
1261+
</Property.Table>
1262+
{span.waitpoint.status === "PENDING" ? (
1263+
<div>Manually complete waitpoint</div>
1264+
) : span.waitpoint.output ? (
1265+
<PacketDisplay
1266+
title="Waitpoint output"
1267+
data={span.waitpoint.output}
1268+
dataType={span.waitpoint.outputType}
1269+
/>
1270+
) : (
1271+
"No output"
1272+
)}
1273+
</>
1274+
);
1275+
}
1276+
default: {
1277+
if (span.properties !== undefined)
1278+
return (
1279+
<CodeBlock
1280+
rowTitle="Properties"
1281+
code={span.properties}
1282+
maxLines={20}
1283+
showLineNumbers={false}
1284+
/>
1285+
);
1286+
}
1287+
}
1288+
1289+
return <></>;
1290+
}

apps/webapp/app/v3/eventRepository.server.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,14 @@ export class EventRepository {
624624
SemanticInternalAttributes.ORIGINAL_RUN_ID
625625
);
626626

627+
const entity = {
628+
type: rehydrateAttribute<string>(
629+
spanEvent.properties,
630+
SemanticInternalAttributes.ENTITY_TYPE
631+
),
632+
id: rehydrateAttribute<string>(spanEvent.properties, SemanticInternalAttributes.ENTITY_ID),
633+
};
634+
627635
return {
628636
...spanEvent,
629637
...span.data,
@@ -634,6 +642,7 @@ export class EventRepository {
634642
show,
635643
links,
636644
originalRun,
645+
entity,
637646
};
638647
});
639648
}

packages/core/src/v3/semanticInternalAttributes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export const SemanticInternalAttributes = {
2525
MACHINE_PRESET_CENTS_PER_MS: "ctx.machine.centsPerMs",
2626
SPAN_PARTIAL: "$span.partial",
2727
SPAN_ID: "$span.span_id",
28+
ENTITY_TYPE: "$entity.type",
29+
ENTITY_ID: "$entity.id",
2830
OUTPUT: "$output",
2931
OUTPUT_TYPE: "$mime_type_output",
3032
STYLE: "$style",

packages/trigger-sdk/src/v3/wait.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ export const wait = {
206206
{
207207
attributes: {
208208
[SemanticInternalAttributes.STYLE_ICON]: "wait-token",
209+
[SemanticInternalAttributes.ENTITY_TYPE]: "waitpoint",
210+
[SemanticInternalAttributes.ENTITY_ID]: tokenId,
209211
id: tokenId,
210212
...accessoryAttributes({
211213
items: [

0 commit comments

Comments
 (0)