-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(err): parse stack traces (#25393)
Co-authored-by: David Newell <[email protected]>
- Loading branch information
1 parent
c80a904
commit f7eaea6
Showing
13 changed files
with
272 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ mod team; | |
|
||
// Events | ||
pub use event::CapturedEvent; | ||
pub use event::ClickHouseEvent; | ||
|
||
// Teams | ||
pub use team::Team; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub mod app_context; | ||
pub mod config; | ||
pub mod error; | ||
pub mod symbols; | ||
pub mod traits; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
// A minifed JS stack frame. Just the minimal information needed to lookup some | ||
// sourcemap for it and produce a "real" stack frame. | ||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct RawJSFrame { | ||
#[serde(rename = "lineno")] | ||
pub line: u32, | ||
#[serde(rename = "colno")] | ||
pub column: u32, | ||
#[serde(rename = "filename")] | ||
pub uri: String, | ||
pub in_app: bool, | ||
#[serde(rename = "function")] | ||
pub fn_name: String, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize)] | ||
pub struct ProcessedFrame { | ||
pub line: u32, | ||
pub column: u32, | ||
pub uri: String, | ||
pub in_app: bool, | ||
pub fn_name: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod js; | ||
pub mod symbolifier; | ||
pub mod types; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use super::types::{ProcessedStack, RawStack}; | ||
|
||
pub struct Symbolifier; | ||
|
||
impl Symbolifier { | ||
pub fn symbolify(_stack: RawStack) -> ProcessedStack { | ||
unimplemented!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use std::collections::HashMap; | ||
|
||
use serde::Deserialize; | ||
use serde::Serialize; | ||
use serde_json::Value; | ||
|
||
use super::{js::RawJSFrame, symbolifier::Symbolifier}; | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[serde(untagged)] | ||
pub enum RawFrame { | ||
JavaScript(RawJSFrame), | ||
} | ||
|
||
// Stacks don't care what the "type" of the frames they contain are, and even permit | ||
// frames of different types to be mixed together, because we're going to end up "exploding" | ||
// them into their frame-set anyway, and dispatching a task per frame in a language-agnostic | ||
// way. Supporting mixed-type stacks is a side benefit of this - I don't know that we'll ever | ||
// see them, but we get the flexibility "for free" | ||
#[derive(Debug, Deserialize)] | ||
pub struct RawStack { | ||
pub frames: Vec<RawFrame>, | ||
} | ||
|
||
pub enum ProcessedFrame { | ||
JavaScript(), | ||
} | ||
|
||
pub struct ProcessedStack { | ||
pub frames: Vec<ProcessedFrame>, | ||
} | ||
|
||
impl RawStack { | ||
pub async fn process(self, _sym: &Symbolifier) -> ProcessedStack { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone)] | ||
pub struct PropertyView { | ||
#[serde(rename = "$exception_type")] | ||
pub exception_type: String, | ||
#[serde(rename = "$exception_message")] | ||
pub exception_message: String, | ||
#[serde(rename = "$exception_stack_trace_raw")] | ||
pub exception_stack_trace_raw: String, | ||
#[serde(rename = "$exception_level")] | ||
pub exception_level: String, | ||
#[serde(rename = "$exception_source")] | ||
pub exception_source: String, | ||
#[serde(rename = "$exception_lineno")] | ||
pub exception_line: u32, | ||
#[serde(rename = "$exception_colno")] | ||
pub exception_col: u32, | ||
#[serde(flatten)] | ||
other: HashMap<String, Value>, | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use common_types::ClickHouseEvent; | ||
|
||
use crate::symbols::types::{PropertyView, RawFrame}; | ||
|
||
#[test] | ||
fn it_symbolifies() { | ||
let raw: &'static str = include_str!("../../tests/static/raw_js_stack.json"); | ||
|
||
let raw: ClickHouseEvent = serde_json::from_str(raw).unwrap(); | ||
|
||
let exception_properties: PropertyView = | ||
serde_json::from_str(&raw.properties.unwrap()).unwrap(); | ||
|
||
let stack_trace: Vec<RawFrame> = | ||
serde_json::from_str(&exception_properties.exception_stack_trace_raw).unwrap(); | ||
|
||
println!("{:?}", stack_trace); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use crate::symbols::types::RawStack; | ||
|
||
// An "exception" is anything that can self-identify with a "fingerprint" | ||
pub trait Exception { | ||
fn id(&self) -> String; | ||
fn to_raw(self) -> serde_json::Value; | ||
} | ||
|
||
// Some excpetions have a raw stack trace we can process. If they do, | ||
|
||
pub trait Stacked: Exception { | ||
fn stack(&self) -> RawStack; | ||
} |
Oops, something went wrong.