throughputChart.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import type {Series} from 'sentry/types/echarts';
  2. import {RateUnit} from 'sentry/utils/discover/fields';
  3. import {formatRate} from 'sentry/utils/formatters';
  4. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  5. import {THROUGHPUT_COLOR} from 'sentry/views/insights/colors';
  6. import Chart, {ChartType} from 'sentry/views/insights/common/components/chart';
  7. import ChartPanel from 'sentry/views/insights/common/components/chartPanel';
  8. import {getThroughputChartTitle} from 'sentry/views/insights/common/views/spans/types';
  9. import {ALERTS} from 'sentry/views/insights/http/alerts';
  10. import {CHART_HEIGHT} from 'sentry/views/insights/http/settings';
  11. import type {SpanMetricsQueryFilters} from 'sentry/views/insights/types';
  12. interface Props {
  13. isLoading: boolean;
  14. series: Series;
  15. error?: Error | null;
  16. filters?: SpanMetricsQueryFilters;
  17. }
  18. export function ThroughputChart({series, isLoading, error, filters}: Props) {
  19. const filterString = filters && MutableSearch.fromQueryObject(filters).formatString();
  20. const alertConfig = {...ALERTS.spm, query: filterString ?? ALERTS.spm.query};
  21. return (
  22. <ChartPanel title={getThroughputChartTitle('http')} alertConfigs={[alertConfig]}>
  23. <Chart
  24. height={CHART_HEIGHT}
  25. grid={{
  26. left: '0',
  27. right: '0',
  28. top: '8px',
  29. bottom: '0',
  30. }}
  31. data={[series]}
  32. loading={isLoading}
  33. error={error}
  34. chartColors={[THROUGHPUT_COLOR]}
  35. type={ChartType.LINE}
  36. aggregateOutputFormat="rate"
  37. rateUnit={RateUnit.PER_MINUTE}
  38. tooltipFormatterOptions={{
  39. valueFormatter: value => formatRate(value, RateUnit.PER_MINUTE),
  40. }}
  41. />
  42. </ChartPanel>
  43. );
  44. }