throughputChart.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {CHART_PALETTE} from 'sentry/constants/chartPalette';
  2. import {t} from 'sentry/locale';
  3. import {decodeScalar} from 'sentry/utils/queryString';
  4. import {useLocation} from 'sentry/utils/useLocation';
  5. import {CHART_HEIGHT} from 'sentry/views/performance/database/settings';
  6. import {useQueuesTimeSeriesQuery} from 'sentry/views/performance/queues/queries/useQueuesTimeSeriesQuery';
  7. import Chart, {ChartType} from 'sentry/views/starfish/components/chart';
  8. import ChartPanel from 'sentry/views/starfish/components/chartPanel';
  9. interface Props {
  10. error?: Error | null;
  11. }
  12. export function ThroughputChart({error}: Props) {
  13. const {query} = useLocation();
  14. const destination = decodeScalar(query.destination);
  15. const {data, isLoading} = useQueuesTimeSeriesQuery({destination});
  16. return (
  17. <ChartPanel title={t('Published vs Processed')}>
  18. <Chart
  19. height={CHART_HEIGHT}
  20. grid={{
  21. left: '0',
  22. right: '0',
  23. top: '8px',
  24. bottom: '0',
  25. }}
  26. data={
  27. [
  28. {
  29. seriesName: t('Published'),
  30. data: data['count_op(queue.publish)'].data,
  31. },
  32. {
  33. seriesName: t('Processed'),
  34. data: data['count_op(queue.process)'].data,
  35. },
  36. ] ?? []
  37. }
  38. loading={isLoading}
  39. error={error}
  40. chartColors={CHART_PALETTE[2].slice(1, 3)}
  41. type={ChartType.LINE}
  42. showLegend
  43. />
  44. </ChartPanel>
  45. );
  46. }