Skip to content

Commit

Permalink
chore: pre shipping review improvements (#26059)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored Nov 7, 2024
1 parent f5d3b2a commit bccbf16
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
9 changes: 2 additions & 7 deletions rust/cymbal/src/frames/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,9 @@ impl RawFrame {
res
}

pub fn needs_symbols(&self) -> bool {
// For now, we only support JS, so this is always true
true
}

pub fn symbol_set_ref(&self) -> String {
pub fn symbol_set_ref(&self) -> Option<String> {
let RawFrame::JavaScript(raw) = self;
raw.source_url().map(String::from).unwrap_or_default()
raw.source_url().map(String::from).ok()
}

pub fn frame_id(&self) -> String {
Expand Down
12 changes: 6 additions & 6 deletions rust/cymbal/src/frames/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ impl Resolver {
return Ok(result.contents);
}

if !frame.needs_symbols() {
return frame.resolve(team_id, catalog).await;
}

if let Some(result) =
ErrorTrackingStackFrame::load(pool, team_id, &frame.frame_id()).await?
{
Expand All @@ -48,7 +44,11 @@ impl Resolver {

let resolved = frame.resolve(team_id, catalog).await?;

let set = SymbolSetRecord::load(pool, team_id, &frame.symbol_set_ref()).await?;
let set = if let Some(set_ref) = frame.symbol_set_ref() {
SymbolSetRecord::load(pool, team_id, &set_ref).await?
} else {
None
};

let record = ErrorTrackingStackFrame::new(
frame.frame_id(),
Expand Down Expand Up @@ -212,7 +212,7 @@ mod test {

// get the symbol set
let set_ref = frame.symbol_set_ref();
let set = SymbolSetRecord::load(&pool, 0, &set_ref)
let set = SymbolSetRecord::load(&pool, 0, &set_ref.unwrap())
.await
.unwrap()
.unwrap();
Expand Down
12 changes: 8 additions & 4 deletions rust/cymbal/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use cymbal::{
};
use envconfig::Envconfig;
use tokio::task::JoinHandle;
use tracing::{error, info};
use tracing::{error, info, warn};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer};

common_alloc::used!();
Expand Down Expand Up @@ -83,7 +83,7 @@ async fn main() -> Result<(), Error> {
offset.store().unwrap();

if event.event != "$exception" {
error!("event of type {}", event.event);
warn!("event of type {}", event.event);
continue;
}

Expand All @@ -96,13 +96,17 @@ async fn main() -> Result<(), Error> {
Ok(r) => r,
Err(err) => {
metrics::counter!(ERRORS, "cause" => "invalid_exception_properties").increment(1);
error!("Error parsing properties: {:?}", err);
error!(
"Error parsing properties: {:?} from properties {:?}",
err, properties
);
continue;
}
};

let Some(mut exception_list) = properties.exception_list else {
// Known issue that $exception_list didn't exist on old clients
metrics::counter!(ERRORS, "cause" => "no_exception_list").increment(1);
continue;
};

Expand Down Expand Up @@ -155,6 +159,6 @@ async fn main() -> Result<(), Error> {
let _fingerprint = fingerprinting::generate_fingerprint(&exception_list);

metrics::counter!(STACK_PROCESSED).increment(1);
whole_loop.label("had_frame", "true").fin();
whole_loop.label("finished", "true").fin();
}
}
16 changes: 0 additions & 16 deletions rust/cymbal/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ pub struct Exception {
pub struct ErrProps {
#[serde(rename = "$exception_list")]
pub exception_list: Option<Vec<Exception>>, // Required from exception producers - we will not process events without this. Optional to support older clients, should eventually be removed
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "$exception_type")]
pub exception_type: Option<String>, // legacy, overridden by exception_list
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "$exception_message")]
pub exception_message: Option<String>, // legacy, overridden by exception_list
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "$exception_stack_trace_raw")]
pub exception_stack_trace_raw: Option<String>, // Not all exceptions have a stack trace
#[serde(rename = "$exception_level")]
pub exception_level: Option<String>, // We generally don't touch this, but we break it out explicitly for users. Not all exceptions have a level
#[serde(flatten)] // A catch-all for all the properties we don't "care" about
pub other: HashMap<String, Value>,
}
Expand Down Expand Up @@ -148,11 +137,6 @@ mod test {
assert!(frame.in_app);
assert_eq!(frame.line, 64);
assert_eq!(frame.column, 15003);

assert_eq!(props.exception_type, None);
assert_eq!(props.exception_message, None);
assert_eq!(props.exception_stack_trace_raw, None);
assert_eq!(props.exception_level, Some("error".to_string()));
}

#[test]
Expand Down

0 comments on commit bccbf16

Please sign in to comment.