import {CHART_PALETTE} from 'sentry/constants/chartPalette'; import {t} from 'sentry/locale'; import {MutableSearch} from 'sentry/utils/tokenizeSearch'; import Chart, {ChartType} from 'sentry/views/starfish/components/chart'; import ChartPanel from 'sentry/views/starfish/components/chartPanel'; import {useSpanMetricsSeries} from 'sentry/views/starfish/queries/useDiscoverSeries'; interface TotalTokensUsedChartProps { groupId?: string; } export function TotalTokensUsedChart({groupId}: TotalTokensUsedChartProps) { const aggregate = 'ai_total_tokens_used()'; let query = 'span.category:"ai"'; if (groupId) { query = `${query} span.ai.pipeline.group:"${groupId}"`; } const {data, isLoading, error} = useSpanMetricsSeries( { yAxis: [aggregate], search: new MutableSearch(query), }, 'api.ai-pipelines.view' ); return ( ); } interface NumberOfPipelinesChartProps { groupId?: string; } export function NumberOfPipelinesChart({groupId}: NumberOfPipelinesChartProps) { const aggregate = 'count()'; let query = 'span.category:"ai.pipeline"'; if (groupId) { query = `${query} span.group:"${groupId}"`; } const {data, isLoading, error} = useSpanMetricsSeries( { yAxis: [aggregate], search: new MutableSearch(query), }, 'api.ai-pipelines.view' ); return ( ); } interface PipelineDurationChartProps { groupId?: string; } export function PipelineDurationChart({groupId}: PipelineDurationChartProps) { const aggregate = 'avg(span.duration)'; let query = 'span.category:"ai.pipeline"'; if (groupId) { query = `${query} span.group:"${groupId}"`; } const {data, isLoading, error} = useSpanMetricsSeries( { yAxis: [aggregate], search: new MutableSearch(query), }, 'api.ai-pipelines.view' ); return ( ); }