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(replays): Combined Envelope Items (reopen) #3035

Merged
merged 44 commits into from
Feb 15, 2024

Conversation

JoshFerge
Copy link
Member

@JoshFerge JoshFerge commented Jan 31, 2024

Reopening #2170

I've resolved merge conflicts, tests pass, and I believe comments from the previous PR have been addressed.

@JoshFerge JoshFerge changed the title feat(replays): feat(replays): Combined Envelope Items (reopen) Jan 31, 2024
@JoshFerge JoshFerge marked this pull request as ready for review January 31, 2024 23:17
@JoshFerge JoshFerge requested a review from a team as a code owner January 31, 2024 23:17
@JoshFerge JoshFerge requested a review from a team January 31, 2024 23:19
Copy link
Member

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

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

Is the goal of this PR purely to unite the two items in the kafka message? If so, I would not introduce a new item type, and implement the entire logic in the kafka producer (store.rs) instead.

If the goal is to send combined items from relay to relay (in a chain of relays), we need to add support for parsing a combined item and processing it correctly. Right now, I believe such an item would hit this branch and cause an error:

} else {
// Cannot group this item type.
ProcessingGroup::Ungrouped

CHANGELOG.md Outdated Show resolved Hide resolved
relay-dynamic-config/src/feature.rs Outdated Show resolved Hide resolved
relay-server/src/services/processor/replay.rs Outdated Show resolved Hide resolved
relay-server/src/services/processor/replay.rs Outdated Show resolved Hide resolved
relay-server/src/services/processor/replay.rs Outdated Show resolved Hide resolved
relay-server/src/services/processor/replay.rs Outdated Show resolved Hide resolved
tests/integration/test_replay_combined_payload.py Outdated Show resolved Hide resolved
@JoshFerge JoshFerge force-pushed the jferg/combine-replay-env-items branch from 8411b1d to 6f7433e Compare February 6, 2024 01:21
JoshFerge and others added 5 commits February 5, 2024 17:25
@JoshFerge
Copy link
Member Author

@jjbayer @cmanallen I've gone ahead and moved the logic to store -- now the change simply will look for the two replay items, and combine them if if finds them. A couple of questions to ponder:

  1. How should we handle this roll-out? If we are able to use project features in store here, I would love to try this on the Sentry project first. If we cannot do that, it seems like we'd have to do some kind of hard cutover.

My general idea here would be to:

  • Double produce, and simply log and ignore the messages with a replay_event on them in our consumer, and ensure that everything there is working correctly.

  • Remove the production of Combined Messages temporarily, let any combined messages drain out

  • Then do a hard cutover, where we change relay to produce combined messages instead of stand-alone replay recording messages.

  • (Note, we've decided we're still going to produce replay_events from relay, so only recording messages will be impacted)

If we are able to use project features in store here, that would be more ideal, and also open to suggestions, perhaps we could use S4S if its set up with replays? Any other ideas?

Copy link
Member

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

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

@JoshFerge in replay::process, you have access to project features. So in that function you could set an internal item header similar to this one, and check that item header in store_envelope.

Comment on lines 435 to 436
let mut replay_event_item = None;
let mut replay_recording_item = None;
Copy link
Member

Choose a reason for hiding this comment

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

nit: We could declare these variables in store_envelope, so we don't have to transform to and from a vector.

@@ -812,6 +834,63 @@ impl StoreService {
Ok(())
}

#[allow(clippy::too_many_arguments)]
Copy link
Member Author

Choose a reason for hiding this comment

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

not sure what to do about the too many args here

Copy link
Member

Choose a reason for hiding this comment

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

Instead of passing replay_event, replay_recording, and a boolean flag, the most idiomatic would probably be to pass an enum like

enum Data {
    Event(&Item),
    Recording(&Item),
    Combined { event: &Item, recording: &Item }
}

That would also make states like `(None, None, true)` impossible.

Copy link
Member

@cmanallen cmanallen left a comment

Choose a reason for hiding this comment

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

Whoops forgot to publish this review on Friday...

relay-server/src/services/store.rs Outdated Show resolved Hide resolved
@JoshFerge
Copy link
Member Author

@cmanallen @jjbayer should be good for final review.

JoshFerge added a commit to getsentry/sentry that referenced this pull request Feb 13, 2024
…64948)

Adds a feature flag for combining envelope items in relay -- will be
used in getsentry/relay#3035. getsentry handler
PR will be linked below.
relay-server/src/services/store.rs Outdated Show resolved Hide resolved
@@ -812,6 +834,63 @@ impl StoreService {
Ok(())
}

#[allow(clippy::too_many_arguments)]
Copy link
Member

Choose a reason for hiding this comment

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

Instead of passing replay_event, replay_recording, and a boolean flag, the most idiomatic would probably be to pass an enum like

enum Data {
    Event(&Item),
    Recording(&Item),
    Combined { event: &Item, recording: &Item }
}

That would also make states like `(None, None, true)` impossible.

@cmanallen
Copy link
Member

cmanallen commented Feb 15, 2024

@jjbayer @TBS1996 Josh is out for the rest of the week. I've updated the PR. Please provide final approval.

Note: replay_event is only populated if the combined envelope feature is enabled. This means we don't need to consider the combined envelope boolean in any other step. Null is always sent if the feature is disabled or if replay_event was not present in the envelope.

Note: the kafka payload size calculation was reconfigured. I'm using addition rather than subtraction. This is to avoid situations where the replay_event is larger than the maximum size of a recording. This would yield a negative number but since its of type usize the value wraps around and could give incorrect results. Addition suffers from similar wrap around problems however because we our server's do not have 18 exabits of RAM I feel safe in using this method.

Note: oversized recording messages will now produce an outcome with discard reason TooLarge.

@cmanallen cmanallen merged commit ac1ff14 into master Feb 15, 2024
20 checks passed
@cmanallen cmanallen deleted the jferg/combine-replay-env-items branch February 15, 2024 13:21
JoshFerge added a commit to getsentry/sentry that referenced this pull request Feb 23, 2024
…e click issues (#65307)

if the replay event exists, use that instead of querying clickhouse to
create a rage click issue.

related:#65291
#65298
getsentry/relay#3035
getsentry/sentry-kafka-schemas#213
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.

None yet

4 participants