Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(billing): Add profile chunks to usage stats page #81476

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,10 @@ tests/sentry/api/endpoints/test_organization_dashboard_widget_details.py @ge
/tests/snuba/search/ @getsentry/issues
## End of Issues

## Billing
/src/sentry/api/endpoints/check_am2_compatibility.py @getsentry/revenue
## Billing/Revenue
/src/sentry/api/endpoints/check_am2_compatibility.py @getsentry/revenue
/static/app/views/organizationStats @getsentry/revenue
## End of Billing/Revenue

## ML & AI
*autofix*.py @getsentry/machine-learning-ai
Expand Down
10 changes: 10 additions & 0 deletions static/app/constants/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,16 @@ export const DATA_CATEGORY_INFO = {
uid: 17,
isBilledCategory: false, // TODO(Continuous Profiling GA): make true for launch to show spend notification toggle
},
[DataCategoryExact.PROFILE_CHUNK]: {
name: DataCategoryExact.PROFILE_CHUNK,
apiName: 'profile_chunk',
plural: 'profileChunks',
displayName: 'profile chunk',
titleName: t('Profile Chunks'),
productName: t('Continuous Profiling'),
uid: 18,
isBilledCategory: false,
},
} as const satisfies Record<DataCategoryExact, DataCategoryInfo>;

// Special Search characters
Expand Down
1 change: 1 addition & 0 deletions static/app/types/core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export enum DataCategoryExact {
PROFILE_DURATION = 'profileDuration',
SPAN = 'span',
SPAN_INDEXED = 'span_indexed',
PROFILE_CHUNK = 'profileChunk',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are some of the values in this enum camel cased and others snake cased?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure. I used the same casing for PROFILE_DURATION = 'profileDuration',

}

export interface DataCategoryInfo {
Expand Down
14 changes: 13 additions & 1 deletion static/app/views/organizationStats/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ describe('OrganizationStats', function () {
expect(screen.getByRole('option', {name: 'Profile Hours'})).toBeInTheDocument();
// Should not show Profiles (transaction) option
expect(screen.queryByRole('option', {name: 'Profiles'})).not.toBeInTheDocument();
// Should not show Profile Chunks option
expect(
screen.queryByRole('option', {name: 'Profile Chunks'})
).not.toBeInTheDocument();
});

it('shows both profile hours and profiles categories with continuous-profiling feature', async () => {
Expand All @@ -454,6 +458,8 @@ describe('OrganizationStats', function () {
expect(screen.getByRole('option', {name: 'Profile Hours'})).toBeInTheDocument();
// Should show Profiles (transaction) option
expect(screen.queryByRole('option', {name: 'Profiles'})).toBeInTheDocument();
// Should show Profile Chunks option
expect(screen.getByRole('option', {name: 'Profile Chunks'})).toBeInTheDocument();
});

it('shows only profile duration category when both profiling features are enabled', async () => {
Expand All @@ -478,6 +484,8 @@ describe('OrganizationStats', function () {
expect(screen.getByRole('option', {name: 'Profile Hours'})).toBeInTheDocument();
// Should not show Profiles (transaction) option
expect(screen.queryByRole('option', {name: 'Profiles'})).not.toBeInTheDocument();
// Should show Profile Chunks option
expect(screen.getByRole('option', {name: 'Profile Chunks'})).toBeInTheDocument();
});

it('shows only Profiles category without profiling features', async () => {
Expand All @@ -493,10 +501,14 @@ describe('OrganizationStats', function () {

await userEvent.click(await screen.findByText('Category'));

// Should show Profile Hours option
// Should not show Profile Hours option
expect(screen.queryByRole('option', {name: 'Profile Hours'})).not.toBeInTheDocument();
// Should show Profiles (transaction) option
expect(screen.getByRole('option', {name: 'Profiles'})).toBeInTheDocument();
// Should not show Profile Chunks option
expect(
screen.queryByRole('option', {name: 'Profile Chunks'})
).not.toBeInTheDocument();
});
});

Expand Down
5 changes: 5 additions & 0 deletions static/app/views/organizationStats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ export class OrganizationStats extends Component<OrganizationStatsProps> {

const isSelfHostedErrorsOnly = ConfigStore.get('isSelfHostedErrorsOnly');

// Some data categories are not applicable to some subscription plans.
// So we filter them out depending on if the organization has the necessary features.
const options = CHART_OPTIONS_DATACATEGORY.filter(opt => {
if (isSelfHostedErrorsOnly) {
return opt.value === DATA_CATEGORY_INFO.error.plural;
Expand All @@ -264,6 +266,9 @@ export class OrganizationStats extends Component<OrganizationStatsProps> {
organization.features.includes('continuous-profiling')
);
}
if (DATA_CATEGORY_INFO.profileChunk.plural === opt.value) {
return organization.features.includes('continuous-profiling');
}
if (DATA_CATEGORY_INFO.profile.plural === opt.value) {
return !organization.features.includes('continuous-profiling-stats');
}
Expand Down
6 changes: 6 additions & 0 deletions static/app/views/organizationStats/usageChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ export const CHART_OPTIONS_DATACATEGORY: CategoryOption[] = [
disabled: false,
yAxisMinInterval: 100,
},
{
label: DATA_CATEGORY_INFO.profileChunk.titleName,
value: DATA_CATEGORY_INFO.profileChunk.plural,
disabled: false,
yAxisMinInterval: 100,
},
];

export enum ChartDataTransform {
Expand Down
Loading