spanRectangleOverlay.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {DurationPill, RowRectangle} from 'sentry/components/performance/waterfall/rowBar';
  2. import {
  3. getDurationDisplay,
  4. getHumanDuration,
  5. toPercent,
  6. } from 'sentry/components/performance/waterfall/utils';
  7. import {EnhancedSpan} from './types';
  8. import {getSpanGroupTimestamps, SpanViewBoundsType} from './utils';
  9. export function SpanRectangleOverlay({
  10. bounds,
  11. spanGrouping,
  12. }: {
  13. bounds: SpanViewBoundsType;
  14. spanGrouping: EnhancedSpan[];
  15. }) {
  16. const {startTimestamp, endTimestamp} = getSpanGroupTimestamps(spanGrouping);
  17. const duration = Math.abs(endTimestamp - startTimestamp);
  18. const durationDisplay = getDurationDisplay(bounds);
  19. const durationString = getHumanDuration(duration);
  20. return (
  21. <RowRectangle
  22. spanBarHatch={false}
  23. style={{
  24. left: `min(${toPercent(bounds.left || 0)}, calc(100% - 1px))`,
  25. width: toPercent(bounds.width || 0),
  26. }}
  27. >
  28. <DurationPill
  29. durationDisplay={durationDisplay}
  30. showDetail={false}
  31. spanBarHatch={false}
  32. >
  33. {durationString}
  34. </DurationPill>
  35. </RowRectangle>
  36. );
  37. }