Browse Source

ref(profiling): Merge profile provider for both modes (#83338)

This merges the 2 providers for transaction and continuous type profiles
into 1 so that we can pass either type of profile to it anywhere instead
of having 2 different providers.
Tony Xiao 1 month ago
parent
commit
ccd071d283

+ 1 - 1
static/app/components/events/interfaces/performance/spanEvidence.tsx

@@ -80,7 +80,7 @@ export function SpanEvidenceSection({event, organization, projectSlug}: Props) {
         <ProfilesProvider
           orgSlug={organization.slug}
           projectSlug={projectSlug}
-          profileId={profileId || ''}
+          profileMeta={profileId || ''}
         >
           <ProfileContext.Consumer>
             {profiles => (

+ 6 - 6
static/app/components/profiling/flamegraph/continuousFlamegraph.tsx

@@ -66,11 +66,11 @@ import {
 import {formatTo} from 'sentry/utils/profiling/units/units';
 import {useDevicePixelRatio} from 'sentry/utils/useDevicePixelRatio';
 import {useMemoWithPrevious} from 'sentry/utils/useMemoWithPrevious';
-import {
-  useContinuousProfile,
-  useContinuousProfileSegment,
-} from 'sentry/views/profiling/continuousProfileProvider';
 import {useProfileGroup} from 'sentry/views/profiling/profileGroupProvider';
+import {
+  useProfiles,
+  useProfileTransaction,
+} from 'sentry/views/profiling/profilesProvider';
 
 import {FlamegraphDrawer} from './flamegraphDrawer/flamegraphDrawer';
 import {FlamegraphWarnings} from './flamegraphOverlays/FlamegraphWarnings';
@@ -246,9 +246,9 @@ export function ContinuousFlamegraph(): ReactElement {
   const devicePixelRatio = useDevicePixelRatio();
   const dispatch = useDispatchFlamegraphState();
 
-  const profiles = useContinuousProfile();
+  const profiles = useProfiles();
   const profileGroup = useProfileGroup();
-  const segment = useContinuousProfileSegment();
+  const segment = useProfileTransaction();
 
   const configSpaceQueryParam = useMemo(() => decodeConfigSpace(), []);
 

+ 1 - 1
static/app/components/profiling/flamegraph/flamegraph.spec.tsx

@@ -6,7 +6,7 @@ import {act, render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 import ProjectsStore from 'sentry/stores/projectsStore';
 import {useParams} from 'sentry/utils/useParams';
 import ProfileFlamegraph from 'sentry/views/profiling/profileFlamechart';
-import ProfilesAndTransactionProvider from 'sentry/views/profiling/profilesProvider';
+import ProfilesAndTransactionProvider from 'sentry/views/profiling/transactionProfileProvider';
 
 jest.mock('sentry/utils/useParams', () => ({
   useParams: jest.fn(),

+ 1 - 8
static/app/components/profiling/flamegraph/flamegraph.tsx

@@ -68,7 +68,6 @@ import {useProfileGroup} from 'sentry/views/profiling/profileGroupProvider';
 import {
   useProfiles,
   useProfileTransaction,
-  useSetProfiles,
 } from 'sentry/views/profiling/profilesProvider';
 
 import {FlamegraphDrawer} from './flamegraphDrawer/flamegraphDrawer';
@@ -219,7 +218,6 @@ function Flamegraph(): ReactElement {
   const dispatch = useDispatchFlamegraphState();
 
   const profiles = useProfiles();
-  const setProfiles = useSetProfiles();
   const profileGroup = useProfileGroup();
 
   const flamegraphTheme = useFlamegraphTheme();
@@ -1314,12 +1312,7 @@ function Flamegraph(): ReactElement {
     [dispatch]
   );
 
-  const onImport = useCallback(
-    (p: Profiling.ProfileInput) => {
-      setProfiles({type: 'resolved', data: p});
-    },
-    [setProfiles]
-  );
+  const onImport = useCallback(() => {}, []);
 
   useEffect(() => {
     if (defined(flamegraphProfiles.threadId)) {

+ 3 - 1
static/app/routes.tsx

@@ -2184,7 +2184,9 @@ function buildRoutes() {
       </Route>
       <Route
         path="profile/:projectId/:eventId/"
-        component={make(() => import('sentry/views/profiling/profilesProvider'))}
+        component={make(
+          () => import('sentry/views/profiling/transactionProfileProvider')
+        )}
       >
         <Route
           path="flamegraph/"

+ 1 - 1
static/app/views/discover/eventDetails/content.tsx

@@ -219,7 +219,7 @@ function EventDetailsContent(props: Props) {
                           <ProfilesProvider
                             orgSlug={organization.slug}
                             projectSlug={projectId}
-                            profileId={profileId || ''}
+                            profileMeta={profileId || ''}
                           >
                             <ProfileContext.Consumer>
                               {profiles => (

+ 2 - 2
static/app/views/performance/newTraceDetails/traceDrawer/details/missingInstrumentation.tsx

@@ -73,7 +73,7 @@ export function MissingInstrumentationNodeDetails(
           <ProfilesProvider
             orgSlug={organization.slug}
             projectSlug={event?.projectSlug ?? ''}
-            profileId={profileId || ''}
+            profileMeta={profileId || ''}
           >
             <ProfileContext.Consumer>
               {profiles => (
@@ -191,7 +191,7 @@ function LegacyMissingInstrumentationNodeDetails({
           <ProfilesProvider
             orgSlug={organization.slug}
             projectSlug={node.event?.projectSlug ?? ''}
-            profileId={profileId || ''}
+            profileMeta={profileId || ''}
           >
             <ProfileContext.Consumer>
               {profiles => (

+ 1 - 1
static/app/views/performance/newTraceDetails/traceDrawer/details/span/index.tsx

@@ -253,7 +253,7 @@ export function SpanNodeDetails({
           <ProfilesProvider
             orgSlug={organization.slug}
             projectSlug={node.event?.projectSlug}
-            profileId={profileId || ''}
+            profileMeta={profileId || ''}
           >
             <ProfileContext.Consumer>
               {profiles => (

+ 1 - 1
static/app/views/performance/traceDetails/newTraceDetailsTransactionBar.tsx

@@ -483,7 +483,7 @@ function NewTraceDetailsTransactionBar(props: Props) {
             <ProfilesProvider
               orgSlug={organization.slug}
               projectSlug={embeddedChildren.projectSlug ?? ''}
-              profileId={profileId || ''}
+              profileMeta={profileId || ''}
             >
               <ProfileContext.Consumer>
                 {profiles => (

+ 1 - 1
static/app/views/performance/traceDetails/traceViewDetailPanel.tsx

@@ -488,7 +488,7 @@ function SpanDetailsBody({
         <ProfilesProvider
           orgSlug={organization.slug}
           projectSlug={detail.event.projectSlug}
-          profileId={profileId || ''}
+          profileMeta={profileId || ''}
         >
           <ProfileContext.Consumer>
             {profiles => (

Some files were not shown because too many files changed in this diff