Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions relay-server/src/processing/profiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ impl Processor for ProfilesProcessor {
profiles: Managed<Self::Input>,
ctx: Context<'_>,
) -> Result<Output<Self::Output>, Rejected<Self::Error>> {
relay_statsd::metric!(
counter(RelayCounters::StandaloneItem) += profiles.profiles.len() as u64,
processor = "new",
item_type = "profile",
);

filter::feature_flag(ctx).reject(&profiles)?;

let profile = process::expand(profiles)?;
Expand Down
6 changes: 0 additions & 6 deletions relay-server/src/processing/user_reports/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ impl Processor for UserReportsProcessor {
mut reports: Managed<Self::Input>,
ctx: Context<'_>,
) -> Result<Output<Self::Output>, Rejected<Self::Error>> {
relay_statsd::metric!(
counter(RelayCounters::StandaloneItem) += reports.reports.len() as u64,
processor = "new",
item_type = "user_report",
);

process::process(&mut reports);

let reports = self.limiter.enforce_quotas(reports, ctx).await?;
Expand Down
5 changes: 1 addition & 4 deletions relay-server/src/services/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1499,10 +1499,9 @@ impl EnvelopeProcessorService {

let mut extracted_metrics = ProcessingExtractedMetrics::new();

// TODO: Not sure where to best move this logic
standalone::process(managed_envelope);

profile::filter(managed_envelope, ctx.config, ctx.project_info);

self.enforce_quotas(
managed_envelope,
Annotated::empty(),
Expand All @@ -1511,8 +1510,6 @@ impl EnvelopeProcessorService {
)
.await?;

report::process_user_reports(managed_envelope);

Ok(Some(extracted_metrics))
}

Expand Down
53 changes: 3 additions & 50 deletions relay-server/src/services/processor/profile.rs
Original file line number Diff line number Diff line change
@@ -1,55 +1,9 @@
//! Profiles related processor code.

use relay_dynamic_config::Feature;

use relay_config::Config;
use relay_profiling::ProfileError;

use crate::envelope::ItemType;
use crate::managed::{ItemAction, TypedEnvelope};
use crate::services::outcome::{DiscardReason, Outcome};
use crate::services::processor::should_filter;
use crate::services::projects::project::ProjectInfo;

pub fn filter<Group>(
managed_envelope: &mut TypedEnvelope<Group>,
config: &Config,
project_info: &ProjectInfo,
) {
let profiling_disabled = should_filter(config, project_info, Feature::Profiling);

let mut saw_profile = false;
managed_envelope.retain_items(|item| match item.ty() {
ItemType::Profile if profiling_disabled => ItemAction::DropSilently,
// First profile found in the envelope, we'll keep it if metadata are valid.
ItemType::Profile if !saw_profile => {
// Drop profile without a transaction in the same envelope,
// except if unsampled profiles are allowed for this project.
let profile_allowed = !item.sampled();
if !profile_allowed {
return ItemAction::DropSilently;
}

match relay_profiling::parse_metadata(&item.payload()) {
Ok(_) => {
saw_profile = true;
ItemAction::Keep
}
Err(err) => ItemAction::Drop(Outcome::Invalid(DiscardReason::Profiling(
relay_profiling::discard_reason(&err),
))),
}
}
// We found another profile, we'll drop it.
ItemType::Profile => ItemAction::Drop(Outcome::Invalid(DiscardReason::Profiling(
relay_profiling::discard_reason(&ProfileError::TooManyProfiles),
))),
_ => ItemAction::Keep,
});
}

// TODO: Not sure what to do with these tests now
#[cfg(test)]
mod tests {
use crate::envelope::ItemType;
use crate::envelope::{ContentType, Envelope, Item};
use crate::extractors::RequestMeta;
use crate::managed::ManagedEnvelope;
Expand All @@ -59,13 +13,12 @@ mod tests {
use crate::services::projects::project::ProjectInfo;
use crate::testutils::create_test_processor;
use insta::assert_debug_snapshot;
use relay_config::Config;
use relay_dynamic_config::{ErrorBoundary, Feature, GlobalConfig, TransactionMetricsConfig};
use relay_event_schema::protocol::{Event, EventId, ProfileContext};
use relay_protocol::Annotated;
use relay_system::Addr;

use super::*;

async fn process_event(envelope: Box<Envelope>) -> Result<Annotated<Event>, ProcessingError> {
let config = Config::from_json_value(serde_json::json!({
"processing": {
Expand Down
Loading