Skip to content

Commit c16ae14

Browse files
committed
lint
1 parent 23cb622 commit c16ae14

File tree

2 files changed

+50
-44
lines changed

2 files changed

+50
-44
lines changed

src/sentry/static/sentry/app/components/events/interfaces/spans/span_tree.tsx

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import space from 'app/styles/space';
66
import Count from 'app/components/count';
77

88
import {SpanType, SpanEntry, SentryEvent} from './types';
9-
import {isValidSpanID, toPercent} from './utils';
9+
import {
10+
isValidSpanID,
11+
toPercent,
12+
boundsGenerator,
13+
SpanBoundsType,
14+
SpanGeneratedBoundsType,
15+
} from './utils';
1016
import {DragManagerChildrenProps} from './drag_manager';
1117
import SpanDetail from './span_detail';
1218

@@ -656,46 +662,4 @@ const ChevronClosed = props => (
656662
</svg>
657663
);
658664

659-
type SpanBoundsType = {startTimestamp: number; endTimestamp: number};
660-
type SpanGeneratedBoundsType = {start: number; end: number};
661-
662-
const boundsGenerator = (bounds: {
663-
traceStartTimestamp: number;
664-
traceEndTimestamp: number;
665-
viewStart: number; // in [0, 1]
666-
viewEnd: number; // in [0, 1]
667-
}) => {
668-
const {traceEndTimestamp, traceStartTimestamp, viewStart, viewEnd} = bounds;
669-
670-
// viewStart and viewEnd are percentage values (%) of the view window relative to the left
671-
// side of the trace view minimap
672-
673-
// invariant: viewStart <= viewEnd
674-
675-
// duration of the entire trace in seconds
676-
const duration = traceEndTimestamp - traceStartTimestamp;
677-
678-
const viewStartTimestamp = traceStartTimestamp + viewStart * duration;
679-
const viewEndTimestamp = traceEndTimestamp - (1 - viewEnd) * duration;
680-
const viewDuration = viewEndTimestamp - viewStartTimestamp;
681-
682-
return (spanBounds: SpanBoundsType): SpanGeneratedBoundsType => {
683-
const {startTimestamp, endTimestamp} = spanBounds;
684-
685-
const start = (startTimestamp - viewStartTimestamp) / viewDuration;
686-
687-
if (!_.isNumber(endTimestamp)) {
688-
return {
689-
start,
690-
end: 1,
691-
};
692-
}
693-
694-
return {
695-
start,
696-
end: (endTimestamp - viewStartTimestamp) / viewDuration,
697-
};
698-
};
699-
};
700-
701665
export default SpanTree;

src/sentry/static/sentry/app/components/events/interfaces/spans/utils.tsx

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {isString} from 'lodash';
1+
import {isString, isNumber} from 'lodash';
22

33
const Rect = (x: number, y: number, width: number, height: number) => {
44
// x and y are left/top coords respectively
@@ -64,3 +64,45 @@ export const isValidSpanID = (maybeSpanID: any) => {
6464
export const toPercent = (value: number) => {
6565
return `${(value * 100).toFixed(3)}%`;
6666
};
67+
68+
export type SpanBoundsType = {startTimestamp: number; endTimestamp: number};
69+
export type SpanGeneratedBoundsType = {start: number; end: number};
70+
71+
export const boundsGenerator = (bounds: {
72+
traceStartTimestamp: number;
73+
traceEndTimestamp: number;
74+
viewStart: number; // in [0, 1]
75+
viewEnd: number; // in [0, 1]
76+
}) => {
77+
const {traceEndTimestamp, traceStartTimestamp, viewStart, viewEnd} = bounds;
78+
79+
// viewStart and viewEnd are percentage values (%) of the view window relative to the left
80+
// side of the trace view minimap
81+
82+
// invariant: viewStart <= viewEnd
83+
84+
// duration of the entire trace in seconds
85+
const duration = traceEndTimestamp - traceStartTimestamp;
86+
87+
const viewStartTimestamp = traceStartTimestamp + viewStart * duration;
88+
const viewEndTimestamp = traceEndTimestamp - (1 - viewEnd) * duration;
89+
const viewDuration = viewEndTimestamp - viewStartTimestamp;
90+
91+
return (spanBounds: SpanBoundsType): SpanGeneratedBoundsType => {
92+
const {startTimestamp, endTimestamp} = spanBounds;
93+
94+
const start = (startTimestamp - viewStartTimestamp) / viewDuration;
95+
96+
if (!isNumber(endTimestamp)) {
97+
return {
98+
start,
99+
end: 1,
100+
};
101+
}
102+
103+
return {
104+
start,
105+
end: (endTimestamp - viewStartTimestamp) / viewDuration,
106+
};
107+
};
108+
};

0 commit comments

Comments
 (0)