From f45bebefd750154eec8142af09fad555b9391215 Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 28 May 2024 09:22:13 -0400 Subject: [PATCH] feat(profiling): enable profiling measurement charts if measurements are sent (#71258) React native uses javascript as the platform value which is used both by browser sdk which doesnt report cpu and memory measures. This means we cant know ahead of time if we expect the measurements and simply enable the charts (this toggles loading and the various no measurement states). In order to not enable these charts for browser SDKs and confuse users, we take a different approach and enable the charts on demand, once the data has loaded. We miss out on some of the loading states, but this all happens pretty fast as the profile loads, so I dont think it's a big deal in terms of UX. Fixes https://github.com/getsentry/sentry/issues/59989 --- .../profiling/flamegraph/flamegraph.tsx | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/static/app/components/profiling/flamegraph/flamegraph.tsx b/static/app/components/profiling/flamegraph/flamegraph.tsx index d0717d683388e1..e37cc842daf4c7 100644 --- a/static/app/components/profiling/flamegraph/flamegraph.tsx +++ b/static/app/components/profiling/flamegraph/flamegraph.tsx @@ -240,18 +240,28 @@ function Flamegraph(): ReactElement { const hasBatteryChart = useMemo(() => { const platform = profileGroup.metadata.platform; - return platform === 'cocoa'; - }, [profileGroup.metadata.platform]); + return platform === 'cocoa' || profileGroup.measurements?.cpu_energy_usage; + }, [profileGroup.metadata.platform, profileGroup.measurements]); const hasCPUChart = useMemo(() => { const platform = profileGroup.metadata.platform; - return platform === 'cocoa' || platform === 'android' || platform === 'node'; - }, [profileGroup.metadata.platform]); + return ( + platform === 'cocoa' || + platform === 'android' || + platform === 'node' || + profileGroup.measurements?.cpu_usage + ); + }, [profileGroup.metadata.platform, profileGroup.measurements]); const hasMemoryChart = useMemo(() => { const platform = profileGroup.metadata.platform; - return platform === 'cocoa' || platform === 'android' || platform === 'node'; - }, [profileGroup.metadata.platform]); + return ( + platform === 'cocoa' || + platform === 'android' || + platform === 'node' || + profileGroup.measurements?.memory_footprint + ); + }, [profileGroup.metadata.platform, profileGroup.measurements]); const profile = useMemo(() => { return profileGroup.profiles.find(p => p.threadId === threadId);