Skip to content
Merged
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
1 change: 0 additions & 1 deletion static/app/components/scoreCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ type ScoreCardProps = {
title: React.ReactNode;
className?: string;
help?: React.ReactNode;
isEstimate?: boolean;
isTooltipHoverable?: boolean;
renderOpenButton?: () => React.ReactNode;
score?: React.ReactNode;
Expand Down
23 changes: 0 additions & 23 deletions static/app/views/organizationStats/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ describe('OrganizationStats', () => {
expect(screen.getAllByText('Invalid')[0]).toBeInTheDocument();
expect(screen.getAllByText('15')[0]).toBeInTheDocument();

expect(
screen.queryByText('*This is an estimation, and may not be 100% accurate.')
).not.toBeInTheDocument();

// Correct API Calls
const mockExpectations = {
UsageStatsOrg: {
Expand Down Expand Up @@ -528,25 +524,6 @@ describe('OrganizationStats', () => {
).toBeInTheDocument();
});

it('shows estimation text when profile duration category is selected', async () => {
const newOrg = OrganizationFixture({
features: ['team-insights', 'continuous-profiling-stats', 'continuous-profiling'],
});

render(<OrganizationStats />, {
organization: newOrg,
initialRouterConfig: {
location: {
pathname: '/organizations/org-slug/stats/',
query: {dataCategory: DATA_CATEGORY_INFO.profile_duration.plural},
},
},
});
expect(
await screen.findByText('*This is an estimation, and may not be 100% accurate.')
).toBeInTheDocument();
});

it('denies access without project membership', async () => {
const newOrg = OrganizationFixture({
openMembership: false,
Expand Down
45 changes: 3 additions & 42 deletions static/app/views/organizationStats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import moment from 'moment-timezone';

import type {DateTimeObject} from 'sentry/components/charts/utils';
import {CompactSelect} from 'sentry/components/core/compactSelect';
import {ExternalLink} from 'sentry/components/core/link';
import ErrorBoundary from 'sentry/components/errorBoundary';
import HookOrDefault from 'sentry/components/hookOrDefault';
import * as Layout from 'sentry/components/layouts/thirds';
Expand All @@ -19,15 +18,10 @@ import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilte
import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
import {DATA_CATEGORY_INFO, DEFAULT_STATS_PERIOD} from 'sentry/constants';
import {t, tct} from 'sentry/locale';
import {t} from 'sentry/locale';
import ConfigStore from 'sentry/stores/configStore';
import {space} from 'sentry/styles/space';
import {
DataCategory,
DataCategoryExact,
type DataCategoryInfo,
type PageFilters,
} from 'sentry/types/core';
import {DataCategory, type DataCategoryInfo, type PageFilters} from 'sentry/types/core';
import type {Organization} from 'sentry/types/organization';
import type {Project} from 'sentry/types/project';
import {decodeScalar} from 'sentry/utils/queryString';
Expand All @@ -39,7 +33,6 @@ import {canUseMetricsStatsUI} from 'sentry/views/explore/metrics/metricsFlags';
import HeaderTabs from 'sentry/views/organizationStats/header';
import {getPerformanceBaseUrl} from 'sentry/views/performance/utils';
import {makeProjectsPathname} from 'sentry/views/projects/pathname';
import {getPricingDocsLinkForEventType} from 'sentry/views/settings/account/notifications/utils';
import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';

import type {ChartDataTransform} from './usageChart';
Expand Down Expand Up @@ -335,29 +328,6 @@ export class OrganizationStatsInner extends Component<OrganizationStatsProps> {
);
}

renderEstimationDisclaimer() {
if (
this.dataCategory === DATA_CATEGORY_INFO.profile_duration.plural ||
this.dataCategory === DATA_CATEGORY_INFO.profile_duration_ui.plural
) {
return (
<EstimationText data-test-id="estimation-text">
{tct(
'*This is an estimation, and may not be 100% accurate. [estimateLink: How we calculate estimated usage]',
{
estimateLink: (
<ExternalLink
href={`${getPricingDocsLinkForEventType(DataCategoryExact.PROFILE_DURATION)}#how-can-i-estimate-usage-for-continuous-profiling-on-the-backend`}
/>
),
}
)}
</EstimationText>
);
}
return null;
}

render() {
const {organization} = this.props;
const hasTeamInsights = organization.features.includes('team-insights');
Expand All @@ -384,10 +354,7 @@ export class OrganizationStatsInner extends Component<OrganizationStatsProps> {
<div>
<Layout.Main width="full">
<HookHeader organization={organization} />
<ControlsWrapper>
{this.renderProjectPageControl()}
{this.renderEstimationDisclaimer()}
</ControlsWrapper>
<ControlsWrapper>{this.renderProjectPageControl()}</ControlsWrapper>
{showProfilingBanner && <HookOrgStatsProfilingBanner />}
<div>
<ErrorBoundary mini>{this.renderUsageStatsOrg()}</ErrorBoundary>
Expand Down Expand Up @@ -470,9 +437,3 @@ const PageControl = styled('div')`
grid-template-columns: minmax(0, 1fr);
}
`;

const EstimationText = styled('div')`
color: ${p => p.theme.subText};
font-size: ${p => p.theme.fontSize.sm};
line-height: ${p => p.theme.text.lineHeightBody};
`;
137 changes: 0 additions & 137 deletions static/app/views/organizationStats/mapSeriesToChart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,141 +251,4 @@ describe('mapSeriesToChart func', () => {
// should format client discard data correctly
expect(mappedSeries.cardStats.clientDiscard).toBe('1.5K');
});

it('should correctly sum up the profile chunks', () => {
const mappedSeries = mapSeriesToChart({
orgStats: {
start: '2021-01-01T00:00:00Z',
end: '2021-01-07T00:00:00Z',
intervals: ['2021-01-01T00:00:00Z', '2021-01-02T00:00:00Z'],
groups: [
{
by: {
outcome: 'invalid',
reason: 'bad',
category: 'profile_chunk',
},
totals: {
'sum(quantity)': 10,
},
series: {
'sum(quantity)': [1, 2],
},
},
{
by: {
outcome: 'accepted',
reason: 'good',
category: 'profile_chunk',
},
totals: {
'sum(quantity)': 10,
},
series: {
'sum(quantity)': [3, 4],
},
},
{
by: {
outcome: 'accepted',
reason: 'good',
category: 'profile_duration',
},
totals: {
'sum(quantity)': 10,
},
series: {
'sum(quantity)': [1, 2],
},
},
],
},
chartDateInterval: '1h',
chartDateUtc: true,
dataCategory: DataCategory.PROFILE_DURATION,
endpointQuery: {},
});

// multiplies dropped profile chunks by 9000
expect(mappedSeries.chartStats.invalid).toEqual([
{value: ['Jan 1 12:00 AM - 1:00 AM (+00:00)', 9000]},
{value: ['Jan 2 12:00 AM - 1:00 AM (+00:00)', 18000]},
]);

// does not add accepted profile chunks to accepted profile duration
expect(mappedSeries.chartStats.accepted).toEqual([
{value: ['Jan 1 12:00 AM - 1:00 AM (+00:00)', 1]},
{value: ['Jan 2 12:00 AM - 1:00 AM (+00:00)', 2]},
]);
});

it('should correctly sum up the profiles', () => {
const groups = [
{
by: {
outcome: 'invalid',
reason: 'bad',
category: 'profile',
},
totals: {
'sum(quantity)': 10,
},
series: {
'sum(quantity)': [1, 2],
},
},
{
by: {
outcome: 'accepted',
reason: 'good',
category: 'profile',
},
totals: {
'sum(quantity)': 10,
},
series: {
'sum(quantity)': [3, 4],
},
},
{
by: {
outcome: 'accepted',
reason: 'good',
category: 'profile_duration',
},
totals: {
'sum(quantity)': 10,
},
series: {
'sum(quantity)': [1, 2],
},
},
];

const mappedSeries = mapSeriesToChart({
orgStats: {
start: '2021-01-01T00:00:00Z',
end: '2021-01-07T00:00:00Z',
intervals: ['2021-01-01T00:00:00Z', '2021-01-02T00:00:00Z'],
groups,
},
chartDateInterval: '1h',
chartDateUtc: true,
dataCategory: DataCategory.PROFILE_DURATION,
shouldEstimateDroppedProfiles: true,
endpointQuery: {},
});

// multiplies dropped profiles by 9000
expect(mappedSeries.chartStats.invalid).toEqual([
{value: ['Jan 1 12:00 AM - 1:00 AM (+00:00)', 9000]},
{value: ['Jan 2 12:00 AM - 1:00 AM (+00:00)', 18000]},
]);

// does not add accepted profiles to accepted profile duration
expect(mappedSeries.chartStats.accepted).toEqual([
{value: ['Jan 1 12:00 AM - 1:00 AM (+00:00)', 1]},
{value: ['Jan 2 12:00 AM - 1:00 AM (+00:00)', 2]},
]);
});
});
31 changes: 2 additions & 29 deletions static/app/views/organizationStats/mapSeriesToChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,18 @@ import type {ChartStats} from './usageChart';
import {SeriesTypes} from './usageChart';
import {formatUsageWithUnits, getFormatUsageOptions} from './utils';

// used for estimated dropped continuous profile hours and ui profile hours from profile chunks and profile chunks ui
export function droppedProfileChunkMultiplier(
category: number | string | undefined,
outcome: number | string | undefined,
shouldEstimateDroppedProfiles?: boolean
) {
if (
category === 'profile_chunk' ||
category === 'profile_chunk_ui' ||
(shouldEstimateDroppedProfiles && category === 'profile')
) {
if (outcome === Outcome.ACCEPTED) {
return 0;
}
return 9000;
}
return 1;
}

export function mapSeriesToChart({
orgStats,
dataCategory,
chartDateUtc,
endpointQuery,
chartDateInterval,
shouldEstimateDroppedProfiles = false,
}: {
chartDateInterval: IntervalPeriod;
chartDateUtc: boolean;
dataCategory: DataCategory;
endpointQuery: Record<string, unknown>;
orgStats?: UsageSeries;
shouldEstimateDroppedProfiles?: boolean;
}): {
cardStats: {
accepted?: string;
Expand Down Expand Up @@ -124,13 +103,10 @@ export function mapSeriesToChart({
countAcceptedStored += group.totals['sum(quantity)']!;
}
} else {
const value =
group.totals['sum(quantity)']! *
droppedProfileChunkMultiplier(category, outcome, shouldEstimateDroppedProfiles);
if (outcome !== Outcome.CLIENT_DISCARD) {
count.total += value;
count.total += group.totals['sum(quantity)']!;
}
(count as any)[outcome!] += value;
(count as any)[outcome!] += group.totals['sum(quantity)']!;
}

if (category === 'span_indexed' && outcome !== Outcome.ACCEPTED) {
Expand All @@ -139,9 +115,6 @@ export function mapSeriesToChart({
}

group.series['sum(quantity)']!.forEach((stat, i) => {
stat =
stat *
droppedProfileChunkMultiplier(category, outcome, shouldEstimateDroppedProfiles);
const dataObject = {name: orgStats.intervals[i]!, value: stat};

const strigfiedReason = String(group.by.reason ?? '');
Expand Down
Loading
Loading