Skip to content
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 @@ -25,7 +25,6 @@ import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';
import {useIssuesTraceTree} from 'sentry/views/performance/newTraceDetails/traceApi/useIssuesTraceTree';
import {useTrace} from 'sentry/views/performance/newTraceDetails/traceApi/useTrace';
import {isEAPTraceOccurrence} from 'sentry/views/performance/newTraceDetails/traceGuards';
import useTraceStateAnalytics from 'sentry/views/performance/newTraceDetails/useTraceStateAnalytics';

enum AnrRootCauseAllowlist {
Expand Down Expand Up @@ -143,12 +142,9 @@ export function AnrRootCause({event, organization}: Props) {
>
{potentialAnrRootCause?.map(occurence => {
const project = projects.find(p => p.id === occurence.project_id.toString());
const title = isEAPTraceOccurrence(occurence)
? occurence.description
: occurence.title;
const shortId = isEAPTraceOccurrence(occurence)
? occurence.short_id
: occurence.issue_short_id;
const isEAPOccurence = 'description' in occurence;
const title = isEAPOccurence ? occurence.description : occurence.title;
const shortId = isEAPOccurence ? occurence.short_id : occurence.issue_short_id;
return (
<IssueSummary key={occurence.issue_id}>
<Title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {decodeScalar} from 'sentry/utils/queryString';
import type RequestError from 'sentry/utils/requestError/requestError';
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
import {isValidEventUUID} from 'sentry/views/performance/newTraceDetails/traceApi/utils';
import type {TraceTree} from 'sentry/views/performance/newTraceDetails/traceModels/traceTree';
import {useIsEAPTraceEnabled} from 'sentry/views/performance/newTraceDetails/useIsEAPTraceEnabled';

Expand Down Expand Up @@ -291,3 +290,9 @@ export function useTrace(

return isDemoMode ? demoTrace : isEAPEnabled ? eapTraceQuery : traceQuery;
}

const isValidEventUUID = (id: string): boolean => {
const uuidRegex =
/^[0-9a-f]{8}[0-9a-f]{4}[1-5][0-9a-f]{3}[89ab][0-9a-f]{3}[0-9a-f]{12}$/i;
return uuidRegex.test(id);
};
23 changes: 16 additions & 7 deletions static/app/views/performance/newTraceDetails/traceApi/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import type {TraceItemDetailsResponse} from 'sentry/views/explore/hooks/useTraceItemDetails';
import type {TraceSplitResults} from 'sentry/views/performance/newTraceDetails/traceApi/types';
import type {TraceRootEventQueryResults} from 'sentry/views/performance/newTraceDetails/traceApi/useTraceRootEvent';
import {isTraceSplitResult} from 'sentry/views/performance/newTraceDetails/traceGuards';
import type {TraceTree} from 'sentry/views/performance/newTraceDetails/traceModels/traceTree';
import type {BaseNode} from 'sentry/views/performance/newTraceDetails/traceModels/traceTreeNode/baseNode';

export function isBrowserRequestNode(node: BaseNode): boolean {
return (
// Adjust for SDK changes in https://github.com/getsentry/sentry-javascript/pull/13527
node.op === 'browser.request' ||
(node.op === 'browser' && node.description === 'request')
);
}

export function isTraceSplitResult(
result: TraceTree.Trace
): result is TraceSplitResults<TraceTree.Transaction> {
return 'transactions' in result && 'orphan_errors' in result;
}

export function isEmptyTrace(trace: TraceTree.Trace): boolean {
if (isTraceSplitResult(trace)) {
Expand All @@ -16,9 +31,3 @@ export const isTraceItemDetailsResponse = (
): data is TraceItemDetailsResponse => {
return data !== undefined && 'attributes' in data;
};

export const isValidEventUUID = (id: string): boolean => {
const uuidRegex =
/^[0-9a-f]{8}[0-9a-f]{4}[1-5][0-9a-f]{3}[89ab][0-9a-f]{3}[0-9a-f]{12}$/i;
return uuidRegex.test(id);
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type {Group} from 'sentry/types/group';
import type {Organization} from 'sentry/types/organization';
import {useApiQuery} from 'sentry/utils/queryClient';
import {TraceDrawerComponents} from 'sentry/views/performance/newTraceDetails/traceDrawer/details/styles';
import {isTraceOccurence} from 'sentry/views/performance/newTraceDetails/traceGuards';
import {TraceIcons} from 'sentry/views/performance/newTraceDetails/traceIcons';
import type {TraceTree} from 'sentry/views/performance/newTraceDetails/traceModels/traceTree';
import type {BaseNode} from 'sentry/views/performance/newTraceDetails/traceModels/traceTreeNode/baseNode';
Expand Down Expand Up @@ -69,8 +68,8 @@ function Issue(props: IssueProps) {
}
);

const isOccurence: boolean = isTraceOccurence(props.issue);
const iconClassName: string = isOccurence ? 'occurence' : props.issue.level;
const iconClassName: string =
props.issue.event_type === 'error' ? props.issue.level : 'occurence';

return isPending ? (
<StyledLoadingIndicatorWrapper>
Expand Down
99 changes: 0 additions & 99 deletions static/app/views/performance/newTraceDetails/traceGuards.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type {TraceSplitResults} from './traceApi/types';
import type {TraceTree} from './traceModels/traceTree';
import type {BaseNode} from './traceModels/traceTreeNode/baseNode';
import type {CollapsedNode} from './traceModels/traceTreeNode/collapsedNode';
Expand Down Expand Up @@ -73,101 +72,3 @@ export function isCollapsedNode(node: BaseNode): node is CollapsedNode {
export function isTraceError(value: TraceTree.NodeValue): value is TraceTree.TraceError {
return !!(value && 'level' in value && 'message' in value);
}

export function isTraceErrorNode(node: BaseNode): node is BaseNode<TraceTree.TraceError> {
return isTraceError(node.value);
}

export function isTraceNode(
node: BaseNode
): node is BaseNode<TraceSplitResults<TraceTree.Transaction>> {
return !!(node.value && 'orphan_errors' in node.value && 'transactions' in node.value);
}

export function shouldAddMissingInstrumentationSpan(sdk: string | undefined): boolean {
if (!sdk) {
return true;
}
if (sdk.length < 'sentry.javascript.'.length) {
return true;
}

switch (sdk.toLowerCase()) {
case 'sentry.javascript.browser':
case 'sentry.javascript.react':
case 'sentry.javascript.gatsby':
case 'sentry.javascript.ember':
case 'sentry.javascript.vue':
case 'sentry.javascript.angular':
case 'sentry.javascript.angular-ivy':
case 'sentry.javascript.nextjs':
case 'sentry.javascript.nuxt':
case 'sentry.javascript.electron':
case 'sentry.javascript.remix':
case 'sentry.javascript.svelte':
case 'sentry.javascript.sveltekit':
case 'sentry.javascript.react-native':
case 'sentry.javascript.astro':
return false;
case undefined:
return true;
default:
return true;
}
}

export function isJavascriptSDKEvent(value: TraceTree.NodeValue): boolean {
return (
!!value &&
'sdk_name' in value &&
/javascript|angular|astro|backbone|ember|gatsby|nextjs|react|remix|svelte|vue/.test(
value.sdk_name
)
);
}

export function isBrowserRequestNode(node: BaseNode): boolean {
return (
// Adjust for SDK changes in https://github.com/getsentry/sentry-javascript/pull/13527
node.op === 'browser.request' ||
(node.op === 'browser' && node.description === 'request')
);
}

export function isTraceOccurence(
issue: TraceTree.TraceIssue
): issue is TraceTree.TraceOccurrence {
return 'issue_id' in issue && issue.event_type !== 'error';
}

export function isEAPTraceOccurrence(
issue: TraceTree.TraceIssue
): issue is TraceTree.EAPOccurrence {
return (
isTraceOccurence(issue) && 'event_type' in issue && issue.event_type === 'occurrence'
);
}

export function isStandaloneSpanMeasurementNode(node: BaseNode): boolean {
if (node.value && 'op' in node.value && node.value.op) {
if (
node.value.op.startsWith('ui.webvital.') ||
node.value.op.startsWith('ui.interaction.')
) {
return true;
}
}

return false;
}

export function isRootEvent(value: TraceTree.NodeValue): boolean {
// Root events has no parent_span_id
return !!value && 'parent_span_id' in value && value.parent_span_id === null;
}

export function isTraceSplitResult(
result: TraceTree.Trace
): result is TraceSplitResults<TraceTree.Transaction> {
return 'transactions' in result && 'orphan_errors' in result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {OrganizationFixture} from 'sentry-fixture/organization';
import {EntryType} from 'sentry/types/event';
import {
isSpanNode,
isTraceErrorNode,
isTraceNode,
isTransactionNode,
} from 'sentry/views/performance/newTraceDetails/traceGuards';
import {TraceTree} from 'sentry/views/performance/newTraceDetails/traceModels/traceTree';
Expand Down Expand Up @@ -61,13 +59,6 @@ function mockSpansResponse(
});
}

function hasErrors(n: BaseNode): boolean {
return (
(isTraceErrorNode(n) || n.errors.size > 0 || n.occurrences.size > 0) &&
!isTraceNode(n)
);
}

describe('IssuesTraceTree', () => {
it('collapsed nodes without errors', () => {
const tree = IssuesTraceTree.FromTrace(traceWithErrorInMiddle, {
Expand All @@ -76,7 +67,7 @@ describe('IssuesTraceTree', () => {
organization,
});

const issues = tree.root.findAllChildren(n => hasErrors(n));
const issues = tree.root.children[0]!.findAllChildren(n => n.hasIssues);
expect(tree.build().collapseList(issues, 3, 0).serialize()).toMatchSnapshot();
});

Expand All @@ -87,11 +78,11 @@ describe('IssuesTraceTree', () => {
organization,
});

const error = tree.root.findChild(n => hasErrors(n));
const error = tree.root.children[0]!.findChild(n => n.hasIssues);

let node = error;
const nodes: Array<BaseNode<any>> = [];
while (node && !isTraceNode(node)) {
while (node) {
nodes.push(node);
node = node.parent;
}
Expand All @@ -107,7 +98,13 @@ describe('IssuesTraceTree', () => {
organization,
});

const errors = tree.root.findAllChildren(n => hasErrors(n)).slice(0, 10);
const errors = tree.root
.findAllChildren(
n =>
n.hasIssues &&
!!(n.value && 'event_type' in n.value && n.value.event_type === 'error')
)
.slice(0, 10);
expect(tree.build().collapseList(errors, 3, 0).serialize()).toMatchSnapshot();
});

Expand All @@ -118,7 +115,7 @@ describe('IssuesTraceTree', () => {
organization,
});

const issues = tree.root.findAllChildren(n => hasErrors(n));
const issues = tree.root.children[0]!.findAllChildren(n => n.hasIssues);

// Test with default value (3)
const defaultCollapsed = tree.build().collapseList(issues, 3, 0).serialize();
Expand All @@ -139,7 +136,7 @@ describe('IssuesTraceTree', () => {
organization,
});

const issues = tree.root.findAllChildren(n => hasErrors(n));
const issues = tree.root.children[0]!.findAllChildren(n => n.hasIssues);

// Test with default minShownNodes value
const defaultMinShown = tree.build().collapseList(issues, 0, 3).serialize();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {Measurement} from 'sentry/types/event';
import {MobileVital, WebVital} from 'sentry/utils/fields';
import {isStandaloneSpanMeasurementNode} from 'sentry/views/performance/newTraceDetails/traceGuards';

import type {BaseNode} from './traceTreeNode/baseNode';
import type {TraceTree} from './traceTree';
Expand Down Expand Up @@ -168,3 +167,16 @@ export function collectTraceMeasurements(

return indicators;
}

function isStandaloneSpanMeasurementNode(node: BaseNode): boolean {
if (node.value && 'op' in node.value && node.value.op) {
if (
node.value.op.startsWith('ui.webvital.') ||
node.value.op.startsWith('ui.interaction.')
) {
return true;
}
}

return false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@ import type {
} from 'sentry/views/performance/newTraceDetails/traceApi/types';
import {getTraceQueryParams} from 'sentry/views/performance/newTraceDetails/traceApi/useTrace';
import type {TraceMetaQueryResults} from 'sentry/views/performance/newTraceDetails/traceApi/useTraceMeta';
import {isTraceSplitResult} from 'sentry/views/performance/newTraceDetails/traceApi/utils';
import {
isEAPError,
isEAPSpan,
isJavascriptSDKEvent,
isMissingInstrumentationNode,
isParentAutogroupedNode,
isRootEvent,
isSiblingAutogroupedNode,
isTraceError,
isTraceSplitResult,
isUptimeCheck,
shouldAddMissingInstrumentationSpan,
} from 'sentry/views/performance/newTraceDetails/traceGuards';
import {
collectTraceMeasurements,
Expand Down Expand Up @@ -1555,3 +1552,50 @@ function hasPreferredOp(node: BaseNode): boolean {
const op = node.op;
return !!op && CANDIDATE_TRACE_TITLE_OPS.includes(op);
}

function shouldAddMissingInstrumentationSpan(sdk: string | undefined): boolean {
if (!sdk) {
return true;
}
if (sdk.length < 'sentry.javascript.'.length) {
return true;
}

switch (sdk.toLowerCase()) {
case 'sentry.javascript.browser':
case 'sentry.javascript.react':
case 'sentry.javascript.gatsby':
case 'sentry.javascript.ember':
case 'sentry.javascript.vue':
case 'sentry.javascript.angular':
case 'sentry.javascript.angular-ivy':
case 'sentry.javascript.nextjs':
case 'sentry.javascript.nuxt':
case 'sentry.javascript.electron':
case 'sentry.javascript.remix':
case 'sentry.javascript.svelte':
case 'sentry.javascript.sveltekit':
case 'sentry.javascript.react-native':
case 'sentry.javascript.astro':
return false;
case undefined:
return true;
default:
return true;
}
}

function isJavascriptSDKEvent(value: TraceTree.NodeValue): boolean {
return (
!!value &&
'sdk_name' in value &&
/javascript|angular|astro|backbone|ember|gatsby|nextjs|react|remix|svelte|vue/.test(
value.sdk_name
)
);
}

function isRootEvent(value: TraceTree.NodeValue): boolean {
// Root events has no parent_span_id
return !!value && 'parent_span_id' in value && value.parent_span_id === null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import {pickBarColor} from 'sentry/components/performance/waterfall/utils';
import {t} from 'sentry/locale';
import type {Measurement} from 'sentry/types/event';
import {TraceItemDataset} from 'sentry/views/explore/types';
import {isBrowserRequestNode} from 'sentry/views/performance/newTraceDetails/traceApi/utils';
import {EAPSpanNodeDetails} from 'sentry/views/performance/newTraceDetails/traceDrawer/details/span';
import type {TraceTreeNodeDetailsProps} from 'sentry/views/performance/newTraceDetails/traceDrawer/tabs/traceTreeNodeDetails';
import {
isBrowserRequestNode,
isEAPSpanNode,
} from 'sentry/views/performance/newTraceDetails/traceGuards';
import {isEAPSpanNode} from 'sentry/views/performance/newTraceDetails/traceGuards';
import type {TraceTree} from 'sentry/views/performance/newTraceDetails/traceModels/traceTree';
import {TraceEAPSpanRow} from 'sentry/views/performance/newTraceDetails/traceRow/traceEAPSpanRow';
import type {TraceRowProps} from 'sentry/views/performance/newTraceDetails/traceRow/traceRow';
Expand Down
Loading
Loading