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(user_report): Treat UserReport like standalone attachment #2984

Merged
merged 6 commits into from
Jan 23, 2024

Conversation

olksdr
Copy link
Contributor

@olksdr olksdr commented Jan 23, 2024

If the user reports are send in separate envelope from the event, we treat it like a standalone attachment.

  • changed the processing grouping
  • added few tests to verify the behaviour
  • client reports are in separate processing group, since they do not require any events

fix: #2980

@olksdr olksdr requested a review from jan-auer January 23, 2024 07:58
@olksdr olksdr self-assigned this Jan 23, 2024
@olksdr olksdr requested a review from a team as a code owner January 23, 2024 07:58
@olksdr olksdr changed the title fix(user_report): Treat UserReport like standalone attachemnt fix(user_report): Treat UserReport like standalone attachment Jan 23, 2024
@@ -110,10 +110,11 @@ pub enum ProcessingGroup {
Error,
/// Session events.
Session,
/// Attachments which can be sent alone without any event attached to it in the current
/// Attachments (including UserReports) which can be sent alone without any event attached to it in the current
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to have a separate group of StandaloneUserReport?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The user reports are sent to the attachment kafka topic as well, and from what I understood we treat them like attachments, so the group name kind of reflects the purpose, I think.

But maybe @jan-auer correct me here and provide a little bit more context here.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense 👍

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should simply rename this group. This is a group of standalone items that belong to events. Not sure what the best concise name is, but effectively everything that has requires_event() = true while there's no event in the envelope has to go in there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done and renamed it to Standalone for now.

CHANGELOG.md Outdated
@@ -13,7 +13,7 @@

- Add automatic PII scrubbing to `logentry.params`. ([#2956](https://github.com/getsentry/relay/pull/2956))
- Avoid producing `null` values in metric data. These values were the result of Infinity or NaN values extracted from event data. The values are now discarded during extraction. ([#2958](https://github.com/getsentry/relay/pull/2958))
- Process user reports in separate processing group. ([#2981](https://github.com/getsentry/relay/pull/2981))
- Add user reports to a correct processing group. ([#2981](https://github.com/getsentry/relay/pull/2981), [#2984](https://github.com/getsentry/relay/pull/2984))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "separate" seems more explicit than "correct", could we find another term to make the changelog a bit more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will think about this a bit hot to rephrase it.

// Note: only if there is no items in the envelope which can create events.
// Extract all standalone attachments and reports.
//
// Note: only if there is no items in the envelope which can create events, otherwise they
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Note: only if there is no items in the envelope which can create events, otherwise they
// Note: only if there are no items in the envelope which can create events, otherwise they


event_id = uuid.uuid1().hex

error_payload = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could benefit from a test where the error is dropped but not the user report, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's might be good, what condition do you have in mind for this to happen?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sending an incorrect error should be good enough; but alternatively, send an error that's filtered out by e.g. inbound filters. The user report should be consumed in both cases.

@@ -110,10 +110,11 @@ pub enum ProcessingGroup {
Error,
/// Session events.
Session,
/// Attachments which can be sent alone without any event attached to it in the current
/// Attachments (including UserReports) which can be sent alone without any event attached to it in the current
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should simply rename this group. This is a group of standalone items that belong to events. Not sure what the best concise name is, but effectively everything that has requires_event() = true while there's no event in the envelope has to go in there.

matches!(item.ty(), &ItemType::Attachment | &ItemType::FormData)
matches!(
item.ty(),
&ItemType::Attachment | &ItemType::FormData | &ItemType::UserReport
Copy link
Member

Choose a reason for hiding this comment

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

Can we replace this with requires_event to prevent future items missing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

/// envelope.
StandaloneAttachment,
UserReport,
/// Outcomes.
ClientReport,
Replay,
Copy link
Member

Choose a reason for hiding this comment

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

While we're at it, could we add docs to the remaining group variants and fix typos in the existing docs?

    /// Unknown item types will be forwarded upstream (to processing Relay), where we will
    /// decide what to do with it.
    ForwardUnknown,
    /// All the items in the envelope that could not be grouped.
    Ungrouped,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed I think 😄 thanks for pointing this out

@olksdr olksdr requested a review from jan-auer January 23, 2024 10:53
Copy link
Member

@jan-auer jan-auer left a comment

Choose a reason for hiding this comment

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

Looks good, thank you for applying the suggestions!

In a follow-up, we can clarify the semantics of creates_event and requires_event, and consider better alternatives to these functions. They do not live up to today's needs anymore.

@olksdr olksdr enabled auto-merge (squash) January 23, 2024 11:20
@olksdr olksdr merged commit c7e4281 into master Jan 23, 2024
20 checks passed
@olksdr olksdr deleted the fix/user-feedback branch January 23, 2024 11:23
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.

Relay User Report Envelope API is broken
4 participants