Skip to content

Commit

Permalink
feat(starfish): fix missing stuff in p95 conversion (#50187)
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikB2014 authored Jun 2, 2023
1 parent da5ea68 commit 25a294d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
19 changes: 12 additions & 7 deletions static/app/views/starfish/components/facetInsights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import {MutableSearch} from 'sentry/utils/tokenizeSearch';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
import {TAG_EXPLORER_COLUMN_ORDER} from 'sentry/views/performance/transactionSummary/transactionOverview/tagExplorer';
import {P95_COLOR} from 'sentry/views/starfish/colours';
import Sparkline from 'sentry/views/starfish/components/sparkline';
import {
OverflowEllipsisTextContainer,
TextAlignLeft,
} from 'sentry/views/starfish/components/textAlign';
import {DataTitles} from 'sentry/views/starfish/views/spans/types';

type Props = {
eventView: EventView;
Expand All @@ -35,7 +37,10 @@ type DataRow = {
tpmCorrelation: string;
};

const COLUMN_ORDER = [
type Keys = 'tagKey' | 'tagValue' | 'p95' | 'throughput' | 'tpmCorrelation';
type TableColumnHeader = GridColumnHeader<Keys>;

const COLUMN_ORDER: TableColumnHeader[] = [
{
key: 'tagKey',
name: 'Key',
Expand All @@ -47,8 +52,8 @@ const COLUMN_ORDER = [
width: 200,
},
{
key: 'p50',
name: 'p50(duration)',
key: 'p95',
name: DataTitles.p95,
width: 200,
},
{
Expand Down Expand Up @@ -84,11 +89,11 @@ export function FacetInsights({eventView}: Props) {
},
]);

function renderBodyCell(column: GridColumnHeader, row: DataRow): React.ReactNode {
if (column.key === 'throughput' || column.key === 'p50') {
function renderBodyCell(column: TableColumnHeader, row: DataRow): React.ReactNode {
if (column.key === 'throughput' || column.key === 'p95') {
return (
<Sparkline
color={column.key === 'throughput' ? CHART_PALETTE[3][0] : CHART_PALETTE[3][1]}
color={column.key === 'throughput' ? CHART_PALETTE[3][0] : P95_COLOR}
series={row[column.key]}
width={column.width ? column.width - column.width / 5 : undefined}
/>
Expand Down Expand Up @@ -177,7 +182,7 @@ export function FacetInsights({eventView}: Props) {
columnSortBy={[]}
location={location}
grid={{
renderBodyCell: (column: GridColumnHeader, row: DataRow) =>
renderBodyCell: (column: TableColumnHeader, row: DataRow) =>
renderBodyCell(column, row),
}}
/>
Expand Down
11 changes: 6 additions & 5 deletions static/app/views/starfish/utils/generatePerformanceEventView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export function generateWebServiceEventView(
organization: Organization
) {
const {query} = location;
const percentile = '0.95';
const hasStartAndEnd = query.start && query.end;
const middleTimestamp = getMiddleTimestamp({
start: decodeScalar(query.start),
Expand All @@ -130,13 +131,13 @@ export function generateWebServiceEventView(
: decodeScalar(query.statsPeriod),
});

const deltaColName = `equation|(percentile_range(transaction.duration,0.50,lessOrEquals,${middleTimestamp})-percentile_range(transaction.duration,0.50,greater,${middleTimestamp}))/percentile_range(transaction.duration,0.50,lessOrEquals,${middleTimestamp})`;
const deltaColName = `equation|(percentile_range(transaction.duration,${percentile},lessOrEquals,${middleTimestamp})-percentile_range(transaction.duration,0.95,greater,${middleTimestamp}))/percentile_range(transaction.duration,${percentile},lessOrEquals,${middleTimestamp})`;
let orderby = decodeScalar(query.sort, `-${TIME_SPENT_IN_SERVICE}`);
const isDescending = orderby.startsWith('-');
const rawOrderby = trimStart(orderby, '-');
if (
rawOrderby.startsWith(
'equation|(percentile_range(transaction.duration,0.50,lessOrEquals,'
`equation|(percentile_range(transaction.duration,${percentile},lessOrEquals,`
)
) {
orderby = isDescending ? `-${deltaColName}` : deltaColName;
Expand All @@ -146,14 +147,14 @@ export function generateWebServiceEventView(
'transaction',
'http.method',
'tpm()',
'p50()',
'p95()',
deltaColName,
'count_if(http.status_code,greaterOrEquals,500)',
TIME_SPENT_IN_SERVICE,
'total.transaction_duration',
'sum(transaction.duration)',
`percentile_range(transaction.duration,0.50,lessOrEquals,${middleTimestamp})`,
`percentile_range(transaction.duration,0.50,greater,${middleTimestamp})`,
`percentile_range(transaction.duration,${percentile},lessOrEquals,${middleTimestamp})`,
`percentile_range(transaction.duration,${percentile},greater,${middleTimestamp})`,
];

const savedQuery: NewQuery = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const EventsRequest = withApi(_EventsRequest);
type EndpointAggregateDetails = {
failureCount: number;
p50: number;
p95: number;
tpm: number;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from 'sentry/utils/discover/fields';
import {TableColumn} from 'sentry/views/discover/table/types';

const COLUMN_TITLES = ['endpoint', 'tpm', 'p50(duration)', 'p95(duration)'];
const COLUMN_TITLES = ['endpoint', 'tpm', 'p95(duration)'];

import styled from '@emotion/styled';

Expand Down Expand Up @@ -144,7 +144,7 @@ function EndpointList({

if (
field.startsWith(
'equation|(percentile_range(transaction.duration,0.50,lessOrEquals,'
'equation|(percentile_range(transaction.duration,0.95,lessOrEquals,'
)
) {
const deltaValue = dataRow[field] as number;
Expand Down Expand Up @@ -189,10 +189,10 @@ function EndpointList({
Object.keys(tableData.data[0]).forEach(col => {
if (
col.startsWith(
'equation|(percentile_range(transaction.duration,0.50,lessOrEquals'
'equation|(percentile_range(transaction.duration,0.95,lessOrEquals'
)
) {
deltaColumnMap['p50()'] = col;
deltaColumnMap['p95()'] = col;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ export function StarfishView(props: BasePerformanceViewProps) {
columnTitles={[
'endpoint',
'tpm',
'p50(duration)',
'p50 change',
DataTitles.p95,
'p95 change',
'failure count',
'cumulative time',
]}
Expand Down

0 comments on commit 25a294d

Please sign in to comment.