@@ -18,17 +18,6 @@ import * as Result from "effect/Result";
1818import * as Schema from "effect/Schema" ;
1919import * as Stream from "effect/Stream" ;
2020
21- interface TraceRecordLike {
22- readonly name ?: unknown ;
23- readonly traceId ?: unknown ;
24- readonly spanId ?: unknown ;
25- readonly startTimeUnixNano ?: unknown ;
26- readonly endTimeUnixNano ?: unknown ;
27- readonly durationMs ?: unknown ;
28- readonly exit ?: unknown ;
29- readonly events ?: unknown ;
30- }
31-
3221interface TraceEventLike {
3322 readonly name ?: unknown ;
3423 readonly timeUnixNano ?: unknown ;
@@ -85,7 +74,7 @@ export function toRotatedTracePaths(
8574 return [ ...backups , traceFilePath ] ;
8675}
8776
88- function isRecordObject ( value : unknown ) : value is TraceRecordLike {
77+ function isRecordObject ( value : unknown ) : value is Readonly < Record < string , unknown > > {
8978 return typeof value === "object" && value !== null ;
9079}
9180
@@ -253,8 +242,13 @@ export function makeTraceDiagnosticsAggregator(
253242 lastSpanAt === null || DateTime . isGreaterThan ( endedAt , lastSpanAt ) ? endedAt : lastSpanAt ;
254243
255244 const exitTag = readExitTag ( parsed . exit ) ;
256- const isFailure = exitTag === "Failure" ;
257- const isInterrupted = exitTag === "Interrupted" ;
245+ const status = isRecordObject ( parsed . status ) ? parsed . status : { } ;
246+ const attributes = isRecordObject ( parsed . attributes ) ? parsed . attributes : { } ;
247+ const isFailure = exitTag === "Failure" || status . code === "2" ;
248+ const isInterrupted =
249+ exitTag === "Interrupted" ||
250+ attributes [ "effect.fiber.interrupted" ] === true ||
251+ status . message === "Interrupted" ;
258252 if ( isFailure ) failureCount += 1 ;
259253 if ( isInterrupted ) interruptionCount += 1 ;
260254
@@ -277,7 +271,10 @@ export function makeTraceDiagnosticsAggregator(
277271 insertBounded ( slowestSpans , spanItem , TOP_LIMIT , slowestFirst ) ;
278272
279273 if ( isFailure ) {
280- const cause = readExitCause ( parsed . exit ) ;
274+ const cause =
275+ exitTag === "Failure"
276+ ? readExitCause ( parsed . exit )
277+ : ( toStringValue ( status . message ) ?. trim ( ) ?? "Failure" ) ;
281278 insertBounded ( latestFailures , { ...spanItem , cause } , RECENT_LIMIT , latestEndedFirst ) ;
282279
283280 const failureKey = `${ name } \0${ cause } ` ;
0 commit comments