latencyChart.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import {CHART_PALETTE} from 'sentry/constants/chartPalette';
  2. import {t} from 'sentry/locale';
  3. import Chart, {ChartType} from 'sentry/views/insights/common/components/chart';
  4. import ChartPanel from 'sentry/views/insights/common/components/chartPanel';
  5. import {useProcessQueuesTimeSeriesQuery} from 'sentry/views/insights/queues/queries/useProcessQueuesTimeSeriesQuery';
  6. import type {Referrer} from 'sentry/views/insights/queues/referrers';
  7. import {CHART_HEIGHT} from 'sentry/views/insights/queues/settings';
  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, isPending} = useProcessQueuesTimeSeriesQuery({
  15. destination,
  16. referrer,
  17. });
  18. return (
  19. <ChartPanel title={t('Avg Latency')}>
  20. <Chart
  21. height={CHART_HEIGHT}
  22. grid={{
  23. left: '0',
  24. right: '0',
  25. top: '8px',
  26. bottom: '0',
  27. }}
  28. data={[
  29. {
  30. seriesName: t('Average Time in Queue'),
  31. data: data['avg(messaging.message.receive.latency)'].data,
  32. },
  33. {
  34. seriesName: t('Average Processing Time'),
  35. data: data['avg(span.duration)'].data,
  36. },
  37. ]}
  38. loading={isPending}
  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. }