Browse Source

feat(discover): Make sampling warning smarter (#60379)

Matej Minar 1 year ago
parent
commit
bb23b73768

+ 1 - 1
static/app/views/discover/results.tsx

@@ -630,7 +630,7 @@ export class Results extends Component<Props, State> {
                     />
                   )}
                 </CustomMeasurementsContext.Consumer>
-                {!query.includes('event.type:error') && <SampleDataAlert />}
+                <SampleDataAlert query={query} />
                 <MetricsCardinalityProvider
                   organization={organization}
                   location={location}

+ 13 - 0
static/app/views/discover/sampleDataAlert.spec.tsx

@@ -51,4 +51,17 @@ describe('SampleDataAlert', function () {
 
     expect(container).toBeEmptyDOMElement();
   });
+
+  it("doesn't render when event.type:error", function () {
+    const dismiss = jest.fn();
+    mockUseDismissAlert.mockImplementation(() => {
+      return {
+        dismiss,
+        isDismissed: false,
+      };
+    });
+    const {container} = render(<SampleDataAlert query="event.type:error" />);
+
+    expect(container).toBeEmptyDOMElement();
+  });
 });

+ 21 - 2
static/app/views/discover/sampleDataAlert.tsx

@@ -9,7 +9,22 @@ import {space} from 'sentry/styles/space';
 import useDismissAlert from 'sentry/utils/useDismissAlert';
 import useOrganization from 'sentry/utils/useOrganization';
 
-export function SampleDataAlert() {
+const EXCLUDED_CONDITIONS = [
+  'event.type:error',
+  '!event.type:transaction',
+  'event.type:csp',
+  'event.type:default',
+  'handled:',
+  'unhandled:',
+  'culprit:',
+  'issue:',
+  'level:',
+  'unreal.crash_type:',
+  'stack.',
+  'error.',
+];
+
+export function SampleDataAlert({query}: {query?: string}) {
   const user = ConfigStore.get('user');
   const {slug, isDynamicallySampled} = useOrganization();
 
@@ -17,7 +32,11 @@ export function SampleDataAlert() {
     key: `${slug}-${user.id}:sample-data-alert-dismissed`,
   });
 
-  if (isDismissed || !isDynamicallySampled) {
+  const isQueryingErrors = EXCLUDED_CONDITIONS.some(
+    condition => query?.includes(condition)
+  );
+
+  if (isDismissed || !isDynamicallySampled || isQueryingErrors) {
     return null;
   }