latencyChart.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 LatencyChart({error}: Props) {
  13. const {query} = useLocation();
  14. const destination = decodeScalar(query.destination);
  15. const {data, isLoading} = useQueuesTimeSeriesQuery({destination});
  16. return (
  17. <ChartPanel title={t('Avg Latency')}>
  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('Average Time in Queue'),
  30. data: data['avg(messaging.message.receive.latency)'].data,
  31. },
  32. {
  33. seriesName: t('Average Processing Time'),
  34. data: data['avg_if(span.duration,span.op,queue.process)'].data,
  35. },
  36. ] ?? []
  37. }
  38. loading={isLoading}
  39. error={error}
  40. chartColors={CHART_PALETTE[2].slice(1)}
  41. type={ChartType.AREA}
  42. showLegend
  43. stacked
  44. aggregateOutputFormat="duration"
  45. />
  46. </ChartPanel>
  47. );
  48. }