Skip to content

ref(grouping): remove line and column numbers from similar issues stacktrace diff #97536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {ExceptionValue, Frame} from 'sentry/types/event';
import type {StacktraceType} from 'sentry/types/stacktrace';
import {defined} from 'sentry/utils';

function getJavaScriptFrame(frame: Frame): string {
function getJavaScriptFrame(frame: Frame, includeLocation = true): string {
let result = '';
if (defined(frame.function)) {
result += ' at ' + frame.function + '(';
Expand All @@ -15,17 +15,17 @@ function getJavaScriptFrame(frame: Frame): string {
} else if (defined(frame.module)) {
result += frame.module;
}
if (defined(frame.lineNo) && frame.lineNo >= 0) {
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
result += ':' + frame.lineNo;
}
if (defined(frame.colNo) && frame.colNo >= 0) {
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) {
result += ':' + frame.colNo;
}
result += ')';
return result;
}

function getRubyFrame(frame: Frame): string {
function getRubyFrame(frame: Frame, includeLocation = true): string {
let result = ' from ';
if (defined(frame.filename)) {
result += frame.filename;
Expand All @@ -34,10 +34,10 @@ function getRubyFrame(frame: Frame): string {
} else {
result += '?';
}
if (defined(frame.lineNo) && frame.lineNo >= 0) {
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
result += ':' + frame.lineNo;
}
if (defined(frame.colNo) && frame.colNo >= 0) {
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) {
result += ':' + frame.colNo;
}
if (defined(frame.function)) {
Expand All @@ -46,12 +46,17 @@ function getRubyFrame(frame: Frame): string {
return result;
}

function getPHPFrame(frame: Frame, idx: number): string {
function getPHPFrame(frame: Frame, idx: number, includeLocation = true): string {
const funcName = frame.function === 'null' ? '{main}' : frame.function;
return `#${idx} ${frame.filename || frame.module}(${frame.lineNo}): ${funcName}`;
let result = `#${idx} ${frame.filename || frame.module}`;
if (includeLocation && defined(frame.lineNo) && frame.lineNo >= 0) {
result += `(${frame.lineNo})`;
}
result += `: ${funcName}`;
return result;
}

function getPythonFrame(frame: Frame): string {
function getPythonFrame(frame: Frame, includeLocation = true): string {
let result = '';
if (defined(frame.filename)) {
result += ' File "' + frame.filename + '"';
Expand All @@ -60,10 +65,10 @@ function getPythonFrame(frame: Frame): string {
} else {
result += ' ?';
}
if (defined(frame.lineNo) && frame.lineNo >= 0) {
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
result += ', line ' + frame.lineNo;
}
if (defined(frame.colNo) && frame.colNo >= 0) {
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) {
result += ', col ' + frame.colNo;
}
if (defined(frame.function)) {
Expand All @@ -79,7 +84,7 @@ function getPythonFrame(frame: Frame): string {
return result;
}

export function getJavaFrame(frame: Frame): string {
export function getJavaFrame(frame: Frame, includeLocation = true): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is only called in this file and in tests, lets make includeLocation a required parameter and update the tests. I'd do the same with the other functions.

Adding a test in static/app/components/events/interfaces/crashContent/stackTrace/rawContent.spec.tsx for this might also be good

let result = ' at';

if (defined(frame.module)) {
Expand All @@ -90,15 +95,19 @@ export function getJavaFrame(frame: Frame): string {
}
if (defined(frame.filename)) {
result += '(' + frame.filename;
if (defined(frame.lineNo) && frame.lineNo >= 0) {
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
result += ':' + frame.lineNo;
}
result += ')';
}
return result;
}

function getDartFrame(frame: Frame, frameIdxFromEnd: number): string {
function getDartFrame(
frame: Frame,
frameIdxFromEnd: number,
includeLocation = true
): string {
let result = ` #${frameIdxFromEnd}`;

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

result += frame.absPath;
if (defined(frame.lineNo) && frame.lineNo >= 0) {
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
result += ':' + frame.lineNo;
}
if (defined(frame.colNo) && frame.colNo >= 0) {
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) {
result += ':' + frame.colNo;
}

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

function getNativeFrame(frame: Frame): string {
function getNativeFrame(frame: Frame, includeLocation = true): string {
let result = ' ';
if (defined(frame.package)) {
result += ljust(trimPackage(frame.package), 20);
Expand All @@ -140,7 +149,7 @@ function getNativeFrame(frame: Frame): string {
result += ' ' + (frame.function || frame.symbolAddr);
if (defined(frame.filename)) {
result += ' (' + frame.filename;
if (defined(frame.lineNo) && frame.lineNo >= 0) {
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) {
result += ':' + frame.lineNo;
}
result += ')';
Expand Down Expand Up @@ -169,40 +178,42 @@ function getFrame(
frame: Frame,
frameIdx: number,
frameIdxFromEnd: number,
platform: string | undefined
platform: string | undefined,
includeLocation = true
): string {
if (frame.platform) {
platform = frame.platform;
}
switch (platform) {
case 'javascript':
return getJavaScriptFrame(frame);
return getJavaScriptFrame(frame, includeLocation);
case 'ruby':
return getRubyFrame(frame);
return getRubyFrame(frame, includeLocation);
case 'php':
return getPHPFrame(frame, frameIdx);
return getPHPFrame(frame, frameIdx, includeLocation);
case 'python':
return getPythonFrame(frame);
return getPythonFrame(frame, includeLocation);
case 'java':
return getJavaFrame(frame);
return getJavaFrame(frame, includeLocation);
case 'dart':
return getDartFrame(frame, frameIdxFromEnd);
return getDartFrame(frame, frameIdxFromEnd, includeLocation);
case 'objc':
// fallthrough
case 'cocoa':
// fallthrough
case 'native':
return getNativeFrame(frame);
return getNativeFrame(frame, includeLocation);
default:
return getPythonFrame(frame);
return getPythonFrame(frame, includeLocation);
}
}

export default function displayRawContent(
data: StacktraceType | null,
platform?: string,
exception?: ExceptionValue,
hasSimilarityEmbeddingsFeature = false
hasSimilarityEmbeddingsFeature = false,
includeLocation = true
) {
const rawFrames = data?.frames || [];

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

const frames = framesToUse.map((frame, frameIdx) =>
getFrame(frame, frameIdx, framesToUse.length - frameIdx - 1, platform)
getFrame(
frame,
frameIdx,
framesToUse.length - frameIdx - 1,
platform,
includeLocation
)
);

if (platform !== 'python') {
Expand Down
14 changes: 11 additions & 3 deletions static/app/components/issueDiff/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,18 @@ class IssueDiff extends Component<Props, State> {
this.fetchEvent(baseIssueId, baseEventId ?? 'latest'),
this.fetchEvent(targetIssueId, targetEventId ?? 'latest'),
]);

const includeLocation = false;
const [baseEvent, targetEvent] = await Promise.all([
getStacktraceBody(baseEventData, hasSimilarityEmbeddingsFeature),
getStacktraceBody(targetEventData, hasSimilarityEmbeddingsFeature),
getStacktraceBody(
baseEventData,
hasSimilarityEmbeddingsFeature,
includeLocation
),
getStacktraceBody(
targetEventData,
hasSimilarityEmbeddingsFeature,
includeLocation
),
]);

this.setState({
Expand Down
6 changes: 4 additions & 2 deletions static/app/utils/getStacktraceBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type {Event} from 'sentry/types/event';

export default function getStacktraceBody(
event: Event,
hasSimilarityEmbeddingsFeature = false
hasSimilarityEmbeddingsFeature = false,
includeLocation = true
) {
if (!event?.entries) {
return [];
Expand Down Expand Up @@ -40,7 +41,8 @@ export default function getStacktraceBody(
value.stacktrace,
event.platform,
value,
hasSimilarityEmbeddingsFeature
hasSimilarityEmbeddingsFeature,
includeLocation
)
)
.reduce((acc: any, value: any) => acc.concat(value), []);
Expand Down
Loading