Browse Source

chore: Remove Sentry SDK metric calls (#84130)

In preparation for upgrading to Sentry SDK v9, we need to remove calls
to the old Sentry Metrics SDK.
Catherine Lee 1 month ago
parent
commit
4a71509d94

+ 0 - 3
static/app/components/replays/canvasReplayerPlugin.tsx

@@ -275,8 +275,6 @@ export function CanvasReplayerPlugin(events: eventWithTime[]): ReplayPlugin {
       errorHandler: (err: unknown) => {
         if (err instanceof Error) {
           Sentry.captureException(err);
-        } else {
-          Sentry.metrics.increment('replay.canvas_player.error_canvas_mutation');
         }
       },
     });
@@ -358,7 +356,6 @@ export function CanvasReplayerPlugin(events: eventWithTime[]): ReplayPlugin {
 function handleProcessEventError(err: unknown) {
   if (err instanceof InvalidCanvasNodeError) {
     // This can throw if mirror DOM is not ready
-    Sentry.metrics.increment('replay.canvas_player.no_canvas_id');
     return;
   }
 

+ 2 - 14
static/app/components/replays/replayProcessingError.tsx

@@ -14,7 +14,7 @@ interface Props {
   className?: string;
 }
 
-export default function ReplayProcessingError({className, processingErrors}: Props) {
+export default function ReplayProcessingError({className}: Props) {
   const {replay} = useReplayContext();
   const {sdk} = replay?.getReplay() || {};
 
@@ -25,20 +25,8 @@ export default function ReplayProcessingError({className, processingErrors}: Pro
       if (sdk) {
         scope.setTag('sdk.version', sdk.version);
       }
-      processingErrors.forEach(error => {
-        Sentry.metrics.increment(`replay.processing-error`, 1, {
-          tags: {
-            'sdk.version': sdk?.version ?? 'unknown',
-            // There are only 2 different error types
-            type:
-              error.toLowerCase() === 'missing meta frame'
-                ? 'missing-meta-frame'
-                : 'insufficient-replay-frames',
-          },
-        });
-      });
     });
-  }, [processingErrors, sdk]);
+  }, [sdk]);
 
   return (
     <StyledAlert type="error" showIcon className={className}>

+ 0 - 3
static/app/utils/metrics/useIncrementQueryMetric.tsx

@@ -28,9 +28,6 @@ export const useIncrementQueryMetric = (options: Options) => {
         isGrouped: !!mergedValues.groupBy?.length,
         isFiltered: !!mergedValues.query,
       };
-      Sentry.metrics.increment(metricName, 1, {
-        tags,
-      });
 
       const span = Sentry.getActiveSpan();
       if (span) {

+ 0 - 31
static/app/utils/performanceForSentry/index.tsx

@@ -601,28 +601,6 @@ function isINPEntity(entry: PerformanceEntry): entry is INPPerformanceEntry {
   return entry.entryType === 'first-input';
 }
 
-function getNearestElementName(node: HTMLElement | undefined | null): string | undefined {
-  if (!node) {
-    return 'no-element';
-  }
-
-  let current: HTMLElement | null = node;
-  while (current && current !== document.body) {
-    const elementName =
-      current.dataset?.testId ??
-      current.dataset?.sentryComponent ??
-      current.dataset?.element;
-
-    if (elementName) {
-      return elementName;
-    }
-
-    current = current.parentElement;
-  }
-
-  return `${node.tagName.toLowerCase()}.${node.className ?? ''}`;
-}
-
 export function makeIssuesINPObserver(): PerformanceObserver | undefined {
   if (!supportsINP()) {
     return undefined;
@@ -639,15 +617,6 @@ export function makeIssuesINPObserver(): PerformanceObserver | undefined {
         if (entry.duration < 16) {
           return;
         }
-
-        Sentry.metrics.distribution('issues-stream.inp', entry.duration, {
-          unit: 'millisecond',
-          tags: {
-            element: getNearestElementName(entry.target),
-            entryType: entry.entryType,
-            interaction: entry.name,
-          },
-        });
       }
     });
   });

+ 0 - 25
static/app/utils/replays/hooks/useLogReplayDataLoaded.tsx

@@ -1,5 +1,4 @@
 import {useEffect} from 'react';
-import * as Sentry from '@sentry/react';
 
 import {trackAnalytics} from 'sentry/utils/analytics';
 import type useLoadReplayReader from 'sentry/utils/replays/hooks/useLoadReplayReader';
@@ -59,30 +58,6 @@ function useLogReplayDataLoaded({fetchError, fetching, projectSlug, replay}: Pro
         replay_id: replayRecord.id,
       });
     }
-
-    const metricData = {
-      unit: 'millisecond',
-      tags: {
-        // This is a boolean to reduce cardinality -- technically this can
-        // match 7.8.x, but replay wasn't released in that version, so this should be fine
-        recentSdkVersion: replayRecord.sdk.version?.startsWith('7.8') ?? false,
-      },
-    };
-
-    if (replay.timestampDeltas.startedAtDelta !== 0) {
-      Sentry.metrics.distribution(
-        'replay.start-time-delta',
-        replay.timestampDeltas.startedAtDelta,
-        metricData
-      );
-    }
-    if (replay.timestampDeltas.finishedAtDelta !== 0) {
-      Sentry.metrics.distribution(
-        'replay.end-time-delta',
-        replay.timestampDeltas.finishedAtDelta,
-        metricData
-      );
-    }
   }, [organization, project, fetchError, fetching, projectSlug, replay]);
 }
 

+ 0 - 10
static/app/views/insights/browser/resources/components/sampleImages.tsx

@@ -208,15 +208,6 @@ function ImageContainer(props: {
 
   const handleError = () => {
     setHasError(true);
-    Sentry.metrics.increment('performance.resource.image_load', 1, {
-      tags: {status: 'error'},
-    });
-  };
-
-  const handleLoad = () => {
-    Sentry.metrics.increment('performance.resource.image_load', 1, {
-      tags: {status: 'success'},
-    });
   };
 
   return (
@@ -231,7 +222,6 @@ function ImageContainer(props: {
           <img
             data-test-id="sample-image"
             onError={handleError}
-            onLoad={handleLoad}
             src={src}
             style={{
               width: '100%',

+ 0 - 4
static/app/views/metrics/context.tsx

@@ -6,7 +6,6 @@ import {
   useMemo,
   useState,
 } from 'react';
-import * as Sentry from '@sentry/react';
 import isEqual from 'lodash/isEqual';
 
 import type {FocusAreaSelection} from 'sentry/components/metrics/chart/types';
@@ -316,10 +315,8 @@ export function MetricsContextProvider({children}: {children: React.ReactNode})
   const handleAddFocusArea = useCallback(
     (area: FocusAreaSelection) => {
       if (!area.range.start || !area.range.end) {
-        Sentry.metrics.increment('ddm.enhance.range-undefined');
         return;
       }
-      Sentry.metrics.increment('ddm.enhance.add');
       handleSetSelectedWidgetIndex(area.widgetIndex);
       updateQuery({focusArea: JSON.stringify(area)}, {replace: true});
     },
@@ -327,7 +324,6 @@ export function MetricsContextProvider({children}: {children: React.ReactNode})
   );
 
   const handleRemoveFocusArea = useCallback(() => {
-    Sentry.metrics.increment('ddm.enhance.remove');
     updateQuery({focusArea: undefined}, {replace: true});
   }, [updateQuery]);
 

+ 0 - 7
static/app/views/metrics/layout.tsx

@@ -1,6 +1,5 @@
 import {Fragment, memo, useCallback} from 'react';
 import styled from '@emotion/styled';
-import * as Sentry from '@sentry/react';
 
 import emptyStateImg from 'sentry-images/spot/custom-metrics-empty-state.svg';
 
@@ -71,11 +70,6 @@ export const MetricsLayout = memo(() => {
 
   const addCustomMetric = useCallback(
     (referrer: 'header' | 'onboarding_panel' | 'banner') => {
-      Sentry.metrics.increment('ddm.add_custom_metric', 1, {
-        tags: {
-          referrer,
-        },
-      });
       trackAnalytics('ddm.open-onboarding', {
         organization,
         source: referrer,
@@ -86,7 +80,6 @@ export const MetricsLayout = memo(() => {
   );
 
   const viewPerformanceMetrics = useCallback(() => {
-    Sentry.metrics.increment('ddm.view_performance_metrics', 1);
     trackAnalytics('ddm.view_performance_metrics', {
       organization,
     });

+ 0 - 4
static/app/views/metrics/metricFormulaContextMenu.tsx

@@ -1,6 +1,5 @@
 import {useMemo} from 'react';
 import styled from '@emotion/styled';
-import * as Sentry from '@sentry/react';
 
 import Feature from 'sentry/components/acl/feature';
 import type {MenuItemProps} from 'sentry/components/dropdownMenu';
@@ -46,7 +45,6 @@ export function MetricFormulaContextMenu({
           trackAnalytics('ddm.widget.duplicate', {
             organization,
           });
-          Sentry.metrics.increment('ddm.widget.duplicate');
           duplicateWidget(widgetIndex);
         },
       },
@@ -75,7 +73,6 @@ export function MetricFormulaContextMenu({
             organization,
             source: 'widget',
           });
-          Sentry.metrics.increment('ddm.widget.dashboard');
           createDashboardWidget?.();
         },
       },
@@ -85,7 +82,6 @@ export function MetricFormulaContextMenu({
         label: t('Remove Equation'),
         disabled: !canDelete,
         onAction: () => {
-          Sentry.metrics.increment('ddm.widget.delete');
           removeWidget(widgetIndex);
         },
       },

+ 0 - 6
static/app/views/metrics/metricQueryContextMenu.tsx

@@ -1,5 +1,4 @@
 import {useMemo} from 'react';
-import * as Sentry from '@sentry/react';
 
 import {openAddToDashboardModal} from 'sentry/actionCreators/modal';
 import {navigateTo} from 'sentry/actionCreators/navigation';
@@ -76,7 +75,6 @@ export function MetricQueryContextMenu({
         trackAnalytics('ddm.widget.duplicate', {
           organization,
         });
-        Sentry.metrics.increment('ddm.widget.duplicate');
         duplicateWidget(widgetIndex);
       },
     };
@@ -91,7 +89,6 @@ export function MetricQueryContextMenu({
           organization,
           source: 'widget',
         });
-        Sentry.metrics.increment('ddm.widget.alert');
         createAlert?.();
       },
     };
@@ -130,7 +127,6 @@ export function MetricQueryContextMenu({
           organization,
           source: 'widget',
         });
-        Sentry.metrics.increment('ddm.widget.dashboard');
         createDashboardWidget?.();
       },
     };
@@ -144,7 +140,6 @@ export function MetricQueryContextMenu({
         trackAnalytics('ddm.widget.settings', {
           organization,
         });
-        Sentry.metrics.increment('ddm.widget.settings');
 
         if (!isVirtualMetric(metricsQuery)) {
           navigateTo(
@@ -166,7 +161,6 @@ export function MetricQueryContextMenu({
         trackAnalytics('ddm.widget.delete', {
           organization,
         });
-        Sentry.metrics.increment('ddm.widget.delete');
         removeWidget(widgetIndex);
       },
     };

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