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

fix(stats): include abuse outcomes in total dropped #49437

Closed
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: 1 addition & 0 deletions static/app/types/core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export enum Outcome {
DROPPED = 'dropped', // this is not a real outcome coming from the server
RATE_LIMITED = 'rate_limited',
CLIENT_DISCARD = 'client_discard',
ABUSE = 'abuse',
}

export type IntervalPeriod = ReturnType<typeof getInterval>;
Expand Down
17 changes: 15 additions & 2 deletions static/app/views/organizationStats/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('OrganizationStats', function () {

// Render the cards
expect(screen.getAllByText('Total')[0]).toBeInTheDocument();
expect(screen.getByText('64')).toBeInTheDocument();
expect(screen.getByText('80')).toBeInTheDocument();

expect(screen.getAllByText('Accepted')[0]).toBeInTheDocument();
expect(screen.getByText('28')).toBeInTheDocument();
Expand All @@ -103,7 +103,7 @@ describe('OrganizationStats', function () {
expect(screen.getAllByText('7')[0]).toBeInTheDocument();

expect(screen.getAllByText('Dropped')[0]).toBeInTheDocument();
expect(screen.getAllByText('29')[0]).toBeInTheDocument();
expect(screen.getAllByText('45')[0]).toBeInTheDocument();

// Correct API Calls
const mockExpectations = {
Expand Down Expand Up @@ -484,5 +484,18 @@ const mockStatsResponse = {
'sum(quantity)': [2, 2, 2, 2, 2, 2, 3],
},
},
{
by: {
project: 1,
category: 'error',
outcome: 'abuse',
},
totals: {
'sum(quantity)': 16,
},
series: {
'sum(quantity)': [2, 2, 2, 2, 2, 3, 3],
},
},
],
};
5 changes: 4 additions & 1 deletion static/app/views/organizationStats/usageStatsOrg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ class UsageStatsOrganization<
[Outcome.FILTERED]: 0,
[Outcome.DROPPED]: 0,
[Outcome.INVALID]: 0, // Combined with dropped later
[Outcome.ABUSE]: 0, // Combined with dropped later
[Outcome.RATE_LIMITED]: 0, // Combined with dropped later
[Outcome.CLIENT_DISCARD]: 0, // Not exposed yet
};
Expand All @@ -372,6 +373,7 @@ class UsageStatsOrganization<
case Outcome.DROPPED:
case Outcome.RATE_LIMITED:
case Outcome.INVALID:
case Outcome.ABUSE:
usageStats[i].dropped.total += stat;
// TODO: add client discards to dropped?
return;
Expand All @@ -381,9 +383,10 @@ class UsageStatsOrganization<
});
});

// Invalid and rate_limited data is combined with dropped
// Invalid, rate_limited data, and abused is combined with dropped
count[Outcome.DROPPED] += count[Outcome.INVALID];
count[Outcome.DROPPED] += count[Outcome.RATE_LIMITED];
count[Outcome.DROPPED] += count[Outcome.ABUSE];

usageStats.forEach(stat => {
stat.total = stat.accepted + stat.filtered + stat.dropped.total;
Expand Down