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(profiling): Distinguish various discard reasons for profiles #1395

Merged
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Spawn more threads for CPU intensive work. ([#1378](https://github.com/getsentry/relay/pull/1378))
- Add missing fields to DeviceContext ([#1383](https://github.com/getsentry/relay/pull/1383))
- Improve performance of Redis accesses by not running `PING` everytime a connection is reused. ([#1394](https://github.com/getsentry/relay/pull/1394))
- Distinguish between various discard reasons for profiles. ([#1395](https://github.com/getsentry/relay/pull/1395))

## 22.7.0

Expand Down
3 changes: 2 additions & 1 deletion relay-profiling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ mod utils;

use crate::android::parse_android_profile;
use crate::cocoa::parse_cocoa_profile;
use crate::error::ProfileError;
use crate::python::parse_python_profile;
use crate::rust::parse_rust_profile;
use crate::typescript::parse_typescript_profile;

pub use crate::error::ProfileError;

#[derive(Debug, Deserialize)]
struct MinimalProfile {
platform: String,
Expand Down
5 changes: 5 additions & 0 deletions relay-server/src/actors/outcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ pub enum DiscardReason {

/// (Relay) We failed to parse the profile so we discard the profile.
ProcessProfile,

/// (Relay) The profile is parseable but semantically invalid. This could happen if
/// profiles lack sufficient samples.
InvalidProfile,
}

impl DiscardReason {
Expand Down Expand Up @@ -342,6 +346,7 @@ impl DiscardReason {
DiscardReason::Internal => "internal",
DiscardReason::TransactionSampled => "transaction_sampled",
DiscardReason::EmptyEnvelope => "empty_envelope",
DiscardReason::InvalidProfile => "invalid_profile",
}
}
}
Expand Down
13 changes: 11 additions & 2 deletions relay-server/src/actors/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ fn outcome_from_parts(field: ClientReportField, reason: &str) -> Result<Outcome,
}
}

fn outcome_from_profile_error(err: relay_profiling::ProfileError) -> Outcome {
let discard_reason = match err {
relay_profiling::ProfileError::CannotSerializePayload => DiscardReason::Internal,
relay_profiling::ProfileError::NotEnoughSamples => DiscardReason::InvalidProfile,
_ => DiscardReason::ProcessProfile,
};
Outcome::Invalid(discard_reason)
}

/// Synchronous service for processing envelopes.
pub struct EnvelopeProcessor {
config: Arc<Config>,
Expand Down Expand Up @@ -882,9 +891,9 @@ impl EnvelopeProcessor {
item.set_payload(ContentType::Json, &payload[..]);
return true;
}
Err(_) => {
Err(err) => {
context.track_outcome(
Outcome::Invalid(DiscardReason::ProcessProfile),
outcome_from_profile_error(err),
DataCategory::Profile,
1,
);
Expand Down