Просмотр исходного кода

fix(profiling): Do not capture 404 errors when finding profile (#36138)

A 404 response indicates that there isn't a matching profile for this
transaction, no need to capture the error in this case but we should otherwise.
Tony Xiao 2 лет назад
Родитель
Сommit
b228f95753
1 измененных файлов с 12 добавлено и 3 удалено
  1. 12 3
      static/app/views/performance/transactionDetails/transactionToProfileButton.tsx

+ 12 - 3
static/app/views/performance/transactionDetails/transactionToProfileButton.tsx

@@ -1,4 +1,5 @@
 import {useEffect, useState} from 'react';
 import {useEffect, useState} from 'react';
+import * as Sentry from '@sentry/react';
 
 
 import {Client} from 'sentry/api';
 import {Client} from 'sentry/api';
 import Button from 'sentry/components/button';
 import Button from 'sentry/components/button';
@@ -24,9 +25,17 @@ function TransactionToProfileButton({transactionId, orgId, projectId}: Props) {
   });
   });
 
 
   useEffect(() => {
   useEffect(() => {
-    fetchProfileId(api, transactionId, orgId, projectId).then((profileId: ProfileId) => {
-      setProfileIdState({type: 'resolved', data: profileId.profile_id});
-    });
+    fetchProfileId(api, transactionId, orgId, projectId)
+      .then((profileId: ProfileId) => {
+        setProfileIdState({type: 'resolved', data: profileId.profile_id});
+      })
+      .catch(err => {
+        // If there isn't a matching profile, we get a 404. No need to raise an error
+        // in this case, but we should otherwise.
+        if (err.status !== 404) {
+          Sentry.captureException(err);
+        }
+      });
   }, [api, transactionId, orgId, projectId]);
   }, [api, transactionId, orgId, projectId]);
 
 
   if (profileIdState.type !== 'resolved') {
   if (profileIdState.type !== 'resolved') {