Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ describe('getReasonGroupName', () => {

expect(getReasonGroupName(Outcome.RATE_LIMITED, 'key_quota')).toBe('DSN limit');
expect(getReasonGroupName(Outcome.RATE_LIMITED, 'org_quota')).toBe('global limit');
expect(getReasonGroupName(Outcome.RATE_LIMITED, 'project_category_pause')).toBe(
'Pause (solutions.sentry.io)'
);
expect(getReasonGroupName(Outcome.RATE_LIMITED, 'organization_pause')).toBe(
'Org Pause (solutions.sentry.io)'
);

expect(getReasonGroupName(Outcome.FILTERED, 'browser-extensions')).toBe(
'Browser Extensions'
Expand Down
15 changes: 15 additions & 0 deletions static/app/views/organizationStats/getReasonGroupName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,19 @@ enum RateLimitedReason {
PROJECT_ABUSE_LIMIT = 'project_abuse_limit',
ORG_ABUSE_LIMIT = 'org_abuse_limit',
GLOBAL_ABUSE_LIMIT = 'global_abuse_limit',
PROJECT_CATEGORY_PAUSE = 'project_category_pause',
ORGANIZATION_PAUSE = 'organization_pause',
}

const PROJECT_CATEGORY_PAUSE_NAME = 'Pause (solutions.sentry.io)';
const ORGANIZATION_PAUSE_NAME = 'Org Pause (solutions.sentry.io)';

// Group names that are shown as written, without title case.
export const VERBATIM_REASON_GROUP_NAMES = new Set([
PROJECT_CATEGORY_PAUSE_NAME,
ORGANIZATION_PAUSE_NAME,
]);

// Invalid reasons should not be exposed directly, but instead in the following groups:
const invalidReasonsGroup: Record<string, DiscardReason[]> = {
duplicate: [DiscardReason.DUPLICATE],
Expand Down Expand Up @@ -225,6 +236,10 @@ function getRateLimitedReasonGroupName(reason: RateLimitedReason | string): stri
case RateLimitedReason.SPIKE_PROTECTION:
case RateLimitedReason.SMART_RATE_LIMIT:
return 'spike protection';
case RateLimitedReason.PROJECT_CATEGORY_PAUSE:
return PROJECT_CATEGORY_PAUSE_NAME;
case RateLimitedReason.ORGANIZATION_PAUSE:
return ORGANIZATION_PAUSE_NAME;
case RateLimitedReason.PROJECT_ABUSE_LIMIT:
return 'project abuse limit';
case RateLimitedReason.ORG_ABUSE_LIMIT:
Expand Down
31 changes: 31 additions & 0 deletions static/app/views/organizationStats/mapSeriesToChart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,37 @@ describe('mapSeriesToChart func', () => {
expect(mappedSeries.cardStats.rateLimited).toBe('11');
});

it('shows pause reasons as written', () => {
const mappedSeries = mapSeriesToChart({
orgStats: {
start: '2021-01-01T00:00:00Z',
end: '2021-01-07T00:00:00Z',
intervals: ['2021-01-01T00:00:00Z'],
groups: [
{
by: {outcome: 'rate_limited', reason: 'project_category_pause'},
totals: {'sum(quantity)': 1},
series: {'sum(quantity)': [1]},
},
{
by: {outcome: 'rate_limited', reason: 'organization_pause'},
totals: {'sum(quantity)': 2},
series: {'sum(quantity)': [2]},
},
],
},
chartDateInterval: '1h',
chartDateUtc: true,
dataCategory: DataCategory.ERRORS,
endpointQuery: {},
});

expect(mappedSeries.chartSubLabels.map(subLabel => subLabel.label)).toEqual([
'Pause (solutions.sentry.io)',
'Org Pause (solutions.sentry.io)',
]);
});

it('excludes no_parent_span from client discard data', () => {
const mappedSeries = mapSeriesToChart({
orgStats: {
Expand Down
6 changes: 4 additions & 2 deletions static/app/views/organizationStats/mapSeriesToChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {DataCategory, IntervalPeriod} from 'sentry/types/core';
import {Outcome} from 'sentry/types/core';

import {getDateFromMoment} from './usageChart/utils';
import {getReasonGroupName} from './getReasonGroupName';
import {getReasonGroupName, VERBATIM_REASON_GROUP_NAMES} from './getReasonGroupName';
import type {UsageSeries, UsageStat} from './types';
import type {ChartStats} from './usageChart';
import {SeriesTypes} from './usageChart';
Expand Down Expand Up @@ -127,7 +127,9 @@ export function mapSeriesToChart({
// Function to handle chart sub-label updates
const updateChartSubLabels = (
parentLabel: SeriesTypes,
label = startCase(reason.replace(/-|_/g, ' '))
label = VERBATIM_REASON_GROUP_NAMES.has(reason)
? reason
: startCase(reason.replace(/-|_/g, ' '))
) => {
const existingSubLabel = chartSubLabels.find(
subLabel => subLabel.label === label && subLabel.parentLabel === parentLabel
Expand Down
Loading