Skip to content

Commit 37fd07d

Browse files
authored
feat(insights): use conditional functions frontend overview (#90815)
1. Use conditional versions of avg, sum, percentile and epm in frontend overview 2. Remove `time_spent_percentage` (we'll only be showing time_spent for now, aka `sum(span.duration)`)
1 parent c09cc2f commit 37fd07d

File tree

6 files changed

+52
-29
lines changed

6 files changed

+52
-29
lines changed

static/app/views/insights/common/components/tableCells/renderHeadCell.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const {
3131
TIME_SPENT_PERCENTAGE,
3232
SPS,
3333
EPM,
34+
TPM,
3435
HTTP_RESPONSE_COUNT,
3536
HTTP_RESPONSE_RATE,
3637
CACHE_HIT_RATE,
@@ -48,6 +49,7 @@ const SORTABLE_FIELDS = new Set([
4849
`count()`,
4950
`${SPS}()`,
5051
`${EPM}()`,
52+
`${TPM}()`,
5153
`${TIME_SPENT_PERCENTAGE}()`,
5254
`${HTTP_RESPONSE_COUNT}(5)`,
5355
`${HTTP_RESPONSE_COUNT}(4)`,
@@ -79,6 +81,10 @@ const SORTABLE_FIELDS = new Set([
7981
'failure_rate()',
8082
'performance_score(measurements.score.total)',
8183
'count_unique(user)',
84+
'p50_if(span.duration,is_transaction,true)',
85+
'p95_if(span.duration,is_transaction,true)',
86+
'failure_rate_if(is_transaction,true)',
87+
'sum_if(span.duration,is_transaction,true)',
8288
]);
8389

8490
const NUMERIC_FIELDS = new Set([

static/app/views/insights/constants.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ export const STARFISH_AGGREGATION_FIELDS: Record<
2020
defaultOutputType: 'number',
2121
valueType: FieldValueType.NUMBER,
2222
},
23+
[SpanFunction.TPM]: {
24+
desc: t('Transactions per minute'),
25+
kind: FieldKind.FUNCTION,
26+
defaultOutputType: 'number',
27+
valueType: FieldValueType.NUMBER,
28+
},
2329
[SpanFunction.TIME_SPENT_PERCENTAGE]: {
2430
desc: t('Span time spent percentage'),
2531
defaultOutputType: 'percentage',

static/app/views/insights/pages/frontend/frontendOverviewPage.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,13 @@ function EAPOverviewPage() {
191191
'is_starred_transaction',
192192
'transaction',
193193
'project',
194-
'epm()',
195-
'p50(span.duration)',
196-
'p95(span.duration)',
197-
'failure_rate()',
198-
'time_spent_percentage(span.duration)',
194+
'tpm()',
195+
'p50_if(span.duration,is_transaction,true)',
196+
'p95_if(span.duration,is_transaction,true)',
197+
'failure_rate_if(is_transaction,true)',
199198
'performance_score(measurements.score.total)',
200199
'count_unique(user)',
201-
'sum(span.duration)',
200+
'sum_if(span.duration,is_transaction,true)',
202201
],
203202
},
204203
'api.performance.landing-table'

static/app/views/insights/pages/frontend/frontendOverviewTable.tsx

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,25 @@ type Row = Pick<
2727
| 'is_starred_transaction'
2828
| 'transaction'
2929
| 'project'
30-
| 'epm()'
31-
| 'p50(span.duration)'
32-
| 'p95(span.duration)'
33-
| 'failure_rate()'
34-
| 'time_spent_percentage(span.duration)'
30+
| 'tpm()'
31+
| 'p50_if(span.duration,is_transaction,true)'
32+
| 'p95_if(span.duration,is_transaction,true)'
33+
| 'failure_rate_if(is_transaction,true)'
3534
| 'count_unique(user)'
36-
| 'sum(span.duration)'
35+
| 'sum_if(span.duration,is_transaction,true)'
3736
| 'performance_score(measurements.score.total)'
3837
>;
3938

4039
type Column = GridColumnHeader<
4140
| 'is_starred_transaction'
4241
| 'transaction'
4342
| 'project'
44-
| 'epm()'
45-
| 'p50(span.duration)'
46-
| 'p95(span.duration)'
47-
| 'failure_rate()'
48-
| 'time_spent_percentage(span.duration)'
43+
| 'tpm()'
44+
| 'p50_if(span.duration,is_transaction,true)'
45+
| 'p95_if(span.duration,is_transaction,true)'
46+
| 'failure_rate_if(is_transaction,true)'
4947
| 'count_unique(user)'
50-
| 'sum(span.duration)'
48+
| 'sum_if(span.duration,is_transaction,true)'
5149
| 'performance_score(measurements.score.total)'
5250
>;
5351

@@ -63,22 +61,22 @@ const COLUMN_ORDER: Column[] = [
6361
width: COL_WIDTH_UNDEFINED,
6462
},
6563
{
66-
key: 'epm()',
64+
key: 'tpm()',
6765
name: t('TPM'),
6866
width: COL_WIDTH_UNDEFINED,
6967
},
7068
{
71-
key: `p50(span.duration)`,
69+
key: `p50_if(span.duration,is_transaction,true)`,
7270
name: t('p50()'),
7371
width: COL_WIDTH_UNDEFINED,
7472
},
7573
{
76-
key: 'p95(span.duration)',
74+
key: `p95_if(span.duration,is_transaction,true)`,
7775
name: t('p95()'),
7876
width: COL_WIDTH_UNDEFINED,
7977
},
8078
{
81-
key: 'failure_rate()',
79+
key: 'failure_rate_if(is_transaction,true)',
8280
name: t('Failure Rate'),
8381
width: COL_WIDTH_UNDEFINED,
8482
},
@@ -88,7 +86,7 @@ const COLUMN_ORDER: Column[] = [
8886
width: COL_WIDTH_UNDEFINED,
8987
},
9088
{
91-
key: 'time_spent_percentage(span.duration)',
89+
key: 'sum_if(span.duration,is_transaction,true)',
9290
name: DataTitles.timeSpent,
9391
width: COL_WIDTH_UNDEFINED,
9492
},
@@ -103,12 +101,12 @@ const SORTABLE_FIELDS = [
103101
'is_starred_transaction',
104102
'transaction',
105103
'project',
106-
'epm()',
107-
'p50(span.duration)',
108-
'p95(span.duration)',
109-
'failure_rate()',
104+
'tpm()',
105+
'p50_if(span.duration,is_transaction,true)',
106+
'p95_if(span.duration,is_transaction,true)',
107+
'failure_rate_if(is_transaction,true)',
110108
'count_unique(user)',
111-
'time_spent_percentage(span.duration)',
109+
'sum_if(span.duration,is_transaction,true)',
112110
'performance_score(measurements.score.total)',
113111
] as const;
114112

static/app/views/insights/pages/frontend/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ export const FRONTEND_PLATFORMS: PlatformKey[] = frontend.filter(
4545
);
4646

4747
export const DEFAULT_SORT: ValidSort = {
48-
field: 'time_spent_percentage(span.duration)' satisfies EAPSpanProperty,
48+
field: 'sum_if(span.duration,is_transaction,true)' satisfies EAPSpanProperty,
4949
kind: 'desc',
5050
};

static/app/views/insights/types.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,27 @@ export type Aggregate =
161161
| (typeof COUNTER_AGGREGATES)[number]
162162
| (typeof DISTRIBUTION_AGGREGATES)[number];
163163

164+
type CounterConditionalAggregate =
165+
| `sum_if`
166+
| `avg_if`
167+
| `p50_if`
168+
| `p75_if`
169+
| `p90_if`
170+
| `p95_if`
171+
| `p99_if`;
172+
164173
type ConditionalAggregate =
165174
| `avg_if`
166175
| `count_op`
176+
| `failure_rate_if`
167177
| 'trace_status_rate'
168178
| 'time_spent_percentage';
169179

170180
export const SPAN_FUNCTIONS = [
171181
'sps',
172182
'spm',
173183
'epm',
184+
'tpm',
174185
'count',
175186
'time_spent_percentage',
176187
'http_response_rate',
@@ -261,6 +272,8 @@ export type EAPSpanResponse = {
261272
[SpanMetricsField.USER_GEO_SUBREGION]: SubregionCode;
262273
} & {
263274
[Property in SpanFields as `count_unique(${Property})`]: number;
275+
} & {
276+
[Property in SpanNumberFields as `${CounterConditionalAggregate}(${Property},${string},${string})`]: number;
264277
};
265278

266279
export type EAPSpanProperty = keyof EAPSpanResponse;
@@ -443,6 +456,7 @@ export type SpanIndexedFieldTypes = SpanIndexedResponse;
443456
export enum SpanFunction {
444457
SPS = 'sps',
445458
EPM = 'epm',
459+
TPM = 'tpm',
446460
TIME_SPENT_PERCENTAGE = 'time_spent_percentage',
447461
HTTP_RESPONSE_COUNT = 'http_response_count',
448462
HTTP_RESPONSE_RATE = 'http_response_rate',

0 commit comments

Comments
 (0)