latencyChart.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import {CHART_PALETTE} from 'sentry/constants/chartPalette';
  2. import {t} from 'sentry/locale';
  3. import {CHART_HEIGHT} from 'sentry/views/performance/database/settings';
  4. import {useQueuesTimeSeriesQuery} from 'sentry/views/performance/queues/queries/useQueuesTimeSeriesQuery';
  5. import Chart, {ChartType} from 'sentry/views/starfish/components/chart';
  6. import ChartPanel from 'sentry/views/starfish/components/chartPanel';
  7. interface Props {
  8. destination?: string;
  9. error?: Error | null;
  10. }
  11. export function LatencyChart({error, destination}: Props) {
  12. const {data, isLoading} = useQueuesTimeSeriesQuery({destination});
  13. return (
  14. <ChartPanel title={t('Avg Latency')}>
  15. <Chart
  16. height={CHART_HEIGHT}
  17. grid={{
  18. left: '0',
  19. right: '0',
  20. top: '8px',
  21. bottom: '0',
  22. }}
  23. data={
  24. [
  25. {
  26. seriesName: t('Average Time in Queue'),
  27. data: data['avg(messaging.message.receive.latency)'].data,
  28. },
  29. {
  30. seriesName: t('Average Processing Time'),
  31. data: data['avg_if(span.duration,span.op,queue.process)'].data,
  32. },
  33. ] ?? []
  34. }
  35. loading={isLoading}
  36. error={error}
  37. chartColors={CHART_PALETTE[2].slice(1)}
  38. type={ChartType.AREA}
  39. showLegend
  40. stacked
  41. aggregateOutputFormat="duration"
  42. />
  43. </ChartPanel>
  44. );
  45. }