Skip to content

Commit

Permalink
Merge branch 'master' into ref/split-envelopes
Browse files Browse the repository at this point in the history
* master:
  fix(envelope): Detect attachments that create events (#609)
  ref(server): Allow formatting in the if_processing! macro (#611)
  • Loading branch information
jan-auer committed Jun 8, 2020
2 parents c59a216 + 783cfc9 commit c610010
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ We have switched to [CalVer](https://calver.org/)! Relay's version is always in
- Invalid session payloads are now logged for SDK debugging. ([#584](https://github.com/getsentry/relay/pull/584), [#591](https://github.com/getsentry/relay/pull/591))
- Remove unused `rev` from project state. ([#586](https://github.com/getsentry/relay/pull/586))
- Add an outcome endpoint for trusted Relays. ([#589](https://github.com/getsentry/relay/pull/589))
- Emit outcomes for event payloads submitted in attachment files. ([#609](https://github.com/getsentry/relay/pull/609))

## 0.5.9

Expand Down
28 changes: 14 additions & 14 deletions relay-server/src/actors/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,9 @@ impl EventProcessor {
} = message;

macro_rules! if_processing {
($($tt:tt)*) => {
($block:block) => {
#[cfg(feature = "processing")] {
if self.config.processing_enabled() {
$($tt)*
}
if self.config.processing_enabled() $block
}
};
}
Expand Down Expand Up @@ -637,12 +635,12 @@ impl EventProcessor {
// fast. For envelopes containing an Unreal request, we will look into the unreal item and
// expand it so it can be consumed like any other event (e.g. `__sentry-event`). External
// Relays should leave this as-is.
if_processing! {
if_processing!({
if let Some(item) = envelope.take_item_by(|item| item.ty() == ItemType::UnrealReport) {
utils::expand_unreal_envelope(item, &mut envelope)
.map_err(ProcessingError::InvalidUnrealReport)?;
}
}
});

// Carry metrics on event sizes through the entire normalization process. Without
// processing, this value is unused and will be optimized away. Note how we need to extract
Expand All @@ -663,7 +661,7 @@ impl EventProcessor {
return Err(ProcessingError::DuplicateItem(duplicate.ty()));
}

if_processing! {
if_processing!({
// This envelope may contain UE4 crash report information, which needs to be patched on
// the event returned from `extract_event`.
utils::process_unreal_envelope(&mut event, &mut envelope)
Expand All @@ -673,26 +671,28 @@ impl EventProcessor {
// event. This indicates to the pipeline that the event needs special processing.
let minidump_attachment = envelope
.get_item_by(|item| item.attachment_type() == Some(AttachmentType::Minidump));
let apple_crash_report_attachment = envelope
.get_item_by(|item| item.attachment_type() == Some(AttachmentType::AppleCrashReport));
let apple_crash_report_attachment = envelope.get_item_by(|item| {
item.attachment_type() == Some(AttachmentType::AppleCrashReport)
});

if let Some(item) = minidump_attachment {
_metrics.bytes_ingested_event_minidump = Annotated::new(item.len() as u64);
self.write_native_placeholder(&mut event, true);
} else if let Some(item) = apple_crash_report_attachment {
} else if let Some(item) = apple_crash_report_attachment {
_metrics.bytes_ingested_event_applecrashreport = Annotated::new(item.len() as u64);
self.write_native_placeholder(&mut event, false);
}

let attachment_size = envelope.items()
let attachment_size = envelope
.items()
.filter(|item| item.attachment_type() == Some(AttachmentType::Attachment))
.map(|item| item.len())
.sum::<usize>();

if attachment_size > 0 {
_metrics.bytes_ingested_event_attachment = Annotated::new(attachment_size as u64);
}
}
});

if let Some(event) = event.value_mut() {
// Event id is set statically in the ingest path.
Expand Down Expand Up @@ -724,7 +724,7 @@ impl EventProcessor {
self.fast_process_event(&mut event, &envelope, start_time)?;
}
// else
if_processing! {
if_processing!({
self.store_process_event(&mut event, &envelope, &project_state, start_time)?;

if let Some(event) = event.value_mut() {
Expand All @@ -734,7 +734,7 @@ impl EventProcessor {
// during processing is overwritten at last.
event._metrics = Annotated::new(_metrics);
}
}
});

// Run PII stripping last since normalization can add PII (e.g. IP addresses).
metric!(timer(RelayTimers::EventProcessingPii), {
Expand Down
18 changes: 12 additions & 6 deletions relay-server/src/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,21 @@ impl Item {
| ItemType::SecurityReport
| ItemType::UnrealReport => true,

// Attachments are only event items if they are crash reports.
// Attachments are only event items if they are crash reports or if they carry partial
// event payloads. Plain attachments never create event payloads.
ItemType::Attachment => match self.attachment_type().unwrap_or_default() {
AttachmentType::AppleCrashReport | AttachmentType::Minidump => true,
_ => false,
AttachmentType::AppleCrashReport
| AttachmentType::Minidump
| AttachmentType::EventPayload
| AttachmentType::Breadcrumbs => true,
AttachmentType::Attachment
| AttachmentType::UnrealContext
| AttachmentType::UnrealLogs => false,
},

// Form data items may contain partial event payloads, but those are only ever valid if they
// occur together with an explicit event item, such as a minidump or apple crash report. For
// this reason, FormData alone does not constitute an event item.
// Form data items may contain partial event payloads, but those are only ever valid if
// they occur together with an explicit event item, such as a minidump or apple crash
// report. For this reason, FormData alone does not constitute an event item.
ItemType::FormData => false,

// The remaining item types cannot carry event payloads.
Expand Down

0 comments on commit c610010

Please sign in to comment.