Skip to content

Commit

Permalink
Catch exception from Critical Path code to protect the rest of the UI (
Browse files Browse the repository at this point in the history
…#1768)

Related to #1766

Signed-off-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
yurishkuro authored Sep 6, 2023
1 parent addbe55 commit f0dff93
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const computeCriticalPath = (
return criticalPath;
};

function TraceCriticalPath(trace: Trace) {
function criticalPathForTrace(trace: Trace) {
let criticalPath: criticalPathSection[] = [];
// As spans are already sorted based on startTime first span is always rootSpan
const rootSpanId = trace.spans[0].spanID;
Expand All @@ -95,11 +95,15 @@ function TraceCriticalPath(trace: Trace) {
}, new Map<string, Span>());
const refinedSpanMap = getChildOfSpans(spanMap);
const sanitizedSpanMap = sanitizeOverFlowingChildren(refinedSpanMap);
criticalPath = computeCriticalPath(sanitizedSpanMap, rootSpanId, criticalPath);
try {
criticalPath = computeCriticalPath(sanitizedSpanMap, rootSpanId, criticalPath);
} catch (error) {
console.log('error while computing critical path for a trace', error);
}
}
return criticalPath;
}

const memoizedTraceCriticalPath = memoizeOne(TraceCriticalPath);
const memoizedTraceCriticalPath = memoizeOne(criticalPathForTrace);

export default memoizedTraceCriticalPath;

0 comments on commit f0dff93

Please sign in to comment.