diff --git a/static/app/views/insights/llmMonitoring/components/tables/pipelinesTable.tsx b/static/app/views/insights/llmMonitoring/components/tables/pipelinesTable.tsx index 3538763cc92c6e..4ec71e2455dafc 100644 --- a/static/app/views/insights/llmMonitoring/components/tables/pipelinesTable.tsx +++ b/static/app/views/insights/llmMonitoring/components/tables/pipelinesTable.tsx @@ -129,11 +129,21 @@ export function PipelinesTable() { search: new MutableSearch( `span.category:ai span.ai.pipeline.group:[${(data as Row[])?.map(x => x['span.group']).join(',')}]` ), - fields: [ - 'span.ai.pipeline.group', - 'sum(ai.total_tokens.used)', - 'sum(ai.total_cost)', - ], + fields: ['span.ai.pipeline.group', 'sum(ai.total_tokens.used)'], + }, + 'api.performance.ai-analytics.token-usage-chart' + ); + + const { + data: tokenCostData, + isLoading: tokenCostLoading, + error: tokenCostError, + } = useSpanMetrics( + { + search: new MutableSearch( + `span.category:ai span.ai.pipeline.group:[${(data as Row[])?.map(x => x['span.group']).join(',')}]` + ), + fields: ['span.ai.pipeline.group', 'sum(ai.total_cost)'], }, 'api.performance.ai-analytics.token-usage-chart' ); @@ -151,7 +161,14 @@ export function PipelinesTable() { if (tokenUsedDataPoint) { row['sum(ai.total_tokens.used)'] = tokenUsedDataPoint['sum(ai.total_tokens.used)']; - row['sum(ai.total_cost)'] = tokenUsedDataPoint['sum(ai.total_cost)']; + } + } + if (!tokenCostLoading && !tokenCostError) { + const tokenCostDataPoint = tokenCostData.find( + tokenRow => tokenRow['span.ai.pipeline.group'] === row['span.group'] + ); + if (tokenCostDataPoint) { + row['sum(ai.total_cost)'] = tokenCostDataPoint['sum(ai.total_cost)']; } } return row;