Skip to content

Commit

Permalink
log(replays): Add organization-id and project-id to log messages (#3949)
Browse files Browse the repository at this point in the history
So we can look up log messages by project and org.

#skip-changelog

---------

Co-authored-by: David Herberth <david.herberth@sentry.io>
  • Loading branch information
cmanallen and Dav1dde committed Aug 27, 2024
1 parent 1543031 commit cce218f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions relay-server/src/services/processor/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::error::Error;
use std::net::IpAddr;

use bytes::Bytes;
use relay_base_schema::project::ProjectId;
use relay_dynamic_config::{Feature, GlobalConfig, ProjectConfig};
use relay_event_normalization::replay::{self, ReplayError};
use relay_event_normalization::RawUserAgentInfo;
Expand All @@ -28,6 +29,8 @@ pub fn process(
let replays_disabled = state.should_filter(Feature::SessionReplay);
let scrubbing_enabled = project_state.has_feature(Feature::SessionReplayRecordingScrubbing);
let replay_video_disabled = project_state.has_feature(Feature::SessionReplayVideoDisabled);
let project_id = project_state.project_id;
let organization_id = project_state.organization_id;

let meta = state.envelope().meta().clone();
let client_addr = meta.client_addr();
Expand Down Expand Up @@ -79,6 +82,8 @@ pub fn process(
global_config,
client_addr,
user_agent,
project_id,
organization_id,
)?;
item.set_payload(ContentType::Json, replay_event);
}
Expand All @@ -101,6 +106,8 @@ pub fn process(
user_agent,
scrubbing_enabled,
&mut scrubber,
project_id,
organization_id,
)?;
item.set_payload(ContentType::OctetStream, replay_video);
}
Expand All @@ -113,13 +120,16 @@ pub fn process(

// Replay Event Processing.

#[allow(clippy::too_many_arguments)]
fn handle_replay_event_item(
payload: Bytes,
event_id: &Option<EventId>,
config: &ProjectConfig,
global_config: &GlobalConfig,
client_ip: Option<IpAddr>,
user_agent: &RawUserAgentInfo<&str>,
project_id: Option<ProjectId>,
organization_id: Option<u64>,
) -> Result<Bytes, ProcessingError> {
let filter_settings = &config.filter_settings;

Expand Down Expand Up @@ -151,6 +161,8 @@ fn handle_replay_event_item(
relay_log::warn!(
error = &error as &dyn Error,
?event_id,
project_id = project_id.map(|v| v.value()),
organization_id = organization_id,
"invalid replay event"
);
Err(match error {
Expand Down Expand Up @@ -259,6 +271,8 @@ fn handle_replay_video_item(
user_agent: &RawUserAgentInfo<&str>,
scrubbing_enabled: bool,
scrubber: &mut RecordingScrubber,
project_id: Option<ProjectId>,
organization_id: Option<u64>,
) -> Result<Bytes, ProcessingError> {
let ReplayVideoEvent {
replay_event,
Expand All @@ -282,6 +296,8 @@ fn handle_replay_video_item(
global_config,
client_ip,
user_agent,
project_id,
organization_id,
)?;

// Process as a replay-recording envelope item.
Expand Down

0 comments on commit cce218f

Please sign in to comment.