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(stats): Add quantity to TrackOutcome and new attachment outcomes #942

Merged
merged 18 commits into from
Mar 16, 2021

Conversation

RyanSkonnord
Copy link
Contributor

@RyanSkonnord RyanSkonnord commented Mar 2, 2021

Add a quantity attribute to outcomes. For attachments, the quantity is
the total attachment size in bytes. For all other categories, the
quantity is the event count (by default, 1).

If a rejected envelope has attachments, emit a second outcome with the
attachment category in addition to the event outcome.

@RyanSkonnord RyanSkonnord requested a review from jan-auer March 3, 2021 00:43
@RyanSkonnord RyanSkonnord marked this pull request as ready for review March 3, 2021 00:43
@RyanSkonnord RyanSkonnord requested a review from a team March 3, 2021 00:43
Some(envelope) => {
envelope_summary.replace(EnvelopeSummary::compute(&envelope));
Ok(envelope)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this the latest place where we need to update the envelope summary?

(I love how it can be written like this in the Rust syntax, btw.)

Copy link
Member

Choose a reason for hiding this comment

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

Similar to the case in endpoints/common.rs, you'll have to make another update after calling ProcessEnvelope below once rate limiting can emit outcomes. For now, a comment will suffice.

Technically, that would also apply to the replace you added here. However, it is fine to do it in this instance. Prior to invoking the HandleEnvelope handler, we split envelopes into event-related and event-unrelated items.

@RyanSkonnord
Copy link
Contributor Author

I think the main code is good to move forward. The integration tests are passing but the new outcomes seem not to be exercised. I'm continuing to muddle around with that but let me know if you can suggest an easy addition.

@@ -446,6 +446,8 @@ where
Some(envelope) => envelope,
None => return Err(BadStoreRequest::RateLimited(checked.rate_limits)),
};
// TODO: Ensure that outcomes are emitted correctly for rate-limited attachments
// so that it is safe to update envelope_summary here.
Copy link
Member

Choose a reason for hiding this comment

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

Technically, we will have to update the envelope summary here. We chose not to do this just yet, until the rate limiting code inside CheckEnvelope can emit its own outcomes.

Some(envelope) => {
envelope_summary.replace(EnvelopeSummary::compute(&envelope));
Ok(envelope)
}
Copy link
Member

Choose a reason for hiding this comment

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

Similar to the case in endpoints/common.rs, you'll have to make another update after calling ProcessEnvelope below once rate limiting can emit outcomes. For now, a comment will suffice.

Technically, that would also apply to the replace you added here. However, it is fine to do it in this instance. Prior to invoking the HandleEnvelope handler, we split envelopes into event-related and event-unrelated items.

@@ -1483,12 +1483,13 @@ impl Handler<HandleEnvelope> for EventManager {

let scoping = Rc::new(RefCell::new(envelope.meta().get_partial_scoping()));
let is_received = Rc::new(AtomicBool::from(false));
let envelope_summary = Rc::new(RefCell::new(EnvelopeSummary::empty()));
Copy link
Member

Choose a reason for hiding this comment

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

You should be able to get rid of the event_category variable as a result of this, and use envelope_summary in the or_else error handler.

relay-server/src/actors/events.rs Show resolved Hide resolved
@RyanSkonnord
Copy link
Contributor Author

Integration tests are updated. Earlier failures in test_minidump demonstrate that the attachment outcomes are being exercised, which is nice, and they're now passing. Might also be nice to get coverage in test_outcome, though.

@jan-auer I think this is good to merge. 🤞 I've addressed all your inline comments and the behavior is correct AFAICT, but I await another check from you. I also took a pass at adding a changelog entry but I'm concerned the phrasing might be slightly wrong; please revise if so.

relay-server/src/envelope.rs Show resolved Hide resolved
@@ -464,11 +464,15 @@ def test_minidump_ratelimit(

# First minidump returns 200 but is rate limited in processing
relay.send_minidump(project_id=project_id, files=attachments)
outcomes_consumer.assert_rate_limited("static_disabled_quota", category="error")
outcomes_consumer.assert_rate_limited(
"static_disabled_quota", categories=["error", "attachment"]
Copy link
Member

Choose a reason for hiding this comment

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

This test unveils that there is a mismatch between what EnvelopeLimiter does and how we generate outcomes. I'll follow up with a more detailed description.

Copy link
Member

Choose a reason for hiding this comment

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

We will go with the current state and fine-tune this in the next stage.

@RyanSkonnord RyanSkonnord changed the title feat(stats): Emit second outcome for attachments when handling request feat(stats): Add quantity to TrackOutcome and new attachment outcomes Mar 11, 2021
@RyanSkonnord RyanSkonnord merged commit dacdb00 into master Mar 16, 2021
@RyanSkonnord RyanSkonnord deleted the add-track-outcome-quantity branch March 16, 2021 15:06
jan-auer added a commit that referenced this pull request Mar 16, 2021
* master:
  feat(stats): Add quantity to TrackOutcome and new attachment outcomes (#942)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants