index.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import {Fragment} from 'react';
  2. import {Location} from 'history';
  3. import {HeaderTitleLegend} from 'sentry/components/charts/styles';
  4. import QuestionTooltip from 'sentry/components/questionTooltip';
  5. import {t, tct} from 'sentry/locale';
  6. import {OrganizationSummary} from 'sentry/types';
  7. import {ViewProps} from '../../../types';
  8. import {filterToField, SpanOperationBreakdownFilter} from '../../filter';
  9. import Content from './content';
  10. type Props = ViewProps & {
  11. currentFilter: SpanOperationBreakdownFilter;
  12. location: Location;
  13. organization: OrganizationSummary;
  14. };
  15. function DurationPercentileChart({currentFilter, ...props}: Props) {
  16. const header = (
  17. <HeaderTitleLegend>
  18. {currentFilter === SpanOperationBreakdownFilter.None
  19. ? t('Duration Percentiles')
  20. : tct('Span Operation Percentiles - [operationName]', {
  21. operationName: currentFilter,
  22. })}
  23. <QuestionTooltip
  24. position="top"
  25. size="sm"
  26. title={t(
  27. `Compare the duration at each percentile. Compare with Latency Histogram to see transaction volume at duration intervals.`
  28. )}
  29. />
  30. </HeaderTitleLegend>
  31. );
  32. function generateFields() {
  33. if (currentFilter === SpanOperationBreakdownFilter.None) {
  34. return [
  35. 'percentile(transaction.duration, 0.10)',
  36. 'percentile(transaction.duration, 0.25)',
  37. 'percentile(transaction.duration, 0.50)',
  38. 'percentile(transaction.duration, 0.75)',
  39. 'percentile(transaction.duration, 0.90)',
  40. 'percentile(transaction.duration, 0.95)',
  41. 'percentile(transaction.duration, 0.99)',
  42. 'percentile(transaction.duration, 0.995)',
  43. 'percentile(transaction.duration, 0.999)',
  44. 'p100()',
  45. ];
  46. }
  47. const field = filterToField(currentFilter);
  48. return [
  49. `percentile(${field}, 0.10)`,
  50. `percentile(${field}, 0.25)`,
  51. `percentile(${field}, 0.50)`,
  52. `percentile(${field}, 0.75)`,
  53. `percentile(${field}, 0.90)`,
  54. `percentile(${field}, 0.95)`,
  55. `percentile(${field}, 0.99)`,
  56. `percentile(${field}, 0.995)`,
  57. `percentile(${field}, 0.999)`,
  58. `p100(${field})`,
  59. ];
  60. }
  61. const fields = generateFields();
  62. return (
  63. <Fragment>
  64. {header}
  65. <Content {...props} currentFilter={currentFilter} fields={fields} />
  66. </Fragment>
  67. );
  68. }
  69. export default DurationPercentileChart;