12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070 |
- import {Fragment} from 'react';
- import {RouteComponentProps} from 'react-router';
- import styled from '@emotion/styled';
- import {addErrorMessage} from 'sentry/actionCreators/indicator';
- import Access from 'sentry/components/acl/access';
- import Feature from 'sentry/components/acl/feature';
- import {Button} from 'sentry/components/button';
- import Confirm from 'sentry/components/confirm';
- import FieldWrapper from 'sentry/components/forms/fieldGroup/fieldWrapper';
- import Form from 'sentry/components/forms/form';
- import JsonForm from 'sentry/components/forms/jsonForm';
- import {Field, JsonFormObject} from 'sentry/components/forms/types';
- import ExternalLink from 'sentry/components/links/externalLink';
- import LoadingIndicator from 'sentry/components/loadingIndicator';
- import Panel from 'sentry/components/panels/panel';
- import PanelFooter from 'sentry/components/panels/panelFooter';
- import PanelHeader from 'sentry/components/panels/panelHeader';
- import PanelItem from 'sentry/components/panels/panelItem';
- import {t, tct} from 'sentry/locale';
- import ConfigStore from 'sentry/stores/configStore';
- import ProjectsStore from 'sentry/stores/projectsStore';
- import {space} from 'sentry/styles/space';
- import {IssueTitle, IssueType, Organization, Project, Scope} from 'sentry/types';
- import {DynamicSamplingBiasType} from 'sentry/types/sampling';
- import {trackAnalytics} from 'sentry/utils/analytics';
- import {formatPercentage} from 'sentry/utils/formatters';
- import {safeGetQsParam} from 'sentry/utils/integrationUtil';
- import {isActiveSuperuser} from 'sentry/utils/isActiveSuperuser';
- import routeTitleGen from 'sentry/utils/routeTitle';
- import DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView';
- import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
- import PermissionAlert from 'sentry/views/settings/project/permissionAlert';
- // These labels need to be exported so that they can be used in audit logs
- export const retentionPrioritiesLabels = {
- boostLatestRelease: t('Prioritize new releases'),
- boostEnvironments: t('Prioritize dev environments'),
- boostLowVolumeTransactions: t('Prioritize low-volume transactions'),
- ignoreHealthChecks: t('Deprioritize health checks'),
- };
- export const allowedDurationValues: number[] = [
- 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1500, 2000, 2500,
- 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500,
- 10000,
- ]; // In milliseconds
- export const allowedPercentageValues: number[] = [
- 0.2, 0.25, 0.3, 0.33, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95,
- ];
- export const allowedSizeValues: number[] = [
- 50000, 100000, 200000, 300000, 400000, 500000, 512000, 600000, 700000, 800000, 900000,
- 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000,
- 10000000,
- ]; // 50kb to 10MB in bytes
- export const projectDetectorSettingsId = 'detector-threshold-settings';
- type ProjectPerformanceSettings = {[key: string]: number | boolean};
- enum DetectorConfigAdmin {
- N_PLUS_DB_ENABLED = 'n_plus_one_db_queries_detection_enabled',
- SLOW_DB_ENABLED = 'slow_db_queries_detection_enabled',
- DB_MAIN_THREAD_ENABLED = 'db_on_main_thread_detection_enabled',
- FILE_IO_ENABLED = 'file_io_on_main_thread_detection_enabled',
- CONSECUTIVE_DB_ENABLED = 'consecutive_db_queries_detection_enabled',
- RENDER_BLOCK_ASSET_ENABLED = 'large_render_blocking_asset_detection_enabled',
- UNCOMPRESSED_ASSET_ENABLED = 'uncompressed_assets_detection_enabled',
- LARGE_HTTP_PAYLOAD_ENABLED = 'large_http_payload_detection_enabled',
- N_PLUS_ONE_API_CALLS_ENABLED = 'n_plus_one_api_calls_detection_enabled',
- CONSECUTIVE_HTTP_ENABLED = 'consecutive_http_spans_detection_enabled',
- HTTP_OVERHEAD_ENABLED = 'http_overhead_detection_enabled',
- TRANSACTION_DURATION_REGRESSION_ENABLED = 'transaction_duration_regression_detection_enabled',
- }
- export enum DetectorConfigCustomer {
- SLOW_DB_DURATION = 'slow_db_query_duration_threshold',
- N_PLUS_DB_DURATION = 'n_plus_one_db_duration_threshold',
- N_PLUS_API_CALLS_DURATION = 'n_plus_one_api_calls_total_duration_threshold',
- RENDER_BLOCKING_ASSET_RATIO = 'render_blocking_fcp_ratio',
- LARGE_HTT_PAYLOAD_SIZE = 'large_http_payload_size_threshold',
- DB_ON_MAIN_THREAD_DURATION = 'db_on_main_thread_duration_threshold',
- FILE_IO_MAIN_THREAD_DURATION = 'file_io_on_main_thread_duration_threshold',
- UNCOMPRESSED_ASSET_DURATION = 'uncompressed_asset_duration_threshold',
- UNCOMPRESSED_ASSET_SIZE = 'uncompressed_asset_size_threshold',
- CONSECUTIVE_DB_MIN_TIME_SAVED = 'consecutive_db_min_time_saved_threshold',
- CONSECUTIVE_HTTP_MIN_TIME_SAVED = 'consecutive_http_spans_min_time_saved_threshold',
- HTTP_OVERHEAD_REQUEST_DELAY = 'http_request_delay_threshold',
- }
- type RouteParams = {orgId: string; projectId: string};
- type Props = RouteComponentProps<{projectId: string}, {}> & {
- organization: Organization;
- project: Project;
- };
- type ProjectThreshold = {
- metric: string;
- threshold: string;
- editedBy?: string;
- id?: string;
- };
- type State = DeprecatedAsyncView['state'] & {
- threshold: ProjectThreshold;
- };
- class ProjectPerformance extends DeprecatedAsyncView<Props, State> {
- getTitle() {
- const {projectId} = this.props.params;
- return routeTitleGen(t('Performance'), projectId, false);
- }
- getProjectEndpoint({orgId, projectId}: RouteParams) {
- return `/projects/${orgId}/${projectId}/`;
- }
- getPerformanceIssuesEndpoint({orgId, projectId}: RouteParams) {
- return `/projects/${orgId}/${projectId}/performance-issues/configure/`;
- }
- getEndpoints(): ReturnType<DeprecatedAsyncView['getEndpoints']> {
- const {params, organization} = this.props;
- const {projectId} = params;
- const endpoints: ReturnType<DeprecatedAsyncView['getEndpoints']> = [
- [
- 'threshold',
- `/projects/${organization.slug}/${projectId}/transaction-threshold/configure/`,
- ],
- ['project', `/projects/${organization.slug}/${projectId}/`],
- ];
- const performanceIssuesEndpoint = [
- 'performance_issue_settings',
- `/projects/${organization.slug}/${projectId}/performance-issues/configure/`,
- ] as [string, string];
- endpoints.push(performanceIssuesEndpoint);
- return endpoints;
- }
- getRetentionPrioritiesData(...data) {
- return {
- dynamicSamplingBiases: Object.entries(data[1].form).map(([key, value]) => ({
- id: key,
- active: value,
- })),
- };
- }
- handleDelete = () => {
- const {projectId} = this.props.params;
- const {organization} = this.props;
- this.setState({
- loading: true,
- });
- this.api.request(
- `/projects/${organization.slug}/${projectId}/transaction-threshold/configure/`,
- {
- method: 'DELETE',
- success: () => {
- trackAnalytics('performance_views.project_transaction_threshold.clear', {
- organization,
- });
- },
- complete: () => this.fetchData(),
- }
- );
- };
- handleThresholdsReset = () => {
- const {projectId} = this.props.params;
- const {organization, project} = this.props;
- this.setState({
- loading: true,
- });
- trackAnalytics('performance_views.project_issue_detection_thresholds_reset', {
- organization,
- project_slug: project.slug,
- });
- this.api.request(
- `/projects/${organization.slug}/${projectId}/performance-issues/configure/`,
- {
- method: 'DELETE',
- complete: () => this.fetchData(),
- }
- );
- };
- getEmptyMessage() {
- return t('There is no threshold set for this project.');
- }
- renderLoading() {
- return (
- <LoadingIndicatorContainer>
- <LoadingIndicator />
- </LoadingIndicatorContainer>
- );
- }
- get formFields(): Field[] {
- const fields: Field[] = [
- {
- name: 'metric',
- type: 'select',
- label: t('Calculation Method'),
- options: [
- {value: 'duration', label: t('Transaction Duration')},
- {value: 'lcp', label: t('Largest Contentful Paint')},
- ],
- help: tct(
- 'This determines which duration is used to set your thresholds. By default, we use transaction duration which measures the entire length of the transaction. You can also set this to use a [link:Web Vital].',
- {
- link: (
- <ExternalLink href="https://docs.sentry.io/product/performance/web-vitals/" />
- ),
- }
- ),
- },
- {
- name: 'threshold',
- type: 'string',
- label: t('Response Time Threshold (ms)'),
- placeholder: t('300'),
- help: tct(
- 'Define what a satisfactory response time is based on the calculation method above. This will affect how your [link1:Apdex] and [link2:User Misery] thresholds are calculated. For example, misery will be 4x your satisfactory response time.',
- {
- link1: (
- <ExternalLink href="https://docs.sentry.io/performance-monitoring/performance/metrics/#apdex" />
- ),
- link2: (
- <ExternalLink href="https://docs.sentry.io/product/performance/metrics/#user-misery" />
- ),
- }
- ),
- },
- ];
- return fields;
- }
- get areAllConfigurationsDisabled(): boolean {
- let result = true;
- Object.values(DetectorConfigAdmin).forEach(threshold => {
- result = result && !this.state.performance_issue_settings[threshold];
- });
- return result;
- }
- get performanceIssueFormFields(): Field[] {
- return [
- {
- name: 'performanceIssueCreationRate',
- type: 'range',
- label: t('Performance Issue Creation Rate'),
- min: 0.0,
- max: 1.0,
- step: 0.01,
- defaultValue: 0,
- help: t(
- 'This determines the rate at which performance issues are created. A rate of 0.0 will disable performance issue creation.'
- ),
- },
- {
- name: 'performanceIssueSendToPlatform',
- type: 'boolean',
- label: t('Send Occurrences To Platform'),
- defaultValue: false,
- help: t(
- 'This determines whether performance issue occurrences are sent to the issues platform.'
- ),
- },
- {
- name: 'performanceIssueCreationThroughPlatform',
- type: 'boolean',
- label: t('Create Issues Through Issues Platform'),
- defaultValue: false,
- help: t(
- 'This determines whether performance issues are created through the issues platform.'
- ),
- },
- ];
- }
- get performanceIssueDetectorAdminFields(): Field[] {
- return [
- {
- name: DetectorConfigAdmin.N_PLUS_DB_ENABLED,
- type: 'boolean',
- label: t('N+1 DB Queries Detection Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue_settings,
- n_plus_one_db_queries_detection_enabled: value,
- },
- }),
- },
- {
- name: DetectorConfigAdmin.SLOW_DB_ENABLED,
- type: 'boolean',
- label: t('Slow DB Queries Detection Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue_settings,
- slow_db_queries_detection_enabled: value,
- },
- }),
- },
- {
- name: DetectorConfigAdmin.N_PLUS_ONE_API_CALLS_ENABLED,
- type: 'boolean',
- label: t('N+1 API Calls Detection Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue_settings,
- n_plus_one_api_calls_detection_enabled: value,
- },
- }),
- },
- {
- name: DetectorConfigAdmin.RENDER_BLOCK_ASSET_ENABLED,
- type: 'boolean',
- label: t('Large Render Blocking Asset Detection Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue_settings,
- large_render_blocking_asset_detection_enabled: value,
- },
- }),
- },
- {
- name: DetectorConfigAdmin.CONSECUTIVE_DB_ENABLED,
- type: 'boolean',
- label: t('Consecutive DB Queries Detection Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue_settings,
- consecutive_db_queries_detection_enabled: value,
- },
- }),
- },
- {
- name: DetectorConfigAdmin.LARGE_HTTP_PAYLOAD_ENABLED,
- type: 'boolean',
- label: t('Large HTTP Payload Detection Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue_settings,
- large_http_payload_detection_enabled: value,
- },
- }),
- },
- {
- name: DetectorConfigAdmin.DB_MAIN_THREAD_ENABLED,
- type: 'boolean',
- label: t('DB On Main Thread Detection Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue_settings,
- db_on_main_thread_detection_enabled: value,
- },
- }),
- },
- {
- name: DetectorConfigAdmin.FILE_IO_ENABLED,
- type: 'boolean',
- label: t('File I/O on Main Thread Detection Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue_settings,
- file_io_on_main_thread_detection_enabled: value,
- },
- }),
- },
- {
- name: DetectorConfigAdmin.UNCOMPRESSED_ASSET_ENABLED,
- type: 'boolean',
- label: t('Uncompressed Assets Detection Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue_settings,
- uncompressed_assets_detection_enabled: value,
- },
- }),
- },
- {
- name: DetectorConfigAdmin.CONSECUTIVE_HTTP_ENABLED,
- type: 'boolean',
- label: t('Consecutive HTTP Detection Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue_settings,
- consecutive_http_spans_detection_enabled: value,
- },
- }),
- },
- {
- name: DetectorConfigAdmin.HTTP_OVERHEAD_ENABLED,
- type: 'boolean',
- label: t('HTTP/1.1 Overhead Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue_settings,
- [DetectorConfigAdmin.HTTP_OVERHEAD_ENABLED]: value,
- },
- }),
- },
- {
- name: DetectorConfigAdmin.TRANSACTION_DURATION_REGRESSION_ENABLED,
- type: 'boolean',
- label: t('Transaction Duration Regression Enabled'),
- defaultValue: true,
- onChange: value =>
- this.setState({
- performance_issue_settings: {
- ...this.state.performance_issue__settings,
- [DetectorConfigAdmin.TRANSACTION_DURATION_REGRESSION_ENABLED]: value,
- },
- }),
- },
- ];
- }
- project_owner_detector_settings = (hasAccess: boolean): JsonFormObject[] => {
- const performanceSettings: ProjectPerformanceSettings =
- this.state.performance_issue_settings;
- const supportMail = ConfigStore.get('supportEmail');
- const disabledReason = hasAccess
- ? tct(
- 'Detection of this issue has been disabled. Contact our support team at [link:support@sentry.io].',
- {
- link: <ExternalLink href={'mailto:' + supportMail} />,
- }
- )
- : null;
- const formatDuration = (value: number | ''): string => {
- return value ? (value < 1000 ? `${value}ms` : `${value / 1000}s`) : '';
- };
- const formatSize = (value: number | ''): string => {
- return value
- ? value < 1000000
- ? `${value / 1000}KB`
- : `${value / 1000000}MB`
- : '';
- };
- const formatFrameRate = (value: number | ''): string => {
- const fps = value && 1000 / value;
- return fps ? `${Math.floor(fps / 5) * 5}fps` : '';
- };
- const issueType = safeGetQsParam('issueType');
- return [
- {
- title: IssueTitle.PERFORMANCE_N_PLUS_ONE_DB_QUERIES,
- fields: [
- {
- name: DetectorConfigCustomer.N_PLUS_DB_DURATION,
- type: 'range',
- label: t('Minimum Total Duration'),
- defaultValue: 100, // ms
- help: t(
- 'Setting the value to 100ms, means that an eligible event will be detected as a N+1 DB Query Issue only if the total duration of the involved spans exceeds 100ms'
- ),
- allowedValues: allowedDurationValues,
- disabled: !(
- hasAccess && performanceSettings[DetectorConfigAdmin.N_PLUS_DB_ENABLED]
- ),
- tickValues: [0, allowedDurationValues.length - 1],
- showTickLabels: true,
- formatLabel: formatDuration,
- flexibleControlStateSize: true,
- disabledReason,
- },
- ],
- initiallyCollapsed: issueType !== IssueType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES,
- },
- {
- title: IssueTitle.PERFORMANCE_SLOW_DB_QUERY,
- fields: [
- {
- name: DetectorConfigCustomer.SLOW_DB_DURATION,
- type: 'range',
- label: t('Minimum Duration'),
- defaultValue: 1000, // ms
- help: t(
- 'Setting the value to 1s, means that an eligible event will be detected as a Slow DB Query Issue only if the duration of the involved db span exceeds 1s.'
- ),
- tickValues: [0, allowedDurationValues.slice(5).length - 1],
- showTickLabels: true,
- allowedValues: allowedDurationValues.slice(5),
- disabled: !(
- hasAccess && performanceSettings[DetectorConfigAdmin.SLOW_DB_ENABLED]
- ),
- formatLabel: formatDuration,
- disabledReason,
- },
- ],
- initiallyCollapsed: issueType !== IssueType.PERFORMANCE_SLOW_DB_QUERY,
- },
- {
- title: IssueTitle.PERFORMANCE_N_PLUS_ONE_API_CALLS,
- fields: [
- {
- name: DetectorConfigCustomer.N_PLUS_API_CALLS_DURATION,
- type: 'range',
- label: t('Minimum Total Duration'),
- defaultValue: 300, // ms
- help: t(
- 'Setting the value to 300ms, means that an eligible event will be detected as a N+1 API Calls Issue only if the total duration of the involved spans exceeds 300ms'
- ),
- allowedValues: allowedDurationValues.slice(5),
- disabled: !(
- hasAccess &&
- performanceSettings[DetectorConfigAdmin.N_PLUS_ONE_API_CALLS_ENABLED]
- ),
- tickValues: [0, allowedDurationValues.slice(5).length - 1],
- showTickLabels: true,
- formatLabel: formatDuration,
- flexibleControlStateSize: true,
- disabledReason,
- },
- ],
- initiallyCollapsed: issueType !== IssueType.PERFORMANCE_N_PLUS_ONE_API_CALLS,
- },
- {
- title: IssueTitle.PERFORMANCE_RENDER_BLOCKING_ASSET,
- fields: [
- {
- name: DetectorConfigCustomer.RENDER_BLOCKING_ASSET_RATIO,
- type: 'range',
- label: t('Minimum FCP Ratio'),
- defaultValue: 0.33,
- help: t(
- 'Setting the value to 33%, means that an eligible event will be detected as a Large Render Blocking Asset Issue only if the duration of the involved span is at least 33% of First Contentful Paint (FCP).'
- ),
- allowedValues: allowedPercentageValues,
- tickValues: [0, allowedPercentageValues.length - 1],
- showTickLabels: true,
- disabled: !(
- hasAccess &&
- performanceSettings[DetectorConfigAdmin.RENDER_BLOCK_ASSET_ENABLED]
- ),
- formatLabel: value => value && formatPercentage(value),
- disabledReason,
- },
- ],
- initiallyCollapsed: issueType !== IssueType.PERFORMANCE_RENDER_BLOCKING_ASSET,
- },
- {
- title: IssueTitle.PERFORMANCE_LARGE_HTTP_PAYLOAD,
- fields: [
- {
- name: DetectorConfigCustomer.LARGE_HTT_PAYLOAD_SIZE,
- type: 'range',
- label: t('Minimum Size'),
- defaultValue: 1000000, // 1MB in bytes
- help: t(
- 'Setting the value to 1MB, means that an eligible event will be detected as a Large HTTP Payload Issue only if the involved HTTP span has a payload size that exceeds 1MB.'
- ),
- tickValues: [0, allowedSizeValues.slice(1).length - 1],
- showTickLabels: true,
- allowedValues: allowedSizeValues.slice(1),
- disabled: !(
- hasAccess &&
- performanceSettings[DetectorConfigAdmin.LARGE_HTTP_PAYLOAD_ENABLED]
- ),
- formatLabel: formatSize,
- disabledReason,
- },
- ],
- initiallyCollapsed: issueType !== IssueType.PERFORMANCE_LARGE_HTTP_PAYLOAD,
- },
- {
- title: IssueTitle.PERFORMANCE_DB_MAIN_THREAD,
- fields: [
- {
- name: DetectorConfigCustomer.DB_ON_MAIN_THREAD_DURATION,
- type: 'range',
- label: t('Frame Rate Drop'),
- defaultValue: 16, // ms
- help: t(
- 'Setting the value to 60fps, means that an eligible event will be detected as a DB on Main Thread Issue only if database spans on the main thread cause frame rate to drop below 60fps.'
- ),
- tickValues: [0, 3],
- showTickLabels: true,
- allowedValues: [10, 16, 33, 50], // representation of 100 to 20 fps in milliseconds
- disabled: !(
- hasAccess && performanceSettings[DetectorConfigAdmin.DB_MAIN_THREAD_ENABLED]
- ),
- formatLabel: formatFrameRate,
- disabledReason,
- },
- ],
- initiallyCollapsed: issueType !== IssueType.PERFORMANCE_DB_MAIN_THREAD,
- },
- {
- title: IssueTitle.PERFORMANCE_FILE_IO_MAIN_THREAD,
- fields: [
- {
- name: DetectorConfigCustomer.FILE_IO_MAIN_THREAD_DURATION,
- type: 'range',
- label: t('Frame Rate Drop'),
- defaultValue: 16, // ms
- help: t(
- 'Setting the value to 60fps, means that an eligible event will be detected as a File I/O on Main Thread Issue only if File I/O spans on the main thread cause frame rate to drop below 60fps.'
- ),
- tickValues: [0, 3],
- showTickLabels: true,
- allowedValues: [10, 16, 33, 50], // representation of 100, 60, 30, 20 fps in milliseconds
- disabled: !(
- hasAccess && performanceSettings[DetectorConfigAdmin.FILE_IO_ENABLED]
- ),
- formatLabel: formatFrameRate,
- disabledReason,
- },
- ],
- initiallyCollapsed: issueType !== IssueType.PERFORMANCE_FILE_IO_MAIN_THREAD,
- },
- {
- title: IssueTitle.PERFORMANCE_CONSECUTIVE_DB_QUERIES,
- fields: [
- {
- name: DetectorConfigCustomer.CONSECUTIVE_DB_MIN_TIME_SAVED,
- type: 'range',
- label: t('Minimum Time Saved'),
- defaultValue: 100, // ms
- help: t(
- 'Setting the value to 100ms, means that an eligible event will be detected as a Consecutive DB Queries Issue only if the time saved by parallelizing the queries exceeds 100ms.'
- ),
- tickValues: [0, allowedDurationValues.slice(0, 23).length - 1],
- showTickLabels: true,
- allowedValues: allowedDurationValues.slice(0, 23),
- disabled: !(
- hasAccess && performanceSettings[DetectorConfigAdmin.CONSECUTIVE_DB_ENABLED]
- ),
- formatLabel: formatDuration,
- disabledReason,
- },
- ],
- initiallyCollapsed: issueType !== IssueType.PERFORMANCE_CONSECUTIVE_DB_QUERIES,
- },
- {
- title: IssueTitle.PERFORMANCE_UNCOMPRESSED_ASSET,
- fields: [
- {
- name: DetectorConfigCustomer.UNCOMPRESSED_ASSET_SIZE,
- type: 'range',
- label: t('Minimum Size'),
- defaultValue: 512000, // in kilobytes
- help: t(
- 'Setting the value to 512KB, means that an eligible event will be detected as an Uncompressed Asset Issue only if the size of the uncompressed asset being transferred exceeds 512KB.'
- ),
- tickValues: [0, allowedSizeValues.slice(1).length - 1],
- showTickLabels: true,
- allowedValues: allowedSizeValues.slice(1),
- disabled: !(
- hasAccess &&
- performanceSettings[DetectorConfigAdmin.UNCOMPRESSED_ASSET_ENABLED]
- ),
- formatLabel: formatSize,
- disabledReason,
- },
- {
- name: DetectorConfigCustomer.UNCOMPRESSED_ASSET_DURATION,
- type: 'range',
- label: t('Minimum Duration'),
- defaultValue: 500, // in ms
- help: t(
- 'Setting the value to 500ms, means that an eligible event will be detected as an Uncompressed Asset Issue only if the duration of the span responsible for transferring the uncompressed asset exceeds 500ms.'
- ),
- tickValues: [0, allowedDurationValues.slice(5).length - 1],
- showTickLabels: true,
- allowedValues: allowedDurationValues.slice(5),
- disabled: !(
- hasAccess &&
- performanceSettings[DetectorConfigAdmin.UNCOMPRESSED_ASSET_ENABLED]
- ),
- formatLabel: formatDuration,
- disabledReason,
- },
- ],
- initiallyCollapsed: issueType !== IssueType.PERFORMANCE_UNCOMPRESSED_ASSET,
- },
- {
- title: IssueTitle.PERFORMANCE_CONSECUTIVE_HTTP,
- fields: [
- {
- name: DetectorConfigCustomer.CONSECUTIVE_HTTP_MIN_TIME_SAVED,
- type: 'range',
- label: t('Minimum Time Saved'),
- defaultValue: 2000, // in ms
- help: t(
- 'Setting the value to 2s, means that an eligible event will be detected as a Consecutive HTTP Issue only if the time saved by parallelizing the http spans exceeds 2s.'
- ),
- tickValues: [0, allowedDurationValues.slice(14).length - 1],
- showTickLabels: true,
- allowedValues: allowedDurationValues.slice(14),
- disabled: !(
- hasAccess &&
- performanceSettings[DetectorConfigAdmin.CONSECUTIVE_HTTP_ENABLED]
- ),
- formatLabel: formatDuration,
- disabledReason,
- },
- ],
- initiallyCollapsed: issueType !== IssueType.PERFORMANCE_CONSECUTIVE_HTTP,
- },
- {
- title: IssueTitle.PERFORMANCE_HTTP_OVERHEAD,
- fields: [
- {
- name: DetectorConfigCustomer.HTTP_OVERHEAD_REQUEST_DELAY,
- type: 'range',
- label: t('Request Delay'),
- defaultValue: 500, // in ms
- help: t(
- 'Setting the value to 500ms, means that the HTTP request delay (wait time) will have to exceed 500ms for an HTTP Overhead issue to be created.'
- ),
- tickValues: [0, allowedDurationValues.slice(6, 17).length - 1],
- showTickLabels: true,
- allowedValues: allowedDurationValues.slice(6, 17),
- disabled: !(
- hasAccess && performanceSettings[DetectorConfigAdmin.HTTP_OVERHEAD_ENABLED]
- ),
- formatLabel: formatDuration,
- disabledReason,
- },
- ],
- initiallyCollapsed: issueType !== IssueType.PERFORMANCE_HTTP_OVERHEAD,
- },
- ];
- };
- get retentionPrioritiesFormFields(): Field[] {
- return [
- {
- name: 'boostLatestRelease',
- type: 'boolean',
- label: retentionPrioritiesLabels.boostLatestRelease,
- help: t(
- 'Captures more transactions for your new releases as they are being adopted'
- ),
- getData: this.getRetentionPrioritiesData,
- },
- {
- name: 'boostEnvironments',
- type: 'boolean',
- label: retentionPrioritiesLabels.boostEnvironments,
- help: t(
- 'Captures more traces from environments that contain "debug", "dev", "local", "qa", and "test"'
- ),
- getData: this.getRetentionPrioritiesData,
- },
- {
- name: 'boostLowVolumeTransactions',
- type: 'boolean',
- label: retentionPrioritiesLabels.boostLowVolumeTransactions,
- help: t("Balance high-volume endpoints so they don't drown out low-volume ones"),
- getData: this.getRetentionPrioritiesData,
- },
- {
- name: 'ignoreHealthChecks',
- type: 'boolean',
- label: retentionPrioritiesLabels.ignoreHealthChecks,
- help: t('Captures fewer of your health checks transactions'),
- getData: this.getRetentionPrioritiesData,
- },
- ];
- }
- get initialData() {
- const {threshold} = this.state;
- return {
- threshold: threshold.threshold,
- metric: threshold.metric,
- };
- }
- renderBody() {
- const {organization, project} = this.props;
- const endpoint = `/projects/${organization.slug}/${project.slug}/transaction-threshold/configure/`;
- const requiredScopes: Scope[] = ['project:write'];
- const params = {orgId: organization.slug, projectId: project.slug};
- const projectEndpoint = this.getProjectEndpoint(params);
- const performanceIssuesEndpoint = this.getPerformanceIssuesEndpoint(params);
- const isSuperUser = isActiveSuperuser();
- return (
- <Fragment>
- <SettingsPageHeader title={t('Performance')} />
- <PermissionAlert project={project} />
- <Form
- saveOnBlur
- allowUndo
- initialData={this.initialData}
- apiMethod="POST"
- apiEndpoint={endpoint}
- onSubmitSuccess={resp => {
- const initial = this.initialData;
- const changedThreshold = initial.metric === resp.metric;
- trackAnalytics('performance_views.project_transaction_threshold.change', {
- organization,
- from: changedThreshold ? initial.threshold : initial.metric,
- to: changedThreshold ? resp.threshold : resp.metric,
- key: changedThreshold ? 'threshold' : 'metric',
- });
- this.setState({threshold: resp});
- }}
- >
- <Access access={requiredScopes} project={project}>
- {({hasAccess}) => (
- <JsonForm
- title={t('General')}
- fields={this.formFields}
- disabled={!hasAccess}
- renderFooter={() => (
- <Actions>
- <Button onClick={() => this.handleDelete()}>{t('Reset All')}</Button>
- </Actions>
- )}
- />
- )}
- </Access>
- </Form>
- <Feature features={['organizations:dynamic-sampling']}>
- <Form
- saveOnBlur
- allowUndo
- initialData={
- project.dynamicSamplingBiases?.reduce((acc, bias) => {
- acc[bias.id] = bias.active;
- return acc;
- }, {}) ?? {}
- }
- onSubmitSuccess={(response, _instance, id, change) => {
- ProjectsStore.onUpdateSuccess(response);
- trackAnalytics(
- change?.new === true
- ? 'dynamic_sampling_settings.priority_enabled'
- : 'dynamic_sampling_settings.priority_disabled',
- {
- organization,
- project_id: project.id,
- id: id as DynamicSamplingBiasType,
- }
- );
- }}
- apiMethod="PUT"
- apiEndpoint={projectEndpoint}
- >
- <Access access={requiredScopes} project={project}>
- {({hasAccess}) => (
- <JsonForm
- title={t('Retention Priorities')}
- fields={this.retentionPrioritiesFormFields}
- disabled={!hasAccess}
- renderFooter={() => (
- <Actions>
- <Button
- external
- href="https://docs.sentry.io/product/performance/performance-at-scale/"
- >
- {t('Read docs')}
- </Button>
- </Actions>
- )}
- />
- )}
- </Access>
- </Form>
- </Feature>
- <Fragment>
- <Feature features={['organizations:performance-issues-dev']}>
- <Form
- saveOnBlur
- allowUndo
- initialData={{
- performanceIssueCreationRate:
- this.state.project.performanceIssueCreationRate,
- performanceIssueSendToPlatform:
- this.state.project.performanceIssueSendToPlatform,
- performanceIssueCreationThroughPlatform:
- this.state.project.performanceIssueCreationThroughPlatform,
- }}
- apiMethod="PUT"
- apiEndpoint={projectEndpoint}
- >
- <Access access={requiredScopes} project={project}>
- {({hasAccess}) => (
- <JsonForm
- title={t('Performance Issues - All')}
- fields={this.performanceIssueFormFields}
- disabled={!hasAccess}
- />
- )}
- </Access>
- </Form>
- </Feature>
- {isSuperUser && (
- <Form
- saveOnBlur
- allowUndo
- initialData={this.state.performance_issue_settings}
- apiMethod="PUT"
- onSubmitError={error => {
- if (error.status === 403) {
- addErrorMessage(
- t(
- 'This action requires active super user access. Please re-authenticate to make changes.'
- )
- );
- }
- }}
- apiEndpoint={performanceIssuesEndpoint}
- >
- <JsonForm
- title={t(
- '### INTERNAL ONLY ### - Performance Issues Admin Detector Settings'
- )}
- fields={this.performanceIssueDetectorAdminFields}
- disabled={!isSuperUser}
- />
- </Form>
- )}
- <Form
- allowUndo
- initialData={this.state.performance_issue_settings}
- apiMethod="PUT"
- apiEndpoint={performanceIssuesEndpoint}
- saveOnBlur
- onSubmitSuccess={(option: {[key: string]: number}) => {
- const [threshold_key, threshold_value] = Object.entries(option)[0];
- trackAnalytics(
- 'performance_views.project_issue_detection_threshold_changed',
- {
- organization,
- project_slug: project.slug,
- threshold_key,
- threshold_value,
- }
- );
- }}
- >
- <Access access={requiredScopes} project={project}>
- {({hasAccess}) => (
- <div id={projectDetectorSettingsId}>
- <StyledPanelHeader>
- {t('Performance Issues - Detector Threshold Settings')}
- </StyledPanelHeader>
- <StyledJsonForm
- forms={this.project_owner_detector_settings(hasAccess)}
- collapsible
- />
- <StyledPanelFooter>
- <Actions>
- <Confirm
- message={t(
- 'Are you sure you wish to reset all detector thresholds?'
- )}
- onConfirm={() => this.handleThresholdsReset()}
- disabled={!hasAccess || this.areAllConfigurationsDisabled}
- >
- <Button>{t('Reset All Thresholds')}</Button>
- </Confirm>
- </Actions>
- </StyledPanelFooter>
- </div>
- )}
- </Access>
- </Form>
- </Fragment>
- </Fragment>
- );
- }
- }
- const Actions = styled(PanelItem)`
- justify-content: flex-end;
- `;
- const StyledPanelHeader = styled(PanelHeader)`
- border: 1px solid ${p => p.theme.border};
- border-bottom: none;
- `;
- const StyledJsonForm = styled(JsonForm)`
- ${Panel} {
- margin-bottom: 0;
- border-radius: 0;
- border-bottom: 0;
- }
- ${FieldWrapper} {
- border-top: 1px solid ${p => p.theme.border};
- }
- ${FieldWrapper} + ${FieldWrapper} {
- border-top: 0;
- }
- ${Panel} + ${Panel} {
- border-top: 1px solid ${p => p.theme.border};
- }
- ${PanelHeader} {
- border-bottom: 0;
- text-transform: none;
- margin-bottom: 0;
- background: none;
- padding: ${space(3)} ${space(2)};
- }
- `;
- const StyledPanelFooter = styled(PanelFooter)`
- background: ${p => p.theme.background};
- border: 1px solid ${p => p.theme.border};
- border-radius: 0 0 calc(${p => p.theme.panelBorderRadius} - 1px)
- calc(${p => p.theme.panelBorderRadius} - 1px);
- ${Actions} {
- padding: ${space(1.5)};
- }
- `;
- const LoadingIndicatorContainer = styled('div')`
- margin: 18px 18px 0;
- `;
- export default ProjectPerformance;
|