latencyChart.tsx 1.5 KB

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