throughputChart.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/database/alerts';
  10. import {CHART_HEIGHT} from 'sentry/views/insights/database/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, 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('db')} 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. chartColors={[THROUGHPUT_COLOR]}
  34. type={ChartType.LINE}
  35. aggregateOutputFormat="rate"
  36. rateUnit={RateUnit.PER_MINUTE}
  37. tooltipFormatterOptions={{
  38. valueFormatter: value => formatRate(value, RateUnit.PER_MINUTE),
  39. }}
  40. />
  41. </ChartPanel>
  42. );
  43. }