Skip to content

Commit

Permalink
Thread scraping config through minidump requests (#1303)
Browse files Browse the repository at this point in the history
Originally, the ScrapingConfig was only passed down to symbolicate requests. Now it is also being handled for minidump requests.
  • Loading branch information
Swatinem authored Sep 21, 2023
1 parent 4aa31ff commit 0afffbc
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::types::{
};
use crate::utils::hex::HexValue;

use super::{StacktraceOrigin, SymbolicateStacktraces, SymbolicationActor};
use super::{ScrapingConfig, StacktraceOrigin, SymbolicateStacktraces, SymbolicationActor};

impl SymbolicationActor {
#[tracing::instrument(skip_all)]
Expand All @@ -24,6 +24,7 @@ impl SymbolicationActor {
scope: Scope,
report: File,
sources: Arc<[SourceConfig]>,
scraping: ScrapingConfig,
) -> Result<(SymbolicateStacktraces, AppleCrashReportState)> {
let report =
AppleCrashReport::from_reader(report).context("failed to parse apple crash report")?;
Expand Down Expand Up @@ -79,7 +80,7 @@ impl SymbolicationActor {
signal: None,
stacktraces,
apply_source_context: true,
scraping: Default::default(),
scraping,
};

let mut system_info = SystemInfo {
Expand Down Expand Up @@ -124,8 +125,9 @@ impl SymbolicationActor {
scope: Scope,
report: File,
sources: Arc<[SourceConfig]>,
scraping: ScrapingConfig,
) -> Result<CompletedSymbolicationResponse> {
let (request, state) = self.parse_apple_crash_report(scope, report, sources)?;
let (request, state) = self.parse_apple_crash_report(scope, report, sources, scraping)?;
let mut response = self.symbolicate(request).await?;

state.merge_into(&mut response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::types::{
};
use crate::utils::hex::HexValue;

use super::{StacktraceOrigin, SymbolicateStacktraces, SymbolicationActor};
use super::{ScrapingConfig, StacktraceOrigin, SymbolicateStacktraces, SymbolicationActor};

type Minidump = minidump::Minidump<'static, ByteView<'static>>;

Expand Down Expand Up @@ -404,9 +404,10 @@ impl SymbolicationActor {
scope: Scope,
minidump_file: TempPath,
sources: Arc<[SourceConfig]>,
scraping: ScrapingConfig,
) -> Result<CompletedSymbolicationResponse> {
let (request, state) = self
.stackwalk_minidump(scope, minidump_file, sources)
.stackwalk_minidump(scope, minidump_file, sources, scraping)
.await?;

let mut response = self.symbolicate(request).await?;
Expand All @@ -421,6 +422,7 @@ impl SymbolicationActor {
scope: Scope,
minidump_file: TempPath,
sources: Arc<[SourceConfig]>,
scraping: ScrapingConfig,
) -> Result<(SymbolicateStacktraces, MinidumpState)> {
let len = minidump_file.metadata()?.len();
tracing::debug!("Processing minidump ({} bytes)", len);
Expand Down Expand Up @@ -476,7 +478,7 @@ impl SymbolicationActor {
signal: None,
stacktraces,
apply_source_context: true,
scraping: Default::default(),
scraping,
};

Ok((request, minidump_state))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ macro_rules! stackwalk_minidump {
Scope::Global,
minidump_file.into_temp_path(),
Arc::new([source]),
Default::default(),
)
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ async fn test_apple_crash_report() {
let report_file = std::fs::File::open(fixture("apple_crash_report.txt")).unwrap();

let response = symbolication
.process_apple_crash_report(Scope::Global, report_file, Arc::new([source]))
.process_apple_crash_report(
Scope::Global,
report_file,
Arc::new([source]),
Default::default(),
)
.await;

assert_snapshot!(response.unwrap());
Expand Down
7 changes: 6 additions & 1 deletion crates/symbolicator-stress/src/workloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ pub async fn process_payload(symbolication: &SymbolicationActor, workload: &Pars
.unwrap();

symbolication
.process_minidump(scope.clone(), temp_path, Arc::clone(sources))
.process_minidump(
scope.clone(),
temp_path,
Arc::clone(sources),
Default::default(),
)
.await
.unwrap();
}
Expand Down
8 changes: 7 additions & 1 deletion crates/symbolicator/src/endpoints/applecrashreport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub async fn handle_apple_crash_report_request(

let mut report = None;
let mut sources = service.config().default_sources();
let mut scraping = Default::default();
let mut options = RequestOptions::default();

while let Some(field) = multipart.next_field().await? {
Expand All @@ -34,6 +35,10 @@ pub async fn handle_apple_crash_report_request(
let data = read_multipart_data(field, 1024 * 1024).await?; // 1Mb
sources = serde_json::from_slice(&data)?;
}
Some("scraping") => {
let data = read_multipart_data(field, 1024 * 1024).await?; // 1Mb
scraping = serde_json::from_slice(&data)?;
}
Some("options") => {
let data = read_multipart_data(field, 1024 * 1024).await?; // 1Mb
options = serde_json::from_slice(&data)?
Expand All @@ -44,7 +49,8 @@ pub async fn handle_apple_crash_report_request(

let report = report.ok_or((StatusCode::BAD_REQUEST, "missing apple crash report"))?;

let request_id = service.process_apple_crash_report(params.scope, report, sources, options)?;
let request_id =
service.process_apple_crash_report(params.scope, report, sources, scraping, options)?;

match service.get_response(request_id, params.timeout).await {
Some(response) => Ok(Json(response)),
Expand Down
8 changes: 7 additions & 1 deletion crates/symbolicator/src/endpoints/minidump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub async fn handle_minidump_request(

let mut minidump = None;
let mut sources = service.config().default_sources();
let mut scraping = Default::default();
let mut options = RequestOptions::default();

while let Some(field) = multipart.next_field().await? {
Expand All @@ -44,6 +45,10 @@ pub async fn handle_minidump_request(
let data = read_multipart_data(field, 1024 * 1024).await?; // 1Mb
sources = serde_json::from_slice(&data)?;
}
Some("scraping") => {
let data = read_multipart_data(field, 1024 * 1024).await?; // 1Mb
scraping = serde_json::from_slice(&data)?;
}
Some("options") => {
let data = read_multipart_data(field, 1024 * 1024).await?; // 1Mb
options = serde_json::from_slice(&data)?;
Expand All @@ -65,7 +70,8 @@ pub async fn handle_minidump_request(
)
.into());
}
let request_id = service.process_minidump(params.scope, minidump_file, sources, options)?;
let request_id =
service.process_minidump(params.scope, minidump_file, sources, scraping, options)?;

match service.get_response(request_id, params.timeout).await {
Some(response) => Ok(Json(response)),
Expand Down
7 changes: 5 additions & 2 deletions crates/symbolicator/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use futures::{channel::oneshot, FutureExt as _};
use sentry::protocol::SessionStatus;
use sentry::SentryFutureExt;
use serde::{Deserialize, Deserializer, Serialize};
use symbolicator_service::services::ScrapingConfig;
use tempfile::TempPath;
use uuid::Uuid;

Expand Down Expand Up @@ -271,12 +272,13 @@ impl RequestService {
scope: Scope,
minidump_file: TempPath,
sources: Arc<[SourceConfig]>,
scraping: ScrapingConfig,
options: RequestOptions,
) -> Result<RequestId, MaxRequestsError> {
let slf = self.inner.clone();
self.create_symbolication_request("minidump_stackwalk", options, async move {
slf.symbolication
.process_minidump(scope, minidump_file, sources)
.process_minidump(scope, minidump_file, sources, scraping)
.await
.map(Into::into)
})
Expand All @@ -291,12 +293,13 @@ impl RequestService {
scope: Scope,
apple_crash_report: File,
sources: Arc<[SourceConfig]>,
scraping: ScrapingConfig,
options: RequestOptions,
) -> Result<RequestId, MaxRequestsError> {
let slf = self.inner.clone();
self.create_symbolication_request("parse_apple_crash_report", options, async move {
slf.symbolication
.process_apple_crash_report(scope, apple_crash_report, sources)
.process_apple_crash_report(scope, apple_crash_report, sources, scraping)
.await
.map(Into::into)
})
Expand Down
2 changes: 1 addition & 1 deletion crates/symbolicli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ async fn main() -> Result<()> {
Payload::Minidump(minidump_path) => {
tracing::info!("symbolicating minidump");
symbolication
.process_minidump(scope, minidump_path, dsym_sources)
.process_minidump(scope, minidump_path, dsym_sources, Default::default())
.await
.map(CompletedResponse::from)?
}
Expand Down

0 comments on commit 0afffbc

Please sign in to comment.