Conversation
|
@jjbayer @Dav1dde The PR has taken your input into account, namely to neither use I personally find one of the following options less verbose and easier to understand: or or or If you prefer to keep things the way they are in this PR, I'm happy to disagree and commit! |
| minidump_item.modify(|inner, records| { | ||
| let old = inner.attachment_body_size() as isize; | ||
| inner.set_payload(Minidump, payload); | ||
| let new = inner.attachment_body_size() as isize; | ||
| records.modify_by(DataCategory::Attachment, new - old); | ||
| }); |
There was a problem hiding this comment.
Several places with new - old. Would it be fine to just use lenient in these cases?
There was a problem hiding this comment.
I think so, but it might make sense to debug_assert that the new size is >= old size.
You could also call I would prefer if a Draft PR for the accounting change: #5919 |
|
I think the necessity for: envelope.merge_with(item, |envelope, item, records| {
if !has_event && item.creates_event() {
records.modify_by(DataCategory::Error, 1);
has_event = true;
}
envelope.add_item(item);
});highlights a complexity (maybe a flaw?) in our accounting logic. That an item in an envelope has a different meaning than standalone. So we need a solution to build up an envelope from individual items. I think hiding the accounting special case behind a function/facade makes sense. This is a bit of unexplored territory in Relay, so far we've only really taken things out of a My initial idea was to only go To be honest none of the solutions or things I can think of make me entirely happy. The thing I probably want to do least is add of this to the Maybe we need something different which allows us to build up managed instances piece by piece. Long story, I think what I'd go with here just to get this unblocked is one of these:
let envelope = Envelope::from_request(Some(path.event_id), meta);
let mut envelope = Managed::from_envelope(envelope, state.outcome_aggregator().clone());
let mut has_event = false;
for item in items {
envelope.merge_with(item, |envelope, item, records| {
if !has_event && item.creates_event() {
records.modify_by(DataCategory::Error, 1);
has_event = true;
}
envelope.add_item(item);
});
}This entire thing, hidden behind a facade.
Instead of having |
Wrap multipart items with
Managedso that outcomes are emitted when something goes wrong (i.e. when items get dropped).Fixes https://linear.app/getsentry/issue/RELAY-231/use-managed-in-multipart