Skip to content

Commit dbc0a15

Browse files
shayna-chandrewshie-sentry
authored andcommitted
ref(grouping): remove line and column numbers from similar issues stacktrace diff (#97536)
1 parent 1c78f48 commit dbc0a15

File tree

4 files changed

+67
-37
lines changed

4 files changed

+67
-37
lines changed

static/app/components/events/interfaces/crashContent/stackTrace/rawContent.spec.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ describe('RawStacktraceContent', () => {
1717
function: 'run',
1818
filename: 'QueuedThreadPool.java',
1919
lineNo: 582,
20-
})
20+
}),
21+
true
2122
)
2223
).toBe(
2324
' at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)'
@@ -30,7 +31,8 @@ describe('RawStacktraceContent', () => {
3031
module: 'org.mortbay.thread.QueuedThreadPool$PoolThread',
3132
function: 'run',
3233
filename: 'QueuedThreadPool.java',
33-
})
34+
}),
35+
true
3436
)
3537
).toBe(
3638
' at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java)'
@@ -43,7 +45,8 @@ describe('RawStacktraceContent', () => {
4345
module: 'org.mortbay.thread.QueuedThreadPool$PoolThread',
4446
function: 'run',
4547
filename: 'QueuedThreadPool.java',
46-
})
48+
}),
49+
true
4750
)
4851
).toBe(
4952
' at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java)'

static/app/components/events/interfaces/crashContent/stackTrace/rawContent.tsx

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {ExceptionValue, Frame} from 'sentry/types/event';
33
import type {StacktraceType} from 'sentry/types/stacktrace';
44
import {defined} from 'sentry/utils';
55

6-
function getJavaScriptFrame(frame: Frame): string {
6+
function getJavaScriptFrame(frame: Frame, includeLocation: boolean): string {
77
let result = '';
88
if (defined(frame.function)) {
99
result += ' at ' + frame.function + '(';
@@ -15,17 +15,17 @@ function getJavaScriptFrame(frame: Frame): string {
1515
} else if (defined(frame.module)) {
1616
result += frame.module;
1717
}
18-
if (defined(frame.lineNo) && frame.lineNo >= 0) {
18+
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
1919
result += ':' + frame.lineNo;
2020
}
21-
if (defined(frame.colNo) && frame.colNo >= 0) {
21+
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) {
2222
result += ':' + frame.colNo;
2323
}
2424
result += ')';
2525
return result;
2626
}
2727

28-
function getRubyFrame(frame: Frame): string {
28+
function getRubyFrame(frame: Frame, includeLocation: boolean): string {
2929
let result = ' from ';
3030
if (defined(frame.filename)) {
3131
result += frame.filename;
@@ -34,10 +34,10 @@ function getRubyFrame(frame: Frame): string {
3434
} else {
3535
result += '?';
3636
}
37-
if (defined(frame.lineNo) && frame.lineNo >= 0) {
37+
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
3838
result += ':' + frame.lineNo;
3939
}
40-
if (defined(frame.colNo) && frame.colNo >= 0) {
40+
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) {
4141
result += ':' + frame.colNo;
4242
}
4343
if (defined(frame.function)) {
@@ -46,12 +46,17 @@ function getRubyFrame(frame: Frame): string {
4646
return result;
4747
}
4848

49-
function getPHPFrame(frame: Frame, idx: number): string {
49+
function getPHPFrame(frame: Frame, idx: number, includeLocation: boolean): string {
5050
const funcName = frame.function === 'null' ? '{main}' : frame.function;
51-
return `#${idx} ${frame.filename || frame.module}(${frame.lineNo}): ${funcName}`;
51+
let result = `#${idx} ${frame.filename || frame.module}`;
52+
if (includeLocation && defined(frame.lineNo) && frame.lineNo >= 0) {
53+
result += `(${frame.lineNo})`;
54+
}
55+
result += `: ${funcName}`;
56+
return result;
5257
}
5358

54-
function getPythonFrame(frame: Frame): string {
59+
function getPythonFrame(frame: Frame, includeLocation: boolean): string {
5560
let result = '';
5661
if (defined(frame.filename)) {
5762
result += ' File "' + frame.filename + '"';
@@ -60,10 +65,10 @@ function getPythonFrame(frame: Frame): string {
6065
} else {
6166
result += ' ?';
6267
}
63-
if (defined(frame.lineNo) && frame.lineNo >= 0) {
68+
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
6469
result += ', line ' + frame.lineNo;
6570
}
66-
if (defined(frame.colNo) && frame.colNo >= 0) {
71+
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) {
6772
result += ', col ' + frame.colNo;
6873
}
6974
if (defined(frame.function)) {
@@ -79,7 +84,7 @@ function getPythonFrame(frame: Frame): string {
7984
return result;
8085
}
8186

82-
export function getJavaFrame(frame: Frame): string {
87+
export function getJavaFrame(frame: Frame, includeLocation: boolean): string {
8388
let result = ' at';
8489

8590
if (defined(frame.module)) {
@@ -90,15 +95,19 @@ export function getJavaFrame(frame: Frame): string {
9095
}
9196
if (defined(frame.filename)) {
9297
result += '(' + frame.filename;
93-
if (defined(frame.lineNo) && frame.lineNo >= 0) {
98+
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
9499
result += ':' + frame.lineNo;
95100
}
96101
result += ')';
97102
}
98103
return result;
99104
}
100105

101-
function getDartFrame(frame: Frame, frameIdxFromEnd: number): string {
106+
function getDartFrame(
107+
frame: Frame,
108+
frameIdxFromEnd: number,
109+
includeLocation: boolean
110+
): string {
102111
let result = ` #${frameIdxFromEnd}`;
103112

104113
if (frame.function === '<asynchronous suspension>') {
@@ -112,10 +121,10 @@ function getDartFrame(frame: Frame, frameIdxFromEnd: number): string {
112121
result += ' (';
113122

114123
result += frame.absPath;
115-
if (defined(frame.lineNo) && frame.lineNo >= 0) {
124+
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
116125
result += ':' + frame.lineNo;
117126
}
118-
if (defined(frame.colNo) && frame.colNo >= 0) {
127+
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) {
119128
result += ':' + frame.colNo;
120129
}
121130

@@ -129,7 +138,7 @@ function ljust(str: string, len: number) {
129138
return str + new Array(Math.max(0, len - str.length) + 1).join(' ');
130139
}
131140

132-
function getNativeFrame(frame: Frame): string {
141+
function getNativeFrame(frame: Frame, includeLocation: boolean): string {
133142
let result = ' ';
134143
if (defined(frame.package)) {
135144
result += ljust(trimPackage(frame.package), 20);
@@ -140,7 +149,7 @@ function getNativeFrame(frame: Frame): string {
140149
result += ' ' + (frame.function || frame.symbolAddr);
141150
if (defined(frame.filename)) {
142151
result += ' (' + frame.filename;
143-
if (defined(frame.lineNo) && frame.lineNo >= 0) {
152+
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
144153
result += ':' + frame.lineNo;
145154
}
146155
result += ')';
@@ -169,40 +178,42 @@ function getFrame(
169178
frame: Frame,
170179
frameIdx: number,
171180
frameIdxFromEnd: number,
172-
platform: string | undefined
181+
platform: string | undefined,
182+
includeLocation: boolean
173183
): string {
174184
if (frame.platform) {
175185
platform = frame.platform;
176186
}
177187
switch (platform) {
178188
case 'javascript':
179-
return getJavaScriptFrame(frame);
189+
return getJavaScriptFrame(frame, includeLocation);
180190
case 'ruby':
181-
return getRubyFrame(frame);
191+
return getRubyFrame(frame, includeLocation);
182192
case 'php':
183-
return getPHPFrame(frame, frameIdx);
193+
return getPHPFrame(frame, frameIdx, includeLocation);
184194
case 'python':
185-
return getPythonFrame(frame);
195+
return getPythonFrame(frame, includeLocation);
186196
case 'java':
187-
return getJavaFrame(frame);
197+
return getJavaFrame(frame, includeLocation);
188198
case 'dart':
189-
return getDartFrame(frame, frameIdxFromEnd);
199+
return getDartFrame(frame, frameIdxFromEnd, includeLocation);
190200
case 'objc':
191201
// fallthrough
192202
case 'cocoa':
193203
// fallthrough
194204
case 'native':
195-
return getNativeFrame(frame);
205+
return getNativeFrame(frame, includeLocation);
196206
default:
197-
return getPythonFrame(frame);
207+
return getPythonFrame(frame, includeLocation);
198208
}
199209
}
200210

201211
export default function displayRawContent(
202212
data: StacktraceType | null,
203213
platform?: string,
204214
exception?: ExceptionValue,
205-
hasSimilarityEmbeddingsFeature = false
215+
hasSimilarityEmbeddingsFeature = false,
216+
includeLocation = true
206217
) {
207218
const rawFrames = data?.frames || [];
208219

@@ -214,7 +225,13 @@ export default function displayRawContent(
214225
: rawFrames;
215226

216227
const frames = framesToUse.map((frame, frameIdx) =>
217-
getFrame(frame, frameIdx, framesToUse.length - frameIdx - 1, platform)
228+
getFrame(
229+
frame,
230+
frameIdx,
231+
framesToUse.length - frameIdx - 1,
232+
platform,
233+
includeLocation
234+
)
218235
);
219236

220237
if (platform !== 'python') {

static/app/components/issueDiff/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,18 @@ class IssueDiff extends Component<Props, State> {
8787
this.fetchEvent(baseIssueId, baseEventId ?? 'latest'),
8888
this.fetchEvent(targetIssueId, targetEventId ?? 'latest'),
8989
]);
90-
90+
const includeLocation = false;
9191
const [baseEvent, targetEvent] = await Promise.all([
92-
getStacktraceBody(baseEventData, hasSimilarityEmbeddingsFeature),
93-
getStacktraceBody(targetEventData, hasSimilarityEmbeddingsFeature),
92+
getStacktraceBody(
93+
baseEventData,
94+
hasSimilarityEmbeddingsFeature,
95+
includeLocation
96+
),
97+
getStacktraceBody(
98+
targetEventData,
99+
hasSimilarityEmbeddingsFeature,
100+
includeLocation
101+
),
94102
]);
95103

96104
this.setState({

static/app/utils/getStacktraceBody.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import type {Event} from 'sentry/types/event';
33

44
export default function getStacktraceBody(
55
event: Event,
6-
hasSimilarityEmbeddingsFeature = false
6+
hasSimilarityEmbeddingsFeature = false,
7+
includeLocation = true
78
) {
89
if (!event?.entries) {
910
return [];
@@ -40,7 +41,8 @@ export default function getStacktraceBody(
4041
value.stacktrace,
4142
event.platform,
4243
value,
43-
hasSimilarityEmbeddingsFeature
44+
hasSimilarityEmbeddingsFeature,
45+
includeLocation
4446
)
4547
)
4648
.reduce((acc: any, value: any) => acc.concat(value), []);

0 commit comments

Comments
 (0)