Skip to content

Commit 87b3603

Browse files
authored
feat(webapp): completing spans server-side no longer write-after-read, improving efficiency and perf (#2530)
* Cancel run events which then propogate cancellation status to span ancestors * WIP * convert closing cached run spans to new system * converted expired complete span event to new method * move v3 over to new methods * Convert getDetailedTraceSummary to use the new ancestor override stuff * remove debug logs * Don't return UNSPECIFIED task events in getRunEvents * fix the call site for cancelling run event in v3 * Add changeset * remove methods
1 parent 365adc2 commit 87b3603

File tree

18 files changed

+1086
-692
lines changed

18 files changed

+1086
-692
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Stop failing attempt spans when a run is cancelled

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ export class SpanPresenter extends BasePresenter {
251251
engine: run.engine,
252252
region,
253253
workerQueue: run.workerQueue,
254+
traceId: run.traceId,
254255
spanId: run.spanId,
255256
isCached: !!span.originalRun,
256257
machinePreset: machine?.name,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,14 @@ function RunBody({
840840
<Property.Label>Worker queue</Property.Label>
841841
<Property.Value>{run.workerQueue}</Property.Value>
842842
</Property.Item>
843+
<Property.Item>
844+
<Property.Label>Trace ID</Property.Label>
845+
<Property.Value>{run.traceId}</Property.Value>
846+
</Property.Item>
847+
<Property.Item>
848+
<Property.Label>Span ID</Property.Label>
849+
<Property.Value>{run.spanId}</Property.Value>
850+
</Property.Item>
843851
</div>
844852
)}
845853
</Property.Table>

apps/webapp/app/runEngine/concerns/idempotencyKeys.server.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,18 @@ export class IdempotencyKeyConcern {
9090
isError: associatedWaitpoint.outputIsError,
9191
},
9292
async (event) => {
93+
const spanId =
94+
request.options?.parentAsLinkType === "replay"
95+
? event.spanId
96+
: event.traceparent?.spanId
97+
? `${event.traceparent.spanId}:${event.spanId}`
98+
: event.spanId;
99+
93100
//block run with waitpoint
94101
await this.engine.blockRunWithWaitpoint({
95102
runId: RunId.fromFriendlyId(parentRunId),
96103
waitpoints: associatedWaitpoint.id,
97-
spanIdToComplete: event.spanId,
104+
spanIdToComplete: spanId,
98105
batch: request.options?.batchId
99106
? {
100107
id: request.options.batchId,

0 commit comments

Comments
 (0)