throughputChart.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import {CHART_PALETTE} from 'sentry/constants/chartPalette';
  2. import {t} from 'sentry/locale';
  3. import {RateUnit} from 'sentry/utils/discover/fields';
  4. import {formatRate} from 'sentry/utils/formatters';
  5. import Chart, {ChartType} from 'sentry/views/insights/common/components/chart';
  6. import ChartPanel from 'sentry/views/insights/common/components/chartPanel';
  7. import {useProcessQueuesTimeSeriesQuery} from 'sentry/views/insights/queues/queries/useProcessQueuesTimeSeriesQuery';
  8. import {usePublishQueuesTimeSeriesQuery} from 'sentry/views/insights/queues/queries/usePublishQueuesTimeSeriesQuery';
  9. import type {Referrer} from 'sentry/views/insights/queues/referrers';
  10. import {CHART_HEIGHT} from 'sentry/views/insights/queues/settings';
  11. interface Props {
  12. referrer: Referrer;
  13. destination?: string;
  14. error?: Error | null;
  15. }
  16. export function ThroughputChart({error, destination, referrer}: Props) {
  17. const {data: publishData, isPending: isPublishDataLoading} =
  18. usePublishQueuesTimeSeriesQuery({
  19. destination,
  20. referrer,
  21. });
  22. const {data: processData, isPending: isProcessDataLoading} =
  23. useProcessQueuesTimeSeriesQuery({
  24. destination,
  25. referrer,
  26. });
  27. return (
  28. <ChartPanel title={t('Published vs Processed')}>
  29. <Chart
  30. height={CHART_HEIGHT}
  31. grid={{
  32. left: '0',
  33. right: '0',
  34. top: '8px',
  35. bottom: '0',
  36. }}
  37. data={[
  38. {
  39. seriesName: t('Published'),
  40. data: publishData['spm()'].data,
  41. },
  42. {
  43. seriesName: t('Processed'),
  44. data: processData['spm()'].data,
  45. },
  46. ]}
  47. loading={isPublishDataLoading || isProcessDataLoading}
  48. error={error}
  49. chartColors={CHART_PALETTE[2].slice(1, 3)}
  50. type={ChartType.LINE}
  51. aggregateOutputFormat="rate"
  52. rateUnit={RateUnit.PER_MINUTE}
  53. tooltipFormatterOptions={{
  54. valueFormatter: value => formatRate(value, RateUnit.PER_MINUTE),
  55. }}
  56. showLegend
  57. />
  58. </ChartPanel>
  59. );
  60. }