Browse Source

chore(profiling): Update list of profiling supported python platforms (#44244)

With sentry-sdk==1.15.0, all transactions in python can be profiled.
Tony Xiao 2 years ago
parent
commit
1fbd09c9ed

+ 28 - 25
static/app/components/profiling/ProfilingOnboarding/util.ts

@@ -15,30 +15,33 @@ export type SupportedProfilingPlatform = (typeof supportedProfilingPlatforms)[nu
 export type SupportedProfilingPlatformSDK =
   (typeof supportedProfilingPlatformSDKs)[number];
 
-const platformToDocsPlatformSDK: Record<
-  SupportedProfilingPlatform,
-  SupportedProfilingPlatformSDK
-> = {
-  android: 'android',
-  'apple-ios': 'apple-ios',
-  node: 'node',
-  'node-express': 'node',
-  'node-koa': 'node',
-  'node-connect': 'node',
-  python: 'python',
-  'python-django': 'python',
-  'python-flask': 'python',
-  'python-sanic': 'python',
-  'python-bottle': 'python',
-  'python-pylons': 'python',
-  'python-pyramid': 'python',
-  'python-tornado': 'python',
-  rust: 'rust',
-};
+function getDocsPlatformSDKForPlatform(platform): PlatformKey | null {
+  if (platform === 'android') {
+    return 'android';
+  }
+
+  if (platform === 'apple-ios') {
+    return 'apple-ios';
+  }
+
+  if (platform.startsWith('node')) {
+    return 'node';
+  }
+
+  if (platform.startsWith('python')) {
+    return 'python';
+  }
+
+  if (platform === 'rust') {
+    return 'rust';
+  }
+
+  return null;
+}
 
 export function isProfilingSupportedOrProjectHasProfiles(project: Project): boolean {
   return !!(
-    (project.platform && platformToDocsPlatformSDK[project.platform]) ||
+    (project.platform && getDocsPlatformSDKForPlatform(project.platform)) ||
     // If this project somehow managed to send profiles, then profiling is supported for this project.
     // Sometimes and for whatever reason, platform can also not be set on a project so the above check alone would fail
     project.hasProfiles
@@ -77,12 +80,12 @@ function makeDocKey(platformId: PlatformKey, key: string) {
 
 type DocKeyMap = Record<(typeof profilingOnboardingDocKeys)[number], string>;
 export function makeDocKeyMap(platformId: PlatformKey | undefined) {
-  if (!platformId || !platformToDocsPlatformSDK[platformId]) {
+  const docsPlatform = getDocsPlatformSDKForPlatform(platformId);
+
+  if (!platformId || !docsPlatform) {
     return null;
   }
 
-  const docsPlatform = platformToDocsPlatformSDK[platformId];
-
   const expectedDocKeys: ProfilingOnboardingDocKeys[] =
     supportedPlatformExpectedDocKeys[docsPlatform];
   return expectedDocKeys.reduce((acc: DocKeyMap, key) => {
@@ -97,7 +100,7 @@ export function splitProjectsByProfilingSupport(projects: Project[]): {
 } {
   const [supported, unsupported] = partition(
     projects,
-    project => project.platform && platformToDocsPlatformSDK[project.platform]
+    project => project.platform && getDocsPlatformSDKForPlatform(project.platform)
   );
 
   return {supported, unsupported};

+ 4 - 0
static/app/data/platformCategories.tsx

@@ -228,11 +228,15 @@ export const profiling = [
   'python',
   'python-django',
   'python-flask',
+  'python-fastapi',
+  'python-starlette',
   'python-sanic',
+  'python-celery',
   'python-bottle',
   'python-pylons',
   'python-pyramid',
   'python-tornado',
+  'python-rq',
   // rust
   'rust',
 ] as const;