Skip to content

Commit f18a2cd

Browse files
Abdkhan14Abdullah Khan
and
Abdullah Khan
authored
fix(performance-quick-trace-query): Using Sentry.captureException to inspect trace endpoint response. (#58167)
Addresses issues: [issue1](https://sentry.sentry.io/issues/4403078222/?alert_rule_id=13882978&alert_type=issue&notification_uuid=4c5c72e6-a878-43c8-81f2-c8da43c62532&project=11276&referrer=slack) and [issue2](https://sentry.sentry.io/issues/4402281669/?alert_rule_id=13882978&alert_type=issue&notification_uuid=ab62210c-9f5c-409f-86e2-6c4c2b27a920&project=11276&referrer=slack). Prevents issue details page from failing. When error is triggered, we just display a link to the trace view without the navigator nodes. --------- Co-authored-by: Abdullah Khan <[email protected]>
1 parent d46aee6 commit f18a2cd

File tree

1 file changed

+45
-17
lines changed

1 file changed

+45
-17
lines changed

static/app/utils/performance/quickTrace/quickTraceQuery.tsx

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {Fragment} from 'react';
2+
import * as Sentry from '@sentry/react';
23

34
import {Event} from 'sentry/types/event';
45
import {DiscoverQueryProps} from 'sentry/utils/discover/genericDiscoverQuery';
@@ -73,6 +74,10 @@ export default function QuickTraceQuery({children, event, ...props}: QueryProps)
7374
organization
7475
);
7576

77+
const scope = new Sentry.Scope();
78+
const traceErrorMsg = 'Trace endpoints returning non-array in response';
79+
scope.setFingerprint([traceErrorMsg]);
80+
7681
if (
7782
!traceFullResults.isLoading &&
7883
traceFullResults.error === null &&
@@ -88,19 +93,31 @@ export default function QuickTraceQuery({children, event, ...props}: QueryProps)
8893
});
8994
}
9095

91-
for (const subtrace of transactions ??
92-
(traceFullResults.traces as TraceFull[])) {
93-
try {
94-
const trace = flattenRelevantPaths(event, subtrace);
95-
return children({
96-
...traceFullResults,
97-
trace,
98-
currentEvent: trace.find(e => isCurrentEvent(e, event)) ?? null,
99-
});
100-
} catch {
101-
// let this fall through and check the next subtrace
102-
// or use the trace lite results
96+
const traceTransactions =
97+
transactions ?? (traceFullResults.traces as TraceFull[]);
98+
99+
try {
100+
for (const subtrace of traceTransactions) {
101+
try {
102+
const trace = flattenRelevantPaths(event, subtrace);
103+
return children({
104+
...traceFullResults,
105+
trace,
106+
currentEvent: trace.find(e => isCurrentEvent(e, event)) ?? null,
107+
});
108+
} catch {
109+
// let this fall through and check the next subtrace
110+
// or use the trace lite results
111+
}
103112
}
113+
} catch {
114+
// capture exception and let this fall through to
115+
// use the /events-trace-lite/ response below
116+
scope.setExtras({
117+
traceTransactions,
118+
traceFullResults,
119+
});
120+
Sentry.captureException(new Error(traceErrorMsg), scope);
104121
}
105122
}
106123

@@ -118,14 +135,25 @@ export default function QuickTraceQuery({children, event, ...props}: QueryProps)
118135
? orphanErrorsLite[0]
119136
: undefined;
120137
const traceTransactions = transactionLite ?? (trace as TraceLite);
138+
139+
let traceTransaction: EventLite | undefined;
140+
try {
141+
traceTransaction = traceTransactions.find(e => isCurrentEvent(e, event));
142+
} catch {
143+
scope.setExtras({
144+
traceTransaction,
145+
orphanError,
146+
traceTransactions,
147+
trace,
148+
});
149+
Sentry.captureException(new Error(traceErrorMsg), scope);
150+
}
151+
121152
return children({
122153
...traceLiteResults,
123-
trace: traceTransactions,
154+
trace: Array.isArray(traceTransactions) ? traceTransactions : [],
124155
orphanErrors: orphanErrorsLite,
125-
currentEvent:
126-
orphanError ??
127-
traceTransactions.find(e => isCurrentEvent(e, event)) ??
128-
null,
156+
currentEvent: orphanError ?? traceTransaction ?? null,
129157
});
130158
}
131159

0 commit comments

Comments
 (0)