resourceInfo.tsx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import FileSize from 'sentry/components/fileSize';
  2. import {Tooltip} from 'sentry/components/tooltip';
  3. import {t, tct} from 'sentry/locale';
  4. import {formatBytesBase2} from 'sentry/utils';
  5. import {RateUnits} from 'sentry/utils/discover/fields';
  6. import getDynamicText from 'sentry/utils/getDynamicText';
  7. import {DurationCell} from 'sentry/views/starfish/components/tableCells/durationCell';
  8. import {ThroughputCell} from 'sentry/views/starfish/components/tableCells/throughputCell';
  9. import {DataTitles, getThroughputTitle} from 'sentry/views/starfish/views/spans/types';
  10. import {Block, BlockContainer} from 'sentry/views/starfish/views/spanSummaryPage/block';
  11. type Props = {
  12. avgContentLength: number;
  13. avgDecodedContentLength: number;
  14. avgDuration: number;
  15. avgTransferSize: number;
  16. throughput: number;
  17. };
  18. function ResourceInfo(props: Props) {
  19. const {
  20. avgContentLength,
  21. avgDecodedContentLength,
  22. avgDuration,
  23. avgTransferSize,
  24. throughput,
  25. } = props;
  26. const tooltips = {
  27. avgContentLength: tct(
  28. 'On average, this resource is [bytes] when encoded (for example when gzipped).',
  29. {
  30. bytes: getDynamicText({
  31. value: formatBytesBase2(avgContentLength),
  32. fixed: 'xx KB',
  33. }),
  34. }
  35. ),
  36. avgDecodedContentLength: tct('On average, this resource is [bytes] when decoded.', {
  37. bytes: getDynamicText({
  38. value: formatBytesBase2(avgDecodedContentLength),
  39. fixed: 'xx KB',
  40. }),
  41. }),
  42. avgTransferSize: tct(
  43. 'On average, the total bytes transferred over the network (body + headers) for this resource is [bytes].',
  44. {
  45. bytes: getDynamicText({
  46. value: formatBytesBase2(avgTransferSize),
  47. fixed: 'xx KB',
  48. }),
  49. }
  50. ),
  51. };
  52. return (
  53. <BlockContainer>
  54. <Block title={t('Avg encoded size')}>
  55. <Tooltip isHoverable title={tooltips.avgContentLength} showUnderline>
  56. <FileSize bytes={avgContentLength} />
  57. </Tooltip>
  58. </Block>
  59. <Block title={t('Avg decoded size')}>
  60. <Tooltip isHoverable title={tooltips.avgDecodedContentLength} showUnderline>
  61. <FileSize bytes={avgDecodedContentLength} />
  62. </Tooltip>
  63. </Block>
  64. <Block title={t('Avg transfer size')}>
  65. <Tooltip isHoverable title={tooltips.avgTransferSize} showUnderline>
  66. <FileSize bytes={avgTransferSize} />
  67. </Tooltip>
  68. </Block>
  69. <Block title={DataTitles.avg}>
  70. <DurationCell milliseconds={avgDuration} />
  71. </Block>
  72. <Block title={getThroughputTitle('http')}>
  73. <ThroughputCell rate={throughput * 60} unit={RateUnits.PER_SECOND} />
  74. </Block>
  75. </BlockContainer>
  76. );
  77. }
  78. export default ResourceInfo;