Skip to content

Commit 07c88ec

Browse files
authored
chore(flamegraph): Remove transactions from differential flamegraphs (#80807)
Due to continuous profiling, we can no longer associate functions to transactions. Only transactions to functions. This removes any reference to transactions in differential flamegraphs so we are only working with functions.
1 parent 7a3168c commit 07c88ec

File tree

5 files changed

+33
-293
lines changed

5 files changed

+33
-293
lines changed

static/app/components/events/eventStatisticalDetector/eventDifferentialFlamegraph.tsx

Lines changed: 14 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import ButtonBar from 'sentry/components/buttonBar';
88
import Link from 'sentry/components/links/link';
99
import LoadingIndicator from 'sentry/components/loadingIndicator';
1010
import Panel from 'sentry/components/panels/panel';
11-
import PerformanceDuration from 'sentry/components/performanceDuration';
1211
import Placeholder from 'sentry/components/placeholder';
1312
import {DifferentialFlamegraph} from 'sentry/components/profiling/flamegraph/differentialFlamegraph';
1413
import {DifferentialFlamegraphToolbar} from 'sentry/components/profiling/flamegraph/flamegraphToolbar/differentialFlamegraphToolbar';
@@ -18,6 +17,7 @@ import ProjectsStore from 'sentry/stores/projectsStore';
1817
import {space} from 'sentry/styles/space';
1918
import type {Event} from 'sentry/types/event';
2019
import type {Project} from 'sentry/types/project';
20+
import {defined} from 'sentry/utils';
2121
import {formatAbbreviatedNumber} from 'sentry/utils/formatters';
2222
import {formatPercentage} from 'sentry/utils/number/formatPercentage';
2323
import {
@@ -31,7 +31,6 @@ import {FlamegraphThemeProvider} from 'sentry/utils/profiling/flamegraph/flamegr
3131
import {useFlamegraphTheme} from 'sentry/utils/profiling/flamegraph/useFlamegraphTheme';
3232
import type {FlamegraphFrame} from 'sentry/utils/profiling/flamegraphFrame';
3333
import type {Frame} from 'sentry/utils/profiling/frame';
34-
import type {EventsResultsDataRow} from 'sentry/utils/profiling/hooks/types';
3534
import {useDifferentialFlamegraphModel} from 'sentry/utils/profiling/hooks/useDifferentialFlamegraphModel';
3635
import type {DifferentialFlamegraphQueryResult} from 'sentry/utils/profiling/hooks/useDifferentialFlamegraphQuery';
3736
import {useDifferentialFlamegraphQuery} from 'sentry/utils/profiling/hooks/useDifferentialFlamegraphQuery';
@@ -41,8 +40,6 @@ import useOrganization from 'sentry/utils/useOrganization';
4140
import usePageFilters from 'sentry/utils/usePageFilters';
4241
import {LOADING_PROFILE_GROUP} from 'sentry/views/profiling/profileGroupProvider';
4342

44-
import {useTransactionsDelta} from './transactionsDeltaProvider';
45-
4643
interface EventDifferentialFlamegraphProps {
4744
event: Event;
4845
}
@@ -75,53 +72,13 @@ export function EventDifferentialFlamegraph(props: EventDifferentialFlamegraphPr
7572
});
7673
}, [isValid, fingerprint, breakpoint]);
7774

78-
const transactions = useTransactionsDelta();
79-
const [transaction, setTransaction] = useState<
80-
EventsResultsDataRow<string> | undefined
81-
>(undefined);
82-
83-
if (transaction === undefined) {
84-
const firstTransaction = transactions?.data?.data?.[0];
85-
if (firstTransaction) {
86-
setTransaction(firstTransaction);
87-
}
88-
}
89-
9075
const {before, after} = useDifferentialFlamegraphQuery({
9176
projectID: parseInt(props.event.projectID, 10),
9277
breakpoint,
9378
environments: selection.selection.environments,
9479
fingerprint: props.event.occurrence?.evidenceData?.fingerprint,
95-
transaction: (transaction?.transaction as string) ?? '',
9680
});
9781

98-
const onNextTransactionClick = useMemo(() => {
99-
if (!transaction) {
100-
return undefined;
101-
}
102-
const idx = transactions?.data?.data?.indexOf?.(transaction) ?? -1;
103-
if (idx === -1 || idx === (transactions?.data?.data?.length ?? 0) - 1) {
104-
return undefined;
105-
}
106-
107-
return () => {
108-
setTransaction(transactions?.data?.data?.[idx + 1] ?? transaction);
109-
};
110-
}, [transaction, transactions?.data?.data]);
111-
112-
const onPreviousTransactionClick = useMemo(() => {
113-
if (!transaction) {
114-
return undefined;
115-
}
116-
const idx = transactions?.data?.data?.indexOf?.(transaction) ?? -1;
117-
if (idx === -1 || idx === 0) {
118-
return undefined;
119-
}
120-
return () => {
121-
setTransaction(transactions?.data?.data?.[idx - 1] ?? transaction);
122-
};
123-
}, [transaction, transactions?.data?.data]);
124-
12582
return (
12683
<Fragment>
12784
<FlamegraphThemeProvider>
@@ -135,9 +92,6 @@ export function EventDifferentialFlamegraph(props: EventDifferentialFlamegraphPr
13592
>
13693
<EventDifferentialFlamegraphView
13794
project={project}
138-
onNextTransactionClick={onNextTransactionClick}
139-
onPreviousTransactionClick={onPreviousTransactionClick}
140-
transaction={transaction}
14195
before={before}
14296
after={after}
14397
/>
@@ -158,10 +112,7 @@ function systemFrameOnly(frame: Frame): boolean {
158112
interface EventDifferentialFlamegraphViewProps {
159113
after: DifferentialFlamegraphQueryResult['before'];
160114
before: DifferentialFlamegraphQueryResult['after'];
161-
onNextTransactionClick: (() => void) | undefined;
162-
onPreviousTransactionClick: (() => void) | undefined;
163115
project: Project | undefined;
164-
transaction: EventsResultsDataRow<string> | undefined;
165116
}
166117
function EventDifferentialFlamegraphView(props: EventDifferentialFlamegraphViewProps) {
167118
const organization = useOrganization();
@@ -196,39 +147,28 @@ function EventDifferentialFlamegraphView(props: EventDifferentialFlamegraphViewP
196147
if (!frame.profileIds?.length) {
197148
return '';
198149
}
199-
const profileId = frame.profileIds[0];
200-
201-
if (typeof profileId !== 'undefined') {
202-
return (
203-
generateProfileRouteFromProfileReference({
204-
orgSlug: organization.slug,
205-
projectSlug: props.project.slug,
206-
reference:
207-
typeof profileId === 'string'
208-
? profileId
209-
: 'profiler_id' in profileId
210-
? profileId.profiler_id
211-
: profileId.profile_id,
212-
framePackage: frame.frame.package,
213-
frameName: frame.frame.name,
214-
}) ?? ''
215-
);
150+
const profile = frame.profileIds?.[0];
151+
152+
if (!defined(profile)) {
153+
return '';
216154
}
217155

218-
// Regression issues do not work with continuous profiles
219-
return '';
156+
return (
157+
generateProfileRouteFromProfileReference({
158+
orgSlug: organization.slug,
159+
projectSlug: props.project.slug,
160+
reference: profile,
161+
framePackage: frame.frame.package,
162+
frameName: frame.frame.name,
163+
}) ?? ''
164+
);
220165
},
221166
[organization.slug, props.project]
222167
);
223168

224169
return (
225170
<FlamegraphContainer>
226171
<StyledPanel>
227-
<DifferentialFlamegraphTransactionToolbar
228-
transaction={props.transaction}
229-
onNextTransactionClick={props.onNextTransactionClick}
230-
onPreviousTransactionClick={props.onPreviousTransactionClick}
231-
/>
232172
<DifferentialFlamegraphToolbar
233173
frameFilter={frameFilterSetting}
234174
onFrameFilterChange={setFrameFilterSetting}
@@ -310,85 +250,6 @@ function EventDifferentialFlamegraphView(props: EventDifferentialFlamegraphViewP
310250
);
311251
}
312252

313-
const numberFormatter = Intl.NumberFormat(undefined, {
314-
maximumFractionDigits: 2,
315-
});
316-
317-
interface DifferentialFlamegraphTransactionToolbarProps {
318-
onNextTransactionClick: (() => void) | undefined;
319-
onPreviousTransactionClick: (() => void) | undefined;
320-
transaction: EventsResultsDataRow<string> | undefined;
321-
}
322-
function DifferentialFlamegraphTransactionToolbar(
323-
props: DifferentialFlamegraphTransactionToolbarProps
324-
) {
325-
const [before, after] = useMemo(() => {
326-
if (!props.transaction) {
327-
return [0, 0];
328-
}
329-
330-
const keys = Object.keys(props.transaction);
331-
332-
let beforePercentile = 0;
333-
let afterPercentile = 0;
334-
335-
for (const key of keys) {
336-
if (key.startsWith('percentile_after')) {
337-
afterPercentile = props.transaction[key] as number;
338-
}
339-
if (key.startsWith('percentile_before')) {
340-
beforePercentile = props.transaction[key] as number;
341-
}
342-
}
343-
344-
return [beforePercentile, afterPercentile];
345-
}, [props.transaction]);
346-
347-
return (
348-
<DifferentialFlamegraphTransactionToolbarContainer>
349-
{props.transaction?.transaction ? (
350-
<DifferentialFlamegraphTransactionName>
351-
{props.transaction.transaction}
352-
</DifferentialFlamegraphTransactionName>
353-
) : (
354-
<Placeholder height="20px" width="66%" />
355-
)}
356-
357-
{props.transaction ? (
358-
<span>
359-
<PerformanceDuration nanoseconds={before} abbreviation />
360-
<DifferentialFlamegraphRegressionChange>
361-
{after === 0 || before === 0
362-
? ''
363-
: '+' + numberFormatter.format(relativeChange(after, before) * 100) + '%'}
364-
</DifferentialFlamegraphRegressionChange>
365-
</span>
366-
) : (
367-
<Fragment>
368-
<Placeholder height="20px" width="60px" />
369-
<Placeholder height="20px" width="60px" />
370-
</Fragment>
371-
)}
372-
<ButtonBar merged>
373-
<DifferentialFlamegraphPaginationButton
374-
icon={<IconChevron direction="left" />}
375-
aria-label={t('Previous Transaction')}
376-
size="xs"
377-
disabled={!props.onPreviousTransactionClick}
378-
onClick={props.onPreviousTransactionClick}
379-
/>
380-
<DifferentialFlamegraphPaginationButton
381-
icon={<IconChevron direction="right" />}
382-
aria-label={t('Next Transaction')}
383-
size="xs"
384-
disabled={!props.onNextTransactionClick}
385-
onClick={props.onNextTransactionClick}
386-
/>
387-
</ButtonBar>
388-
</DifferentialFlamegraphTransactionToolbarContainer>
389-
);
390-
}
391-
392253
interface PaginationReducerState {
393254
page: number;
394255
pageCount: number;
@@ -762,26 +623,6 @@ const DifferentialFlamegraphPaginationButton = styled(Button)`
762623
padding-left: ${space(0.75)};
763624
padding-right: ${space(0.75)};
764625
`;
765-
const DifferentialFlamegraphTransactionName = styled('div')`
766-
font-weight: ${p => p.theme.fontWeightBold};
767-
flex: 1;
768-
overflow: hidden;
769-
text-overflow: ellipsis;
770-
`;
771-
772-
const DifferentialFlamegraphRegressionChange = styled('span')`
773-
margin-left: ${space(1)};
774-
color: ${p => p.theme.red300};
775-
`;
776-
777-
const DifferentialFlamegraphTransactionToolbarContainer = styled('div')`
778-
display: flex;
779-
justify-content: space-between;
780-
align-items: center;
781-
padding: ${space(1)};
782-
gap: ${space(1)};
783-
border-bottom: 1px solid ${p => p.theme.border};
784-
`;
785626

786627
const ErrorMessageContainer = styled('div')`
787628
position: absolute;

static/app/components/events/eventStatisticalDetector/transactionsDeltaProvider.tsx

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)