Skip to content

Commit

Permalink
set defaults for recording attachment chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshFerge committed Jun 3, 2022
1 parent 88b7cb7 commit 73845e0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion relay-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ pub struct TopicAssignments {
pub metrics: TopicAssignment,
/// Stacktrace topic name
pub profiles: TopicAssignment,
/// Payloads topic name.
/// Recordings topic name.
pub replay_recordings: TopicAssignment,
}

Expand Down
2 changes: 1 addition & 1 deletion relay-server/src/actors/envelopes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ impl EnvelopeProcessor {
if !replays_enabled {
return false;
}
return true;
true
}
_ => true,
});
Expand Down
15 changes: 7 additions & 8 deletions relay-server/src/actors/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const MAX_EXPLODED_SESSIONS: usize = 100;
/// Fallback name used for attachment items without a `filename` header.
const UNNAMED_ATTACHMENT: &str = "Unnamed Attachment";

const REPLAY_RECORDINGS_ATTACHMENT_NAME: &str = "rr";

#[derive(Fail, Debug)]
pub enum StoreError {
#[fail(display = "failed to send kafka message")]
Expand Down Expand Up @@ -464,15 +466,15 @@ impl StoreForwarder {
let max_chunk_size = self.config.attachment_chunk_size();
let chunk_size = std::cmp::min(max_chunk_size, size - offset);

let attachment_message =
let replay_recording_chunk_message =
KafkaMessage::ReplayRecordingChunk(ReplayRecordingChunkKafkaMessage {
payload: payload.slice(offset, offset + chunk_size),
replay_id,
project_id,
id: id.clone(),
chunk_index,
});
self.produce(KafkaTopic::ReplayRecordings, attachment_message)?;
self.produce(KafkaTopic::ReplayRecordings, replay_recording_chunk_message)?;
offset += chunk_size;
chunk_index += 1;
}
Expand All @@ -482,10 +484,7 @@ impl StoreForwarder {

Ok(ChunkedAttachment {
id,
name: match item.filename() {
Some(name) => name.to_owned(),
None => UNNAMED_ATTACHMENT.to_owned(),
},
name: REPLAY_RECORDINGS_ATTACHMENT_NAME.to_owned(),
content_type: item
.content_type()
.map(|content_type| content_type.as_str().to_owned()),
Expand Down Expand Up @@ -637,7 +636,7 @@ struct ReplayRecordingKafkaMessage {
/// The project id for the current event.
project_id: ProjectId,
/// The recording.
recording: ChunkedAttachment,
replay_recording: ChunkedAttachment,
}

/// User report for an event wrapped up in a message ready for consumption in Kafka.
Expand Down Expand Up @@ -865,7 +864,7 @@ impl Handler<StoreEnvelope> for StoreForwarder {
KafkaMessage::ReplayRecording(ReplayRecordingKafkaMessage {
replay_id: event_id.ok_or(StoreError::NoEventId)?,
project_id: scoping.project_id,
recording: replay_recording,
replay_recording,
});

self.produce(KafkaTopic::ReplayRecordings, replay_recording_message)?;
Expand Down
8 changes: 5 additions & 3 deletions tests/integration/test_replay_recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def test_replay_recordings_processing(
replay_recordings_consumer = replay_recordings_consumer()
outcomes_consumer = outcomes_consumer()

envelope = Envelope(headers=[["event_id", replay_id]])
envelope = Envelope(
headers=[["event_id", replay_id,], ["attachment_type", "replay_recording"]]
)
envelope.add_item(Item(payload=PayloadRef(bytes=b"test"), type="replay_recording"))

relay.send_envelope(project_id, envelope)
Expand Down Expand Up @@ -72,12 +74,12 @@ def test_replay_recordings_processing(

assert replay_recording == {
"type": "replay_recording",
"recording": {
"replay_recording": {
"attachment_type": "event.attachment",
"chunks": replay_recording_num_chunks[id1],
"content_type": "application/octet-stream",
"id": id1,
"name": "Unnamed Attachment",
"name": "rr",
"size": len(replay_recording_contents[id1]),
"rate_limited": False,
},
Expand Down

0 comments on commit 73845e0

Please sign in to comment.