* Force-close any remaining open spans at session end.
()
| 963 | * Force-close any remaining open spans at session end. |
| 964 | */ |
| 965 | function closeOpenSpans(): void { |
| 966 | for (const [spanId, pending] of pendingSpans) { |
| 967 | const endTime = getTimestamp() |
| 968 | events.push({ |
| 969 | name: pending.name, |
| 970 | cat: pending.category, |
| 971 | ph: 'E', |
| 972 | ts: endTime, |
| 973 | pid: pending.agentInfo.processId, |
| 974 | tid: pending.agentInfo.threadId, |
| 975 | args: { |
| 976 | ...pending.args, |
| 977 | incomplete: true, |
| 978 | duration_ms: (endTime - pending.startTime) / 1000, |
| 979 | }, |
| 980 | }) |
| 981 | pendingSpans.delete(spanId) |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | /** |
| 986 | * Write the full trace to disk. Errors are logged but swallowed so that a |
no test coverage detected