@@ -16,8 +16,10 @@ import {
16
16
getPhysicalSpacePositionFromOffset ,
17
17
transformMatrixBetweenRect ,
18
18
} from 'sentry/utils/profiling/gl/utils' ;
19
+ import type { Profile } from 'sentry/utils/profiling/profile/profile' ;
19
20
import { FlamegraphChartRenderer } from 'sentry/utils/profiling/renderers/chartRenderer' ;
20
21
import type { Rect } from 'sentry/utils/profiling/speedscope' ;
22
+ import { formatTo } from 'sentry/utils/profiling/units/units' ;
21
23
22
24
import { useCanvasScroll } from './interactions/useCanvasScroll' ;
23
25
import { useCanvasZoomOrScroll } from './interactions/useCanvasZoomOrScroll' ;
@@ -36,6 +38,7 @@ interface FlamegraphChartProps {
36
38
chartCanvas : FlamegraphCanvas | null ;
37
39
chartCanvasRef : HTMLCanvasElement | null ;
38
40
chartView : CanvasView < FlamegraphChartModel > | null ;
41
+ configViewUnit : Profile [ 'unit' ] ;
39
42
noMeasurementMessage : string | undefined ;
40
43
setChartCanvasRef : ( ref : HTMLCanvasElement | null ) => void ;
41
44
status : RequestState < any > [ 'type' ] ;
@@ -51,9 +54,10 @@ export function FlamegraphChart({
51
54
setChartCanvasRef,
52
55
canvasBounds,
53
56
noMeasurementMessage,
57
+ configViewUnit,
54
58
} : FlamegraphChartProps ) {
55
- const scheduler = useCanvasScheduler ( canvasPoolManager ) ;
56
59
const theme = useFlamegraphTheme ( ) ;
60
+ const scheduler = useCanvasScheduler ( canvasPoolManager ) ;
57
61
58
62
const [ configSpaceCursor , setConfigSpaceCursor ] = useState < vec2 | null > ( null ) ;
59
63
const [ startInteractionVector , setStartInteractionVector ] = useState < vec2 | null > ( null ) ;
@@ -262,15 +266,20 @@ export function FlamegraphChart({
262
266
[ configSpaceCursor , chartView ]
263
267
) ;
264
268
269
+ const isInsufficientDuration = useMemo ( ( ) => {
270
+ if ( ! chart ) return false ;
271
+ return formatTo ( chart ?. configSpace . width , configViewUnit , 'millisecond' ) < 200 ;
272
+ } , [ chart , configViewUnit ] ) ;
273
+
265
274
let message : string | undefined ;
266
275
267
276
if ( chart ) {
268
277
if (
269
- chart . configSpace . width < 200 * 1e6 &&
278
+ isInsufficientDuration &&
270
279
( chart . status === 'insufficient data' || chart . status === 'empty metrics' )
271
280
) {
272
281
message = t ( 'Profile duration was too short to collect enough metrics' ) ;
273
- } else if ( chart . configSpace . width >= 200 && chart . status === 'insufficient data' ) {
282
+ } else if ( ! isInsufficientDuration && chart . status === 'insufficient data' ) {
274
283
message =
275
284
noMeasurementMessage ||
276
285
t (
0 commit comments