-
Notifications
You must be signed in to change notification settings - Fork 94
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): add recordings payload ItemType #1236
Conversation
relay-server/src/utils/multipart.rs
Outdated
@@ -218,7 +220,12 @@ fn consume_item( | |||
let file_name = content_disposition.as_ref().and_then(|d| d.get_filename()); | |||
|
|||
if let Some(file_name) = file_name { | |||
let mut item = Item::new(ItemType::Attachment); | |||
let item_type = match file_name { | |||
REPLAY_RECORDING_FILENAME => ItemType::ReplayRecording, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should only ever be 1 replay attachment per envelope, not sure if we should take that into account here / other parts where it can accept N.
We could also make replay recording uploads a separate endpoint altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this you could return true
from is_duplicate
. What's the reason behind this constraint? It could be beneficial for clients with offline caching to send several replay payloads in a single envelope.
assert message.error() is None | ||
|
||
v = msgpack.unpackb(message.value(), raw=False, use_list=False) | ||
assert v["type"] == "attachment_chunk", v["type"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would probably want to have this type be replay_chunk
for cleanliness sake, as well as attachment_type be something else, but for now i don't think these matter.
40aed88
to
b45dea2
Compare
b45dea2
to
f5c7942
Compare
f5c7942
to
b910e80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, initial review attached. We had two general thoughts when reading through this change:
- Right now, this PR does not add any rate limiting capabilities and also does not track data categories. This is perfectly fine for the initial implementation. Once you want to check for rate limits or track outcomes, you'll also have to add a new
DataCategory
. - Since this is experimental, it would be good to add a feature flag that allows us to disable and drop replays. For an example of how to do this, see
process_profiling
:
relay/relay-server/src/actors/envelopes.rs
Lines 975 to 976 in 604fe06
fn process_profiles(&self, state: &mut ProcessEnvelopeState) { | |
let profiling_enabled = state.project_state.has_feature(Feature::Profiling); |
relay-config/src/config.rs
Outdated
@@ -830,6 +835,7 @@ impl Default for TopicAssignments { | |||
sessions: "ingest-sessions".to_owned().into(), | |||
metrics: "ingest-metrics".to_owned().into(), | |||
profiles: "profiles".to_owned().into(), | |||
replay_payloads: "ingest-replay-payloads".to_owned().into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before deploying, please ensure the topic is provisioned in the broker.
relay-server/src/utils/sizes.rs
Outdated
@@ -27,7 +27,7 @@ pub fn check_envelope_size_limits(config: &Config, envelope: &Envelope) -> bool | |||
| ItemType::Security | |||
| ItemType::RawSecurity | |||
| ItemType::FormData => event_size += item.len(), | |||
ItemType::Attachment | ItemType::UnrealReport => { | |||
ItemType::Attachment | ItemType::UnrealReport | ItemType::ReplayPayload => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since replays will become their own thing (including for rate limiting), consider having separate limits for them. This relates to one of the comments in the store actor, since you may want to have smaller limits per replay item (such as 1MB). The limit for attachments is at 100MB right now.
|
||
// This skips chunks for empty replay recordings. The consumer does not require chunks for | ||
// empty replay recordings. `chunks` will be `0` in this case. | ||
while offset < size { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these bits are copied from the attachment chunks produce function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for calling this out. For now this is totally fine, once we have a third use case, we can still generalize the chunking implementation.
e35ea6c
to
73845e0
Compare
relay-server/src/actors/store.rs
Outdated
|
||
Ok(ChunkedAttachment { | ||
id, | ||
name: REPLAY_RECORDINGS_ATTACHMENT_NAME.to_owned(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't forsee a use for the name
field for us, but didn't seem worth defining our own type just to remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping some constant name here is a good solution to distinguish the message contents in other places 👍
If all you need here are id
, chunks
, and size
, then you can also add those fields directly to your ReplayRecordingKafkaMessage
, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just went ahead and defined a separate type with just these 3 fields 👍🏼
alright ready for re-review. added comments where i had questions / thoughts. only other thing is if using |
hmm not sure why the integration test is failing, passes on my machine. |
73845e0
to
3e3882c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the thorough work and applying all feedback. This looks good and is ready to merge from my end. See minor stylistic comments below.
relay-server/src/actors/store.rs
Outdated
|
||
Ok(ChunkedAttachment { | ||
id, | ||
name: REPLAY_RECORDINGS_ATTACHMENT_NAME.to_owned(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping some constant name here is a good solution to distinguish the message contents in other places 👍
If all you need here are id
, chunks
, and size
, then you can also add those fields directly to your ReplayRecordingKafkaMessage
, though.
|
||
// This skips chunks for empty replay recordings. The consumer does not require chunks for | ||
// empty replay recordings. `chunks` will be `0` in this case. | ||
while offset < size { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for calling this out. For now this is totally fine, once we have a third use case, we can still generalize the chunking implementation.
* master: ref(metrics): Stop logging relative bucket size (#1302) fix(metrics): Rename misnamed aggregator option (#1298) fix(server): Avoid a panic in the Sentry middleware (#1301) build: Update dependencies with known vulnerabilities (#1294) fix(metrics): Stop logging statsd metric per project key (#1295) feat(metrics): Limits on bucketing cost in aggregator [INGEST-1132] (#1287) fix(metrics): Track memory footprint more accurately (#1288) build(deps): Bump dependencies (#1293) feat(aws): Add relay-aws-extension crate which implements AWS extension as an actor (#1277) fix(meta): Update codeowners for the release actions (#1286) feat(metrics): Track memory footprint of metrics buckets (#1284)
See the spec here for more background information:
https://www.notion.so/sentry/Session-Replay-V1-alpha-Ingest-Backend-ae068d1e1d514221b6c3ea2233f360f4
By submitting this pull request, I confirm that Sentry can use, modify, copy, and redistribute this contribution, under Sentry's choice of terms.