Skip to content

Commit a6139cd

Browse files
wmakandrewshie-sentry
authored andcommitted
fix(events): Handle count_if(span.status) (#96692)
- I'm updating count_if to match discover's api in #96689, so for consistency adding the operator to all our existing -if combinator usage before deprecating it
1 parent ec8946b commit a6139cd

32 files changed

+187
-187
lines changed

static/app/views/dashboards/widgetBuilder/utils.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ describe('WidgetBuilder utils', function () {
3131
});
3232

3333
it('does not split aggregates with inner commas', function () {
34-
const testFieldsString = 'p75(),count_if(transaction.duration,equal,200),p95()';
34+
const testFieldsString = 'p75(),count_if(transaction.duration,equals,200),p95()';
3535
const actual = getFields(testFieldsString);
3636
expect(actual).toEqual([
3737
'p75()',
38-
'count_if(transaction.duration,equal,200)',
38+
'count_if(transaction.duration,equals,200)',
3939
'p95()',
4040
]);
4141
});

static/app/views/insights/agentMonitoring/components/modelsTable.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const EMPTY_ARRAY: never[] = [];
6666
const defaultColumnOrder: Array<GridColumnOrder<string>> = [
6767
{key: 'model', name: t('Model'), width: COL_WIDTH_UNDEFINED},
6868
{key: 'count()', name: t('Requests'), width: 120},
69-
{key: 'count_if(span.status,unknown)', name: t('Errors'), width: 120},
69+
{key: 'count_if(span.status,equals,unknown)', name: t('Errors'), width: 120},
7070
{key: 'avg(span.duration)', name: t('Avg'), width: 100},
7171
{key: 'p95(span.duration)', name: t('P95'), width: 100},
7272
{key: AI_COST_ATTRIBUTE_SUM, name: t('Cost'), width: 100},
@@ -81,7 +81,7 @@ const rightAlignColumns = new Set([
8181
AI_OUTPUT_TOKENS_REASONING_ATTRIBUTE_SUM,
8282
AI_INPUT_TOKENS_CACHED_ATTRIBUTE_SUM,
8383
AI_COST_ATTRIBUTE_SUM,
84-
'count_if(span.status,unknown)',
84+
'count_if(span.status,equals,unknown)',
8585
'avg(span.duration)',
8686
'p95(span.duration)',
8787
]);
@@ -123,7 +123,7 @@ export function ModelsTable() {
123123
'count()',
124124
'avg(span.duration)',
125125
'p95(span.duration)',
126-
'count_if(span.status,unknown)', // spans with status unknown are errors
126+
'count_if(span.status,equals,unknown)', // spans with status unknown are errors
127127
],
128128
sorts: [{field: sortField, kind: sortOrder}],
129129
search: fullQuery,
@@ -145,7 +145,7 @@ export function ModelsTable() {
145145
avg: span['avg(span.duration)'] ?? 0,
146146
p95: span['p95(span.duration)'] ?? 0,
147147
cost: Number(span[AI_COST_ATTRIBUTE_SUM]),
148-
errors: span['count_if(span.status,unknown)'] ?? 0,
148+
errors: span['count_if(span.status,equals,unknown)'] ?? 0,
149149
inputTokens: Number(span[AI_INPUT_TOKENS_ATTRIBUTE_SUM]),
150150
inputCachedTokens: Number(span[AI_INPUT_TOKENS_CACHED_ATTRIBUTE_SUM]),
151151
outputTokens: Number(span[AI_OUTPUT_TOKENS_ATTRIBUTE_SUM]),
@@ -269,7 +269,7 @@ const BodyCell = memo(function BodyCell({
269269
return <DurationCell milliseconds={dataRow.p95} />;
270270
case AI_COST_ATTRIBUTE_SUM:
271271
return <TextAlignRight>{formatLLMCosts(dataRow.cost)}</TextAlignRight>;
272-
case 'count_if(span.status,unknown)':
272+
case 'count_if(span.status,equals,unknown)':
273273
return (
274274
<ErrorCell
275275
value={dataRow.errors}

static/app/views/insights/agentMonitoring/components/toolsTable.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ const EMPTY_ARRAY: never[] = [];
5151
const defaultColumnOrder: Array<GridColumnOrder<string>> = [
5252
{key: 'tool', name: t('Tool Name'), width: COL_WIDTH_UNDEFINED},
5353
{key: 'count()', name: t('Requests'), width: 120},
54-
{key: 'count_if(span.status,unknown)', name: t('Errors'), width: 120},
54+
{key: 'count_if(span.status,equals,unknown)', name: t('Errors'), width: 120},
5555
{key: 'avg(span.duration)', name: t('Avg'), width: 100},
5656
{key: 'p95(span.duration)', name: t('P95'), width: 100},
5757
];
5858

5959
const rightAlignColumns = new Set([
6060
'count()',
61-
'count_if(span.status,unknown)',
61+
'count_if(span.status,equals,unknown)',
6262
'avg(span.duration)',
6363
'p95(span.duration)',
6464
]);
@@ -97,7 +97,7 @@ export function ToolsTable() {
9797
'avg(span.duration)',
9898
'p95(span.duration)',
9999
'failure_rate()',
100-
'count_if(span.status,unknown)', // spans with status unknown are errors
100+
'count_if(span.status,equals,unknown)', // spans with status unknown are errors
101101
],
102102
sorts: [{field: sortField, kind: sortOrder}],
103103
search: fullQuery,
@@ -118,7 +118,7 @@ export function ToolsTable() {
118118
requests: Number(span['count()']),
119119
avg: Number(span['avg(span.duration)']),
120120
p95: Number(span['p95(span.duration)']),
121-
errors: Number(span['count_if(span.status,unknown)']),
121+
errors: Number(span['count_if(span.status,equals,unknown)']),
122122
}));
123123
}, [toolsRequest.data]);
124124

@@ -218,7 +218,7 @@ const BodyCell = memo(function BodyCell({
218218
return <DurationCell milliseconds={dataRow.avg} />;
219219
case 'p95(span.duration)':
220220
return <DurationCell milliseconds={dataRow.p95} />;
221-
case 'count_if(span.status,unknown)':
221+
case 'count_if(span.status,equals,unknown)':
222222
return (
223223
<ErrorCell
224224
value={dataRow.errors}

static/app/views/insights/agentMonitoring/components/tracesTable.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ const rightAlignColumns = new Set([
8383
]);
8484

8585
// FIXME: This is potentially not correct, we need to find a way for it to work with the new filter
86-
const GENERATION_COUNTS = AI_GENERATION_OPS.map(op => `count_if(span.op,${op})` as const);
86+
const GENERATION_COUNTS = AI_GENERATION_OPS.map(
87+
op => `count_if(span.op,equals,${op})` as const
88+
);
8789

8890
const AI_AGENT_SUB_OPS = [...AI_GENERATION_OPS, ...AI_TOOL_CALL_OPS].map(
89-
op => `count_if(span.op,${op})` as const
91+
op => `count_if(span.op,equals,${op})` as const
9092
);
9193

9294
export function TracesTable() {
@@ -115,7 +117,7 @@ export function TracesTable() {
115117
fields: [
116118
'trace',
117119
...GENERATION_COUNTS,
118-
'count_if(span.op,gen_ai.execute_tool)',
120+
'count_if(span.op,equals,gen_ai.execute_tool)',
119121
AI_TOKEN_USAGE_ATTRIBUTE_SUM,
120122
AI_COST_ATTRIBUTE_SUM,
121123
],
@@ -161,7 +163,7 @@ export function TracesTable() {
161163
(sum, key) => sum + (span[key] ?? 0),
162164
0
163165
),
164-
toolCalls: span['count_if(span.op,gen_ai.execute_tool)'] ?? 0,
166+
toolCalls: span['count_if(span.op,equals,gen_ai.execute_tool)'] ?? 0,
165167
totalTokens: Number(span[AI_TOKEN_USAGE_ATTRIBUTE_SUM] ?? 0),
166168
totalCost: Number(span[AI_COST_ATTRIBUTE_SUM] ?? 0),
167169
totalErrors: errors[span.trace] ?? 0,

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const SORTABLE_FIELDS = new Set([
6565
SpanFields.MESSAGING_MESSAGE_DESTINATION_NAME,
6666
'count_op(queue.publish)',
6767
'count_op(queue.process)',
68-
'avg_if(span.duration,span.op,queue.process)',
68+
'avg_if(span.duration,span.op,equals,queue.process)',
6969
'avg(messaging.message.receive.latency)',
7070
'time_spent_percentage(span.duration)',
7171
'transaction',
@@ -78,10 +78,10 @@ const SORTABLE_FIELDS = new Set([
7878
'failure_rate()',
7979
'performance_score(measurements.score.total)',
8080
'count_unique(user)',
81-
'p50_if(span.duration,is_transaction,true)',
82-
'p95_if(span.duration,is_transaction,true)',
83-
'failure_rate_if(is_transaction,true)',
84-
'sum_if(span.duration,is_transaction,true)',
81+
'p50_if(span.duration,is_transaction,equals,true)',
82+
'p95_if(span.duration,is_transaction,equals,true)',
83+
'failure_rate_if(is_transaction,equals,true)',
84+
'sum_if(span.duration,is_transaction,equals,true)',
8585
'p75(measurements.frames_slow_rate)',
8686
'p75(measurements.frames_frozen_rate)',
8787
'trace_status_rate(ok)',

static/app/views/insights/mobile/appStarts/components/tables/screensTable.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ describe('AppStartScreens', () => {
7676
{
7777
id: '1',
7878
transaction: 'Screen 1',
79-
'avg_if(measurements.app_start_cold,release,com.example.vu.android@2.10.5)': 100,
80-
'avg_if(measurements.app_start_cold,release,com.example.vu.android@2.10.3+42)': 200,
79+
'avg_if(measurements.app_start_cold,release,equals,com.example.vu.android@2.10.5)': 100,
80+
'avg_if(measurements.app_start_cold,release,equals,com.example.vu.android@2.10.3+42)': 200,
8181
'avg_compare(measurements.app_start_cold,release,com.example.vu.android@2.10.5,com.example.vu.android@2.10.3+42)': 50,
8282
app_start_breakdown: 'breakdown',
8383
'count_starts(measurements.app_start_cold)': 10,

static/app/views/insights/mobile/appStarts/components/tables/screensTable.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ export function AppStartScreens({data, eventView, isLoading, pageLinks}: Props)
3939

4040
const columnNameMap = {
4141
transaction: t('Screen'),
42-
[`avg_if(measurements.app_start_cold,release,${primaryRelease})`]: t(
42+
[`avg_if(measurements.app_start_cold,release,equals,${primaryRelease})`]: t(
4343
'Avg Cold Start (%s)',
4444
PRIMARY_RELEASE_ALIAS
4545
),
46-
[`avg_if(measurements.app_start_cold,release,${secondaryRelease})`]: t(
46+
[`avg_if(measurements.app_start_cold,release,equals,${secondaryRelease})`]: t(
4747
'Avg Cold Start (%s)',
4848
SECONDARY_RELEASE_ALIAS
4949
),
50-
[`avg_if(measurements.app_start_warm,release,${primaryRelease})`]: t(
50+
[`avg_if(measurements.app_start_warm,release,equals,${primaryRelease})`]: t(
5151
'Avg Warm Start (%s)',
5252
PRIMARY_RELEASE_ALIAS
5353
),
54-
[`avg_if(measurements.app_start_warm,release,${secondaryRelease})`]: t(
54+
[`avg_if(measurements.app_start_warm,release,equals,${secondaryRelease})`]: t(
5555
'Avg Warm Start (%s)',
5656
SECONDARY_RELEASE_ALIAS
5757
),
@@ -135,8 +135,8 @@ export function AppStartScreens({data, eventView, isLoading, pageLinks}: Props)
135135
pageLinks={pageLinks}
136136
columnOrder={[
137137
'transaction',
138-
`avg_if(measurements.app_start_${startType},release,${primaryRelease})`,
139-
`avg_if(measurements.app_start_${startType},release,${secondaryRelease})`,
138+
`avg_if(measurements.app_start_${startType},release,equals,${primaryRelease})`,
139+
`avg_if(measurements.app_start_${startType},release,equals,${secondaryRelease})`,
140140
`avg_compare(measurements.app_start_${startType},release,${primaryRelease},${secondaryRelease})`,
141141
'app_start_breakdown',
142142
`count_starts(measurements.app_start_${startType})`,

static/app/views/insights/mobile/appStarts/components/tables/spanOperationTable.spec.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ describe('SpanOpSelector', function () {
5454
'span.op': 'string',
5555
'span.description': 'string',
5656
'span.group': 'string',
57-
'avg_if(span.self_time,release,release1)': 'duration',
57+
'avg_if(span.self_time,release,equals,release1)': 'duration',
5858
'avg_compare(span.self_time,release,release1,release2)': 'percent_change',
5959
'count()': 'integer',
60-
'avg_if(span.self_time,release,release2)': 'duration',
60+
'avg_if(span.self_time,release,equals,release2)': 'duration',
6161
'sum(span.self_time)': 'duration',
6262
},
6363
},
@@ -67,10 +67,10 @@ describe('SpanOpSelector', function () {
6767
'span.op': 'app.start.warm',
6868
'span.description': 'Application Init',
6969
'span.group': '7f4be68f08c0455f',
70-
'avg_if(span.self_time,release,release1)': 22.549867,
70+
'avg_if(span.self_time,release,equals,release1)': 22.549867,
7171
'avg_compare(span.self_time,release,release1,release2)': 0.5,
7272
'count()': 14,
73-
'avg_if(span.self_time,release,release2)': 12504.931908384617,
73+
'avg_if(span.self_time,release,equals,release2)': 12504.931908384617,
7474
'sum(span.self_time)': 162586.66467600001,
7575
},
7676
],
@@ -115,10 +115,10 @@ describe('SpanOpSelector', function () {
115115
'span.op': 'string',
116116
'span.description': 'string',
117117
'span.group': 'string',
118-
'avg_if(span.self_time,release,release1)': 'duration',
118+
'avg_if(span.self_time,release,equals,release1)': 'duration',
119119
'avg_compare(span.self_time,release,release1,release2)': 'percent_change',
120120
'count()': 'integer',
121-
'avg_if(span.self_time,release,release2)': 'duration',
121+
'avg_if(span.self_time,release,equals,release2)': 'duration',
122122
'sum(span.self_time)': 'duration',
123123
},
124124
},
@@ -132,8 +132,8 @@ describe('SpanOpSelector', function () {
132132
'sum(span.self_time)': 162586.66467600001,
133133

134134
// simulate a scenario where a span was added in release 2
135-
'avg_if(span.self_time,release,release1)': 0,
136-
'avg_if(span.self_time,release,release2)': 12504.931908384617,
135+
'avg_if(span.self_time,release,equals,release1)': 0,
136+
'avg_if(span.self_time,release,equals,release2)': 12504.931908384617,
137137
'avg_compare(span.self_time,release,release1,release2)': null,
138138
},
139139
],

static/app/views/insights/mobile/appStarts/components/tables/spanOperationTable.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ export function SpanOperationTable({
117117
SPAN_OP,
118118
SPAN_GROUP,
119119
SPAN_DESCRIPTION,
120-
`avg_if(${SPAN_SELF_TIME},release,${primaryRelease})`,
121-
`avg_if(${SPAN_SELF_TIME},release,${secondaryRelease})`,
120+
`avg_if(${SPAN_SELF_TIME},release,equals,${primaryRelease})`,
121+
`avg_if(${SPAN_SELF_TIME},release,equals,${secondaryRelease})`,
122122
`avg_compare(${SPAN_SELF_TIME},release,${primaryRelease},${secondaryRelease})`,
123123
`sum(${SPAN_SELF_TIME})`,
124124
],
@@ -131,11 +131,11 @@ export function SpanOperationTable({
131131
const columnNameMap = {
132132
[SPAN_OP]: t('Operation'),
133133
[SPAN_DESCRIPTION]: t('Span Description'),
134-
[`avg_if(${SPAN_SELF_TIME},release,${primaryRelease})`]: t(
134+
[`avg_if(${SPAN_SELF_TIME},release,equals,${primaryRelease})`]: t(
135135
'Avg Duration (%s)',
136136
PRIMARY_RELEASE_ALIAS
137137
),
138-
[`avg_if(${SPAN_SELF_TIME},release,${secondaryRelease})`]: t(
138+
[`avg_if(${SPAN_SELF_TIME},release,equals,${secondaryRelease})`]: t(
139139
'Avg Duration (%s)',
140140
SECONDARY_RELEASE_ALIAS
141141
),
@@ -249,8 +249,8 @@ export function SpanOperationTable({
249249
columnOrder={[
250250
String(SPAN_OP),
251251
String(SPAN_DESCRIPTION),
252-
`avg_if(${SPAN_SELF_TIME},release,${primaryRelease})`,
253-
`avg_if(${SPAN_SELF_TIME},release,${secondaryRelease})`,
252+
`avg_if(${SPAN_SELF_TIME},release,equals,${primaryRelease})`,
253+
`avg_if(${SPAN_SELF_TIME},release,equals,${secondaryRelease})`,
254254
`avg_compare(${SPAN_SELF_TIME},release,${primaryRelease},${secondaryRelease})`,
255255
].map(col => {
256256
return {key: col, name: columnNameMap[col] ?? col, width: COL_WIDTH_UNDEFINED};

static/app/views/insights/mobile/appStarts/views/screenSummaryPage.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ describe('Screen Summary', function () {
101101
data: [
102102
{
103103
'span.op': 'app.start.cold',
104-
'avg_if(span.duration,release,com.example.vu.android@2.10.5)': 1000,
105-
'avg_if(span.duration,release,com.example.vu.android@2.10.3+42)': 2000,
104+
'avg_if(span.duration,release,equals,com.example.vu.android@2.10.5)': 1000,
105+
'avg_if(span.duration,release,equals,com.example.vu.android@2.10.3+42)': 2000,
106106
'avg_compare(span.duration,release,com.example.vu.android@2.10.5,com.example.vu.android@2.10.3+42)':
107107
-0.5,
108-
'count_if(release,com.example.vu.android@2.10.5)': 20,
109-
'count_if(release,com.example.vu.android@2.10.3+42)': 10,
108+
'count_if(release,equals,com.example.vu.android@2.10.5)': 20,
109+
'count_if(release,equals,com.example.vu.android@2.10.3+42)': 10,
110110
},
111111
],
112112
},

0 commit comments

Comments
 (0)