index.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import {Fragment} from 'react';
  2. import type {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 type {Organization, OrganizationSummary} from 'sentry/types';
  7. import {getPercentiles} from 'sentry/views/performance/transactionSummary/transactionOverview/durationPercentileChart/utils';
  8. import type {ViewProps} from '../../../types';
  9. import {filterToField, SpanOperationBreakdownFilter} from '../../filter';
  10. import Content from './content';
  11. type Props = ViewProps & {
  12. currentFilter: SpanOperationBreakdownFilter;
  13. location: Location;
  14. organization: OrganizationSummary;
  15. queryExtras?: Record<string, string>;
  16. };
  17. function DurationPercentileChart({currentFilter, ...props}: Props) {
  18. const percentiles = getPercentiles(props.organization as Organization);
  19. const header = (
  20. <HeaderTitleLegend>
  21. {currentFilter === SpanOperationBreakdownFilter.NONE
  22. ? t('Duration Percentiles')
  23. : tct('Span Operation Percentiles - [operationName]', {
  24. operationName: currentFilter,
  25. })}
  26. <QuestionTooltip
  27. position="top"
  28. size="sm"
  29. title={t(
  30. `Compare the duration at each percentile. Compare with Latency Histogram to see transaction volume at duration intervals.`
  31. )}
  32. />
  33. </HeaderTitleLegend>
  34. );
  35. function generateFields() {
  36. let field: string | undefined;
  37. if (currentFilter === SpanOperationBreakdownFilter.NONE) {
  38. field = 'transaction.duration';
  39. } else {
  40. field = filterToField(currentFilter);
  41. }
  42. return percentiles.map(percentile =>
  43. percentile === '1' ? `p100(${field})` : `percentile(${field}, ${percentile})`
  44. );
  45. }
  46. const fields = generateFields();
  47. return (
  48. <Fragment>
  49. {header}
  50. <Content {...props} currentFilter={currentFilter} fields={fields} />
  51. </Fragment>
  52. );
  53. }
  54. export default DurationPercentileChart;