Skip to content
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

feat(insights): Switch to ratios for slow and frozen frames #74523

Merged
merged 5 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions static/app/components/gridEditable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export type GridColumn<K = ObjectKey> = {

export type GridColumnHeader<K = ObjectKey> = GridColumn<K> & {
name: string;
tooltip?: string;
markushi marked this conversation as resolved.
Show resolved Hide resolved
};

export type GridColumnOrder<K = ObjectKey> = GridColumnHeader<K>;
Expand Down
4 changes: 4 additions & 0 deletions static/app/utils/discover/fieldRenderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,10 @@ export function getSortField(
return field;
}

if (field.startsWith('division_if(')) {
Copy link
Member Author

@markushi markushi Jul 19, 2024

Choose a reason for hiding this comment

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

This feels like a hack 🙈, an alternative would be adding them to aggregations, but then we'd need to support this for discover queries as well (see count_if as an example,

[AggregationKey.COUNT_IF]: {
...getDocsAndOutputType(AggregationKey.COUNT_IF),
parameters: [
{
kind: 'column',
columnTypes: validateDenyListColumns(
['string', 'duration', 'number'],
['id', 'issue', 'user.display']
),
defaultValue: 'transaction.duration',
required: true,
},
{
kind: 'dropdown',
options: CONDITIONS_ARGUMENTS,
dataType: 'string',
defaultValue: CONDITIONS_ARGUMENTS[0].value,
required: true,
},
{
kind: 'value',
dataType: 'string',
defaultValue: '300',
required: true,
},
],
isSortable: true,
multiPlotType: 'area',
) - not too sure if this would blow stuff up, as the backend support for division_if is tightly bound to releases.

Copy link
Member

Choose a reason for hiding this comment

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

I think there's a cleaner way to get around this, but I have to do a bit of investigation. I'm seeing some odd access paths when it comes to the structure of tableMeta. If you want, we can remove this until I get a chance to poke around a bit more and we can put up a separate PR to handle the sortability of the headers.

The endpoint returns in the meta data that the corresponding type to the division_if statements should be percentages so they should be sortable by default when it gets to this block. I know that the key gets kind of mangled for equations but we should be able to work around that

return field;
}

for (const alias in AGGREGATIONS) {
if (field.startsWith(alias)) {
return AGGREGATIONS[alias].isSortable ? field : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ export function AppStartScreens({data, eventView, isLoading, pageLinks}: Props)
'count_starts(measurements.app_start_warm)': t('Warm Start Count'),
};

const columnTooltipMap = {
[`avg_compare(measurements.app_start_cold,release,${primaryRelease},${secondaryRelease})`]:
t('Average Cold Start difference'),
[`avg_compare(measurements.app_start_warm,release,${primaryRelease},${secondaryRelease})`]:
t('Average Warm Start difference'),
};

function renderBodyCell(column, row): React.ReactNode {
if (!data) {
return null;
Expand Down Expand Up @@ -121,6 +128,7 @@ export function AppStartScreens({data, eventView, isLoading, pageLinks}: Props)
return (
<ScreensTable
columnNameMap={columnNameMap}
columnTooltipMap={columnTooltipMap}
data={data}
eventView={eventView}
isLoading={isLoading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('ScreensTable', () => {
columnNameMap={{
transaction: 'Screen',
}}
columnTooltipMap={{}}
columnOrder={['transaction']}
data={{
data: [{id: '1', transaction: 'Screen 1'}],
Expand All @@ -56,6 +57,7 @@ describe('ScreensTable', () => {
columnNameMap={{
transaction: 'Screen',
}}
columnTooltipMap={{}}
columnOrder={['transaction', 'non-custom']}
data={{
data: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Fragment} from 'react';
import styled from '@emotion/styled';

import type {
GridColumn,
Expand All @@ -8,6 +9,7 @@ import type {
import GridEditable, {COL_WIDTH_UNDEFINED} from 'sentry/components/gridEditable';
import SortLink from 'sentry/components/gridEditable/sortLink';
import Pagination from 'sentry/components/pagination';
import {Tooltip} from 'sentry/components/tooltip';
import {defined} from 'sentry/utils';
import {trackAnalytics} from 'sentry/utils/analytics';
import type {TableData, TableDataRow} from 'sentry/utils/discover/discoverQuery';
Expand All @@ -23,6 +25,7 @@ import type {ModuleName} from 'sentry/views/insights/types';
type Props = {
columnNameMap: Record<string, string>;
columnOrder: string[];
columnTooltipMap: Record<string, string> | undefined;
data: TableData | undefined;
defaultSort: GridColumnSortBy<string>[];
eventView: EventView;
Expand All @@ -42,6 +45,7 @@ export function ScreensTable({
pageLinks,
columnNameMap,
columnOrder,
columnTooltipMap,
defaultSort,
customBodyCellRenderer,
moduleName,
Expand Down Expand Up @@ -116,6 +120,20 @@ export function ScreensTable({
generateSortLink={generateSortLink}
/>
);

function columnWithTooltip(tooltipTitle: string) {
return (
<Alignment align={alignment}>
<StyledTooltip isHoverable title={<span>{tooltipTitle}</span>}>
{sortLink}
</StyledTooltip>
</Alignment>
);
}

if (column.tooltip) {
return columnWithTooltip(column.tooltip);
}
return sortLink;
}

Expand All @@ -129,6 +147,7 @@ export function ScreensTable({
key: columnKey,
name: columnNameMap[columnKey],
width: COL_WIDTH_UNDEFINED,
toolTip: columnTooltipMap ? columnTooltipMap[columnKey] : undefined,
markushi marked this conversation as resolved.
Show resolved Hide resolved
};
})}
columnSortBy={defaultSort}
Expand All @@ -152,3 +171,15 @@ export function ScreensTable({
</Fragment>
);
}

const Alignment = styled('span')<{align: string}>`
display: block;
margin: auto;
text-align: ${props => props.align};
width: 100%;
`;

const StyledTooltip = styled(Tooltip)`
top: 1px;
position: relative;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ describe('SpanOperationTable', () => {
'span.op',
'span.group',
'span.description',
'avg_if(mobile.slow_frames,release,foo)',
'avg_if(mobile.slow_frames,release,bar)',
'avg_if(mobile.frozen_frames,release,foo)',
'avg_if(mobile.frozen_frames,release,bar)',
'division_if(mobile.slow_frames,mobile.total_frames,release,foo)',
'division_if(mobile.slow_frames,mobile.total_frames,release,bar)',
'division_if(mobile.frozen_frames,mobile.total_frames,release,foo)',
'division_if(mobile.frozen_frames,mobile.total_frames,release,bar)',
'avg_if(mobile.frames_delay,release,foo)',
'avg_if(mobile.frames_delay,release,bar)',
'avg_compare(mobile.frames_delay,release,foo,bar)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ export function SpanOperationTable({
SPAN_OP,
SPAN_GROUP,
SPAN_DESCRIPTION,
`avg_if(mobile.slow_frames,release,${primaryRelease})`,
`avg_if(mobile.slow_frames,release,${secondaryRelease})`,
`avg_if(mobile.frozen_frames,release,${primaryRelease})`,
`avg_if(mobile.frozen_frames,release,${secondaryRelease})`,
`division_if(mobile.slow_frames,mobile.total_frames,release,${primaryRelease})`,
`division_if(mobile.slow_frames,mobile.total_frames,release,${secondaryRelease})`,
`division_if(mobile.frozen_frames,mobile.total_frames,release,${primaryRelease})`,
`division_if(mobile.frozen_frames,mobile.total_frames,release,${secondaryRelease})`,
`avg_if(mobile.frames_delay,release,${primaryRelease})`,
`avg_if(mobile.frames_delay,release,${secondaryRelease})`,
`avg_compare(mobile.frames_delay,release,${primaryRelease},${secondaryRelease})`,
Expand All @@ -97,22 +97,16 @@ export function SpanOperationTable({
const columnNameMap = {
[SPAN_OP]: t('Operation'),
[SPAN_DESCRIPTION]: t('Span Description'),
[`avg_if(mobile.slow_frames,release,${primaryRelease})`]: t(
[`division_if(mobile.slow_frames,mobile.total_frames,release,${primaryRelease})`]: t(
'Slow (%s)',
PRIMARY_RELEASE_ALIAS
),
[`avg_if(mobile.slow_frames,release,${secondaryRelease})`]: t(
'Slow (%s)',
SECONDARY_RELEASE_ALIAS
),
[`avg_if(mobile.frozen_frames,release,${primaryRelease})`]: t(
'Frozen (%s)',
PRIMARY_RELEASE_ALIAS
),
[`avg_if(mobile.frozen_frames,release,${secondaryRelease})`]: t(
'Frozen (%s)',
SECONDARY_RELEASE_ALIAS
),
[`division_if(mobile.slow_frames,mobile.total_frames,release,${secondaryRelease})`]:
t('Slow (%s)', SECONDARY_RELEASE_ALIAS),
[`division_if(mobile.frozen_frames,mobile.total_frames,release,${primaryRelease})`]:
t('Frozen (%s)', PRIMARY_RELEASE_ALIAS),
[`division_if(mobile.frozen_frames,mobile.total_frames,release,${secondaryRelease})`]:
t('Frozen (%s)', SECONDARY_RELEASE_ALIAS),
[`avg_if(mobile.frames_delay,release,${primaryRelease})`]: t(
'Delay (%s)',
PRIMARY_RELEASE_ALIAS
Expand All @@ -125,6 +119,28 @@ export function SpanOperationTable({
t('Change'),
};

const columnTooltipMap = {
[`division_if(mobile.slow_frames,mobile.total_frames,release,${primaryRelease})`]: t(
'The number of slow frames divided by total frames (%s)',
PRIMARY_RELEASE_ALIAS
),
[`division_if(mobile.slow_frames,mobile.total_frames,release,${secondaryRelease})`]:
t(
'The number of slow frames divided by total frames (%s)',
SECONDARY_RELEASE_ALIAS
),
[`division_if(mobile.frozen_frames,mobile.total_frames,release,${primaryRelease})`]:
t(
'The number of frozen frames divided by total frames (%s)',
PRIMARY_RELEASE_ALIAS
),
[`division_if(mobile.frozen_frames,mobile.total_frames,release,${secondaryRelease})`]:
t(
'The number of frozen frames divided by total frames (%s)',
SECONDARY_RELEASE_ALIAS
),
};

function renderBodyCell(column, row) {
if (column.key === SPAN_DESCRIPTION) {
const label = row[SpanMetricsField.SPAN_DESCRIPTION];
Expand Down Expand Up @@ -163,17 +179,18 @@ export function SpanOperationTable({
return (
<ScreensTable
columnNameMap={columnNameMap}
columnTooltipMap={columnTooltipMap}
data={data}
eventView={eventView}
isLoading={isLoading}
pageLinks={pageLinks}
columnOrder={[
String(SPAN_OP),
String(SPAN_DESCRIPTION),
`avg_if(mobile.slow_frames,release,${primaryRelease})`,
`avg_if(mobile.slow_frames,release,${secondaryRelease})`,
`avg_if(mobile.frozen_frames,release,${primaryRelease})`,
`avg_if(mobile.frozen_frames,release,${secondaryRelease})`,
`division_if(mobile.slow_frames,mobile.total_frames,release,${primaryRelease})`,
`division_if(mobile.slow_frames,mobile.total_frames,release,${secondaryRelease})`,
`division_if(mobile.frozen_frames,mobile.total_frames,release,${primaryRelease})`,
`division_if(mobile.frozen_frames,mobile.total_frames,release,${secondaryRelease})`,
`avg_if(mobile.frames_delay,release,${primaryRelease})`,
`avg_if(mobile.frames_delay,release,${secondaryRelease})`,
`avg_compare(mobile.frames_delay,release,${primaryRelease},${secondaryRelease})`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,16 @@ export function UIScreensTable({data, eventView, isLoading, pageLinks}: Props) {

const columnNameMap = {
transaction: t('Screen'),
[`avg_if(mobile.slow_frames,release,${primaryRelease})`]: t(
[`division_if(mobile.slow_frames,mobile.total_frames,release,${primaryRelease})`]: t(
'Slow (%s)',
PRIMARY_RELEASE_ALIAS
),
[`avg_if(mobile.slow_frames,release,${secondaryRelease})`]: t(
'Slow (%s)',
SECONDARY_RELEASE_ALIAS
),
[`avg_if(mobile.frozen_frames,release,${primaryRelease})`]: t(
'Frozen (%s)',
PRIMARY_RELEASE_ALIAS
),
[`avg_if(mobile.frozen_frames,release,${secondaryRelease})`]: t(
'Frozen (%s)',
SECONDARY_RELEASE_ALIAS
),
[`division_if(mobile.slow_frames,mobile.total_frames,release,${secondaryRelease})`]:
t('Slow (%s)', SECONDARY_RELEASE_ALIAS),
[`division_if(mobile.frozen_frames,mobile.total_frames,release,${primaryRelease})`]:
t('Frozen (%s)', PRIMARY_RELEASE_ALIAS),
[`division_if(mobile.frozen_frames,mobile.total_frames,release,${secondaryRelease})`]:
t('Frozen (%s)', SECONDARY_RELEASE_ALIAS),
[`avg_if(mobile.frames_delay,release,${primaryRelease})`]: t(
'Delay (%s)',
PRIMARY_RELEASE_ALIAS
Expand All @@ -66,6 +60,36 @@ export function UIScreensTable({data, eventView, isLoading, pageLinks}: Props) {
// TODO: Counts
};

const columnTooltipMap = {
[`division_if(mobile.slow_frames,mobile.total_frames,release,${primaryRelease})`]: t(
'The number of slow frames divided by total frames (%s)',
PRIMARY_RELEASE_ALIAS
),
[`division_if(mobile.slow_frames,mobile.total_frames,release,${secondaryRelease})`]:
t(
'The number of slow frames divided by total frames (%s)',
SECONDARY_RELEASE_ALIAS
),
[`division_if(mobile.frozen_frames,mobile.total_frames,release,${primaryRelease})`]:
t(
'The number of frozen frames divided by total frames (%s)',
PRIMARY_RELEASE_ALIAS
),
[`division_if(mobile.frozen_frames,mobile.total_frames,release,${secondaryRelease})`]:
t(
'The number of frozen frames divided by total frames (%s)',
SECONDARY_RELEASE_ALIAS
),
[`avg_if(mobile.frames_delay,release,${primaryRelease})`]: t(
'The average frame delay (%s)',
PRIMARY_RELEASE_ALIAS
),
[`avg_if(mobile.frames_delay,release,${secondaryRelease})`]: t(
'The average frame delay (%s)',
SECONDARY_RELEASE_ALIAS
),
};

function renderBodyCell(column, row): React.ReactNode | null {
if (!data) {
return null;
Expand Down Expand Up @@ -113,16 +137,17 @@ export function UIScreensTable({data, eventView, isLoading, pageLinks}: Props) {
return (
<ScreensTable
columnNameMap={columnNameMap}
columnTooltipMap={columnTooltipMap}
data={data}
eventView={eventView}
isLoading={isLoading}
pageLinks={pageLinks}
columnOrder={[
'transaction',
`avg_if(mobile.slow_frames,release,${primaryRelease})`,
`avg_if(mobile.slow_frames,release,${secondaryRelease})`,
`avg_if(mobile.frozen_frames,release,${primaryRelease})`,
`avg_if(mobile.frozen_frames,release,${secondaryRelease})`,
`division_if(mobile.slow_frames,mobile.total_frames,release,${primaryRelease})`,
`division_if(mobile.slow_frames,mobile.total_frames,release,${secondaryRelease})`,
`division_if(mobile.frozen_frames,mobile.total_frames,release,${primaryRelease})`,
`division_if(mobile.frozen_frames,mobile.total_frames,release,${secondaryRelease})`,
`avg_if(mobile.frames_delay,release,${primaryRelease})`,
`avg_if(mobile.frames_delay,release,${secondaryRelease})`,
`avg_compare(mobile.frames_delay,release,${primaryRelease},${secondaryRelease})`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const createMockTablePayload = ({
null,
'avg_if(mobile.frames_delay,release,com.example.vu.android@2.10.5)': 0,
'avg_if(mobile.frames_delay,release,com.example.vu.android@2.10.3+42)': 0.259326119,
'avg_if(mobile.frozen_frames,release,com.example.vu.android@2.10.5)': 0,
'avg_if(mobile.frozen_frames,release,com.example.vu.android@2.10.3+42)': 0,
'avg_if(mobile.slow_frames,release,com.example.vu.android@2.10.5)': 0,
'avg_if(mobile.slow_frames,release,com.example.vu.android@2.10.3+42)': 2,
'division_if(mobile.frozen_frames,mobile.total_frames,release,com.example.vu.android@2.10.5)': 0,
'division_if(mobile.frozen_frames,mobile.total_frames,release,com.example.vu.android@2.10.3+42)': 0,
'division_if(mobile.slow_frames,mobile.total_frames,release,com.example.vu.android@2.10.5)': 0,
'division_if(mobile.slow_frames,mobile.total_frames,release,com.example.vu.android@2.10.3+42)': 2,
'project.id': project.id,
transaction,
});
Expand Down Expand Up @@ -88,10 +88,10 @@ describe('Performance Mobile UI Screens', () => {
field: [
'project.id',
'transaction',
'avg_if(mobile.slow_frames,release,com.example.vu.android@2.10.5)',
'avg_if(mobile.slow_frames,release,com.example.vu.android@2.10.3+42)',
'avg_if(mobile.frozen_frames,release,com.example.vu.android@2.10.5)',
'avg_if(mobile.frozen_frames,release,com.example.vu.android@2.10.3+42)',
'division_if(mobile.slow_frames,mobile.total_frames,release,com.example.vu.android@2.10.5)',
'division_if(mobile.slow_frames,mobile.total_frames,release,com.example.vu.android@2.10.3+42)',
'division_if(mobile.frozen_frames,mobile.total_frames,release,com.example.vu.android@2.10.5)',
'division_if(mobile.frozen_frames,mobile.total_frames,release,com.example.vu.android@2.10.3+42)',
'avg_if(mobile.frames_delay,release,com.example.vu.android@2.10.5)',
'avg_if(mobile.frames_delay,release,com.example.vu.android@2.10.3+42)',
'avg_compare(mobile.frames_delay,release,com.example.vu.android@2.10.5,com.example.vu.android@2.10.3+42)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export function UIScreens() {
fields: [
SpanMetricsField.PROJECT_ID,
'transaction',
`avg_if(mobile.slow_frames,release,${primaryRelease})`,
`avg_if(mobile.slow_frames,release,${secondaryRelease})`,
`avg_if(mobile.frozen_frames,release,${primaryRelease})`,
`avg_if(mobile.frozen_frames,release,${secondaryRelease})`,
`division_if(mobile.slow_frames,mobile.total_frames,release,${primaryRelease})`,
`division_if(mobile.slow_frames,mobile.total_frames,release,${secondaryRelease})`,
`division_if(mobile.frozen_frames,mobile.total_frames,release,${primaryRelease})`,
`division_if(mobile.frozen_frames,mobile.total_frames,release,${secondaryRelease})`,
`avg_if(mobile.frames_delay,release,${primaryRelease})`,
`avg_if(mobile.frames_delay,release,${secondaryRelease})`,
`avg_compare(mobile.frames_delay,release,${primaryRelease},${secondaryRelease})`,
Expand Down
Loading