latencyChart.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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, isLoading} = 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. {
  31. seriesName: t('Average Time in Queue'),
  32. data: data['avg(messaging.message.receive.latency)'].data,
  33. },
  34. {
  35. seriesName: t('Average Processing Time'),
  36. data: data['avg(span.duration)'].data,
  37. },
  38. ] ?? []
  39. }
  40. loading={isLoading}
  41. error={error}
  42. chartColors={CHART_PALETTE[2].slice(1)}
  43. type={ChartType.AREA}
  44. showLegend
  45. stacked
  46. aggregateOutputFormat="duration"
  47. />
  48. </ChartPanel>
  49. );
  50. }