Browse Source

feat(perf-issues): Make perf issue rate option managable

Uses the /manage endpoint to expose some of our perf issue options, starting with the global detection option.
k-fish 2 years ago
parent
commit
68b27d35da
2 changed files with 27 additions and 2 deletions
  1. 9 0
      static/app/views/admin/adminSettings.tsx
  2. 18 2
      static/app/views/admin/options.tsx

+ 9 - 0
static/app/views/admin/adminSettings.tsx

@@ -1,3 +1,4 @@
+import Feature from 'sentry/components/acl/feature';
 import {Form} from 'sentry/components/forms';
 import {Panel, PanelHeader} from 'sentry/components/panels';
 import {t} from 'sentry/locale';
@@ -16,6 +17,7 @@ const optionsAvailable = [
   'auth.user-rate-limit',
   'api.rate-limit.org-create',
   'beacon.anonymous',
+  'store.use-ingest-performance-detection-only',
 ];
 
 type Field = ReturnType<typeof getOption>;
@@ -87,6 +89,13 @@ export default class AdminSettings extends AsyncView<{}, State> {
             <PanelHeader>Beacon</PanelHeader>
             {fields['beacon.anonymous']}
           </Panel>
+
+          <Feature features={['organizations:performance-issues']}>
+            <Panel>
+              <PanelHeader>Performance</PanelHeader>
+              {fields['store.use-ingest-performance-detection-only']}
+            </Panel>
+          </Feature>
         </Form>
       </div>
     );

+ 18 - 2
static/app/views/admin/options.tsx

@@ -3,6 +3,7 @@ import keyBy from 'lodash/keyBy';
 import {
   BooleanField,
   EmailField,
+  NumberField,
   RadioBooleanField,
   TextField,
 } from 'sentry/components/forms';
@@ -19,13 +20,16 @@ type Field = {
   label: React.ReactNode;
   allowEmpty?: boolean;
   component?: React.ComponentType<any>;
-  defaultValue?: () => string | false;
+  defaultValue?: () => string | number | false;
   disabled?: boolean;
   disabledReason?: string;
   help?: React.ReactNode;
+  max?: number;
+  min?: number;
   noLabel?: string;
   placeholder?: string;
   required?: boolean;
+  step?: number;
   yesFirst?: boolean;
   yesLabel?: string;
 };
@@ -184,6 +188,18 @@ const definitions: Field[] = [
     component: BooleanField,
     defaultValue: () => false,
   },
+  {
+    key: 'store.use-ingest-performance-detection-only',
+    label: t('Performance issue detection rate'),
+    help: t(
+      'Controls the rate at which performance issues are detected across the entire system. A value of 0 will disable performance issue detection, and a value of 1.0 turns on detection for every ingested transaction.'
+    ),
+    defaultValue: () => '0',
+    component: NumberField,
+    min: 0.0,
+    max: 1.0,
+    step: 0.0001,
+  },
 ];
 
 const definitionsMap = keyBy(definitions, def => def.key);
@@ -198,7 +214,7 @@ export function getOption(option: string): Field {
   return definitionsMap[option];
 }
 
-export function getOptionDefault(option: string): string | false | undefined {
+export function getOptionDefault(option: string): string | number | false | undefined {
   const meta = getOption(option);
   return meta.defaultValue ? meta.defaultValue() : undefined;
 }