Skip to content

fix(events): Handle count_if(span.status) #96692

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

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions static/app/views/dashboards/widgetBuilder/utils.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ describe('WidgetBuilder utils', function () {
});

it('does not split aggregates with inner commas', function () {
const testFieldsString = 'p75(),count_if(transaction.duration,equal,200),p95()';
const testFieldsString = 'p75(),count_if(transaction.duration,equals,200),p95()';
const actual = getFields(testFieldsString);
expect(actual).toEqual([
'p75()',
'count_if(transaction.duration,equal,200)',
'count_if(transaction.duration,equals,200)',
'p95()',
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const EMPTY_ARRAY: never[] = [];
const defaultColumnOrder: Array<GridColumnOrder<string>> = [
{key: 'model', name: t('Model'), width: COL_WIDTH_UNDEFINED},
{key: 'count()', name: t('Requests'), width: 120},
{key: 'count_if(span.status,unknown)', name: t('Errors'), width: 120},
{key: 'count_if(span.status,equals,unknown)', name: t('Errors'), width: 120},
{key: 'avg(span.duration)', name: t('Avg'), width: 100},
{key: 'p95(span.duration)', name: t('P95'), width: 100},
{key: AI_COST_ATTRIBUTE_SUM, name: t('Cost'), width: 100},
Expand All @@ -81,7 +81,7 @@ const rightAlignColumns = new Set([
AI_OUTPUT_TOKENS_REASONING_ATTRIBUTE_SUM,
AI_INPUT_TOKENS_CACHED_ATTRIBUTE_SUM,
AI_COST_ATTRIBUTE_SUM,
'count_if(span.status,unknown)',
'count_if(span.status,equals,unknown)',
'avg(span.duration)',
'p95(span.duration)',
]);
Expand Down Expand Up @@ -123,7 +123,7 @@ export function ModelsTable() {
'count()',
'avg(span.duration)',
'p95(span.duration)',
'count_if(span.status,unknown)', // spans with status unknown are errors
'count_if(span.status,equals,unknown)', // spans with status unknown are errors
],
sorts: [{field: sortField, kind: sortOrder}],
search: fullQuery,
Expand All @@ -145,7 +145,7 @@ export function ModelsTable() {
avg: span['avg(span.duration)'] ?? 0,
p95: span['p95(span.duration)'] ?? 0,
cost: Number(span[AI_COST_ATTRIBUTE_SUM]),
errors: span['count_if(span.status,unknown)'] ?? 0,
errors: span['count_if(span.status,equals,unknown)'] ?? 0,
inputTokens: Number(span[AI_INPUT_TOKENS_ATTRIBUTE_SUM]),
inputCachedTokens: Number(span[AI_INPUT_TOKENS_CACHED_ATTRIBUTE_SUM]),
outputTokens: Number(span[AI_OUTPUT_TOKENS_ATTRIBUTE_SUM]),
Expand Down Expand Up @@ -269,7 +269,7 @@ const BodyCell = memo(function BodyCell({
return <DurationCell milliseconds={dataRow.p95} />;
case AI_COST_ATTRIBUTE_SUM:
return <TextAlignRight>{formatLLMCosts(dataRow.cost)}</TextAlignRight>;
case 'count_if(span.status,unknown)':
case 'count_if(span.status,equals,unknown)':
return (
<ErrorCell
value={dataRow.errors}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ const EMPTY_ARRAY: never[] = [];
const defaultColumnOrder: Array<GridColumnOrder<string>> = [
{key: 'tool', name: t('Tool Name'), width: COL_WIDTH_UNDEFINED},
{key: 'count()', name: t('Requests'), width: 120},
{key: 'count_if(span.status,unknown)', name: t('Errors'), width: 120},
{key: 'count_if(span.status,equals,unknown)', name: t('Errors'), width: 120},
{key: 'avg(span.duration)', name: t('Avg'), width: 100},
{key: 'p95(span.duration)', name: t('P95'), width: 100},
];

const rightAlignColumns = new Set([
'count()',
'count_if(span.status,unknown)',
'count_if(span.status,equals,unknown)',
'avg(span.duration)',
'p95(span.duration)',
]);
Expand Down Expand Up @@ -97,7 +97,7 @@ export function ToolsTable() {
'avg(span.duration)',
'p95(span.duration)',
'failure_rate()',
'count_if(span.status,unknown)', // spans with status unknown are errors
'count_if(span.status,equals,unknown)', // spans with status unknown are errors
],
sorts: [{field: sortField, kind: sortOrder}],
search: fullQuery,
Expand All @@ -118,7 +118,7 @@ export function ToolsTable() {
requests: Number(span['count()']),
avg: Number(span['avg(span.duration)']),
p95: Number(span['p95(span.duration)']),
errors: Number(span['count_if(span.status,unknown)']),
errors: Number(span['count_if(span.status,equals,unknown)']),
}));
}, [toolsRequest.data]);

Expand Down Expand Up @@ -218,7 +218,7 @@ const BodyCell = memo(function BodyCell({
return <DurationCell milliseconds={dataRow.avg} />;
case 'p95(span.duration)':
return <DurationCell milliseconds={dataRow.p95} />;
case 'count_if(span.status,unknown)':
case 'count_if(span.status,equals,unknown)':
return (
<ErrorCell
value={dataRow.errors}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ const rightAlignColumns = new Set([
]);

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

const AI_AGENT_SUB_OPS = [...AI_GENERATION_OPS, ...AI_TOOL_CALL_OPS].map(
op => `count_if(span.op,${op})` as const
op => `count_if(span.op,equals,${op})` as const
);

export function TracesTable() {
Expand Down Expand Up @@ -115,7 +117,7 @@ export function TracesTable() {
fields: [
'trace',
...GENERATION_COUNTS,
'count_if(span.op,gen_ai.execute_tool)',
'count_if(span.op,equals,gen_ai.execute_tool)',
AI_TOKEN_USAGE_ATTRIBUTE_SUM,
AI_COST_ATTRIBUTE_SUM,
],
Expand Down Expand Up @@ -161,7 +163,7 @@ export function TracesTable() {
(sum, key) => sum + (span[key] ?? 0),
0
),
toolCalls: span['count_if(span.op,gen_ai.execute_tool)'] ?? 0,
toolCalls: span['count_if(span.op,equals,gen_ai.execute_tool)'] ?? 0,
totalTokens: Number(span[AI_TOKEN_USAGE_ATTRIBUTE_SUM] ?? 0),
totalCost: Number(span[AI_COST_ATTRIBUTE_SUM] ?? 0),
totalErrors: errors[span.trace] ?? 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const SORTABLE_FIELDS = new Set([
SpanFields.MESSAGING_MESSAGE_DESTINATION_NAME,
'count_op(queue.publish)',
'count_op(queue.process)',
'avg_if(span.duration,span.op,queue.process)',
'avg_if(span.duration,span.op,equals,queue.process)',
'avg(messaging.message.receive.latency)',
'time_spent_percentage(span.duration)',
'transaction',
Expand All @@ -78,10 +78,10 @@ const SORTABLE_FIELDS = new Set([
'failure_rate()',
'performance_score(measurements.score.total)',
'count_unique(user)',
'p50_if(span.duration,is_transaction,true)',
'p95_if(span.duration,is_transaction,true)',
'failure_rate_if(is_transaction,true)',
'sum_if(span.duration,is_transaction,true)',
'p50_if(span.duration,is_transaction,equals,true)',
'p95_if(span.duration,is_transaction,equals,true)',
'failure_rate_if(is_transaction,equals,true)',
'sum_if(span.duration,is_transaction,equals,true)',
'p75(measurements.frames_slow_rate)',
'p75(measurements.frames_frozen_rate)',
'trace_status_rate(ok)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ describe('AppStartScreens', () => {
{
id: '1',
transaction: 'Screen 1',
'avg_if(measurements.app_start_cold,release,com.example.vu.android@2.10.5)': 100,
'avg_if(measurements.app_start_cold,release,com.example.vu.android@2.10.3+42)': 200,
'avg_if(measurements.app_start_cold,release,equals,com.example.vu.android@2.10.5)': 100,
'avg_if(measurements.app_start_cold,release,equals,com.example.vu.android@2.10.3+42)': 200,
'avg_compare(measurements.app_start_cold,release,com.example.vu.android@2.10.5,com.example.vu.android@2.10.3+42)': 50,
app_start_breakdown: 'breakdown',
'count_starts(measurements.app_start_cold)': 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ export function AppStartScreens({data, eventView, isLoading, pageLinks}: Props)

const columnNameMap = {
transaction: t('Screen'),
[`avg_if(measurements.app_start_cold,release,${primaryRelease})`]: t(
[`avg_if(measurements.app_start_cold,release,equals,${primaryRelease})`]: t(
'Avg Cold Start (%s)',
PRIMARY_RELEASE_ALIAS
),
[`avg_if(measurements.app_start_cold,release,${secondaryRelease})`]: t(
[`avg_if(measurements.app_start_cold,release,equals,${secondaryRelease})`]: t(
'Avg Cold Start (%s)',
SECONDARY_RELEASE_ALIAS
),
[`avg_if(measurements.app_start_warm,release,${primaryRelease})`]: t(
[`avg_if(measurements.app_start_warm,release,equals,${primaryRelease})`]: t(
'Avg Warm Start (%s)',
PRIMARY_RELEASE_ALIAS
),
[`avg_if(measurements.app_start_warm,release,${secondaryRelease})`]: t(
[`avg_if(measurements.app_start_warm,release,equals,${secondaryRelease})`]: t(
'Avg Warm Start (%s)',
SECONDARY_RELEASE_ALIAS
),
Expand Down Expand Up @@ -135,8 +135,8 @@ export function AppStartScreens({data, eventView, isLoading, pageLinks}: Props)
pageLinks={pageLinks}
columnOrder={[
'transaction',
`avg_if(measurements.app_start_${startType},release,${primaryRelease})`,
`avg_if(measurements.app_start_${startType},release,${secondaryRelease})`,
`avg_if(measurements.app_start_${startType},release,equals,${primaryRelease})`,
`avg_if(measurements.app_start_${startType},release,equals,${secondaryRelease})`,
`avg_compare(measurements.app_start_${startType},release,${primaryRelease},${secondaryRelease})`,
'app_start_breakdown',
`count_starts(measurements.app_start_${startType})`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ describe('SpanOpSelector', function () {
'span.op': 'string',
'span.description': 'string',
'span.group': 'string',
'avg_if(span.self_time,release,release1)': 'duration',
'avg_if(span.self_time,release,equals,release1)': 'duration',
'avg_compare(span.self_time,release,release1,release2)': 'percent_change',
'count()': 'integer',
'avg_if(span.self_time,release,release2)': 'duration',
'avg_if(span.self_time,release,equals,release2)': 'duration',
'sum(span.self_time)': 'duration',
},
},
Expand All @@ -67,10 +67,10 @@ describe('SpanOpSelector', function () {
'span.op': 'app.start.warm',
'span.description': 'Application Init',
'span.group': '7f4be68f08c0455f',
'avg_if(span.self_time,release,release1)': 22.549867,
'avg_if(span.self_time,release,equals,release1)': 22.549867,
'avg_compare(span.self_time,release,release1,release2)': 0.5,
'count()': 14,
'avg_if(span.self_time,release,release2)': 12504.931908384617,
'avg_if(span.self_time,release,equals,release2)': 12504.931908384617,
'sum(span.self_time)': 162586.66467600001,
},
],
Expand Down Expand Up @@ -115,10 +115,10 @@ describe('SpanOpSelector', function () {
'span.op': 'string',
'span.description': 'string',
'span.group': 'string',
'avg_if(span.self_time,release,release1)': 'duration',
'avg_if(span.self_time,release,equals,release1)': 'duration',
'avg_compare(span.self_time,release,release1,release2)': 'percent_change',
'count()': 'integer',
'avg_if(span.self_time,release,release2)': 'duration',
'avg_if(span.self_time,release,equals,release2)': 'duration',
'sum(span.self_time)': 'duration',
},
},
Expand All @@ -132,8 +132,8 @@ describe('SpanOpSelector', function () {
'sum(span.self_time)': 162586.66467600001,

// simulate a scenario where a span was added in release 2
'avg_if(span.self_time,release,release1)': 0,
'avg_if(span.self_time,release,release2)': 12504.931908384617,
'avg_if(span.self_time,release,equals,release1)': 0,
'avg_if(span.self_time,release,equals,release2)': 12504.931908384617,
'avg_compare(span.self_time,release,release1,release2)': null,
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export function SpanOperationTable({
SPAN_OP,
SPAN_GROUP,
SPAN_DESCRIPTION,
`avg_if(${SPAN_SELF_TIME},release,${primaryRelease})`,
`avg_if(${SPAN_SELF_TIME},release,${secondaryRelease})`,
`avg_if(${SPAN_SELF_TIME},release,equals,${primaryRelease})`,
`avg_if(${SPAN_SELF_TIME},release,equals,${secondaryRelease})`,
`avg_compare(${SPAN_SELF_TIME},release,${primaryRelease},${secondaryRelease})`,
`sum(${SPAN_SELF_TIME})`,
],
Expand All @@ -131,11 +131,11 @@ export function SpanOperationTable({
const columnNameMap = {
[SPAN_OP]: t('Operation'),
[SPAN_DESCRIPTION]: t('Span Description'),
[`avg_if(${SPAN_SELF_TIME},release,${primaryRelease})`]: t(
[`avg_if(${SPAN_SELF_TIME},release,equals,${primaryRelease})`]: t(
'Avg Duration (%s)',
PRIMARY_RELEASE_ALIAS
),
[`avg_if(${SPAN_SELF_TIME},release,${secondaryRelease})`]: t(
[`avg_if(${SPAN_SELF_TIME},release,equals,${secondaryRelease})`]: t(
'Avg Duration (%s)',
SECONDARY_RELEASE_ALIAS
),
Expand Down Expand Up @@ -249,8 +249,8 @@ export function SpanOperationTable({
columnOrder={[
String(SPAN_OP),
String(SPAN_DESCRIPTION),
`avg_if(${SPAN_SELF_TIME},release,${primaryRelease})`,
`avg_if(${SPAN_SELF_TIME},release,${secondaryRelease})`,
`avg_if(${SPAN_SELF_TIME},release,equals,${primaryRelease})`,
`avg_if(${SPAN_SELF_TIME},release,equals,${secondaryRelease})`,
`avg_compare(${SPAN_SELF_TIME},release,${primaryRelease},${secondaryRelease})`,
].map(col => {
return {key: col, name: columnNameMap[col] ?? col, width: COL_WIDTH_UNDEFINED};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ describe('Screen Summary', function () {
data: [
{
'span.op': 'app.start.cold',
'avg_if(span.duration,release,com.example.vu.android@2.10.5)': 1000,
'avg_if(span.duration,release,com.example.vu.android@2.10.3+42)': 2000,
'avg_if(span.duration,release,equals,com.example.vu.android@2.10.5)': 1000,
'avg_if(span.duration,release,equals,com.example.vu.android@2.10.3+42)': 2000,
'avg_compare(span.duration,release,com.example.vu.android@2.10.5,com.example.vu.android@2.10.3+42)':
-0.5,
'count_if(release,com.example.vu.android@2.10.5)': 20,
'count_if(release,com.example.vu.android@2.10.3+42)': 10,
'count_if(release,equals,com.example.vu.android@2.10.5)': 20,
'count_if(release,equals,com.example.vu.android@2.10.3+42)': 10,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ export function ScreenSummaryContentPage() {
')',
]}
fields={[
`avg_if(span.duration,release,${primaryRelease})`,
`avg_if(span.duration,release,${secondaryRelease})`,
`avg_if(span.duration,release,equals,${primaryRelease})`,
`avg_if(span.duration,release,equals,${secondaryRelease})`,
`avg_compare(span.duration,release,${primaryRelease},${secondaryRelease})`,
`count_if(release,${primaryRelease})`,
`count_if(release,${secondaryRelease})`,
`count_if(release,equals,${primaryRelease})`,
`count_if(release,equals,${secondaryRelease})`,
]}
blocks={[
{
Expand All @@ -153,7 +153,7 @@ export function ScreenSummaryContentPage() {
appStartType === COLD_START_TYPE
? t('Avg Cold Start (%s)', PRIMARY_RELEASE_ALIAS)
: t('Avg Warm Start (%s)', PRIMARY_RELEASE_ALIAS),
dataKey: `avg_if(span.duration,release,${primaryRelease})`,
dataKey: `avg_if(span.duration,release,equals,${primaryRelease})`,
},
{
unit: DurationUnit.MILLISECOND,
Expand All @@ -162,7 +162,7 @@ export function ScreenSummaryContentPage() {
appStartType === COLD_START_TYPE
? t('Avg Cold Start (%s)', SECONDARY_RELEASE_ALIAS)
: t('Avg Warm Start (%s)', SECONDARY_RELEASE_ALIAS),
dataKey: `avg_if(span.duration,release,${secondaryRelease})`,
dataKey: `avg_if(span.duration,release,equals,${secondaryRelease})`,
},
{
unit: 'percent_change',
Expand All @@ -173,12 +173,12 @@ export function ScreenSummaryContentPage() {
{
unit: 'count',
title: t('Count (%s)', PRIMARY_RELEASE_ALIAS),
dataKey: `count_if(release,${primaryRelease})`,
dataKey: `count_if(release,equals,${primaryRelease})`,
},
{
unit: 'count',
title: t('Count (%s)', SECONDARY_RELEASE_ALIAS),
dataKey: `count_if(release,${secondaryRelease})`,
dataKey: `count_if(release,equals,${secondaryRelease})`,
},
]}
referrer="api.starfish.mobile-startup-totals"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ describe('ScreenLoadSpansTable', function () {
'span.op',
'span.group',
'span.description',
'avg_if(span.self_time,release,io.sentry.samples.android@7.0.0+2)',
'avg_if(span.self_time,release,io.sentry.samples.android@6.27.0+2)',
'avg_if(span.self_time,release,equals,io.sentry.samples.android@7.0.0+2)',
'avg_if(span.self_time,release,equals,io.sentry.samples.android@6.27.0+2)',
'ttid_contribution_rate()',
'ttfd_contribution_rate()',
'count()',
Expand Down
Loading
Loading