-
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.
fix(err): include raw js frame on frame content in pg (#26326)
- Loading branch information
1 parent
b8440d2
commit 6354e87
Showing
8 changed files
with
4,062 additions
and
30 deletions.
There are no files selected for viewing
3,718 changes: 3,718 additions & 0 deletions
3,718
rust/cymbal/src/bin/nameless_frames_in_raw_format.json
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[ | ||
{ | ||
"uuid": "01932ad3-bd2a-796c-9f4c-f65ab1ff27ac", | ||
"event": "$exception", | ||
"properties": "{\"$exception_list\":[{\"type\":\"SyntaxError\",\"value\":\"Unexpected non-whitespace character after JSON at position 3708 (line 2 column 1)\",\"stacktrace\":{\"frames\":[{\"platform\":\"javascript\",\"filename\":\"https://unpkg.com/[email protected]/example/eventsource-polyfill.js\",\"function\":\"drainQueue\",\"in_app\":true,\"lineno\":219,\"colno\":42},{\"platform\":\"javascript\",\"filename\":\"https://unpkg.com/[email protected]/example/eventsource-polyfill.js\",\"function\":\"Item.run\",\"in_app\":true,\"lineno\":249,\"colno\":14},{\"platform\":\"javascript\",\"filename\":\"https://unpkg.com/[email protected]/example/eventsource-polyfill.js\",\"function\":\"afterTickTwo\",\"in_app\":true,\"lineno\":2392,\"colno\":10},{\"platform\":\"javascript\",\"filename\":\"https://unpkg.com/[email protected]/example/eventsource-polyfill.js\",\"function\":\"resume_\",\"in_app\":true,\"lineno\":4950,\"colno\":3},{\"platform\":\"javascript\",\"filename\":\"https://unpkg.com/[email protected]/example/eventsource-polyfill.js\",\"function\":\"flow\",\"in_app\":true,\"lineno\":4967,\"colno\":34},{\"platform\":\"javascript\",\"filename\":\"https://unpkg.com/[email protected]/example/eventsource-polyfill.js\",\"function\":\"Readable.read\",\"in_app\":true,\"lineno\":4623,\"colno\":26},{\"platform\":\"javascript\",\"filename\":\"https://unpkg.com/[email protected]/example/eventsource-polyfill.js\",\"function\":\"exports.IncomingMessage.emit\",\"in_app\":true,\"lineno\":3377,\"colno\":5},{\"platform\":\"javascript\",\"filename\":\"https://unpkg.com/[email protected]/example/eventsource-polyfill.js\",\"function\":\"exports.IncomingMessage.<anonymous>\",\"in_app\":true,\"lineno\":6756,\"colno\":11},{\"platform\":\"javascript\",\"filename\":\"https://unpkg.com/[email protected]/example/eventsource-polyfill.js\",\"function\":\"parseEventStreamLine\",\"in_app\":true,\"lineno\":6799,\"colno\":9},{\"platform\":\"javascript\",\"filename\":\"https://unpkg.com/[email protected]/example/eventsource-polyfill.js\",\"function\":\"_emit\",\"in_app\":true,\"lineno\":6784,\"colno\":17},{\"platform\":\"javascript\",\"filename\":\"https://unpkg.com/[email protected]/example/eventsource-polyfill.js\",\"function\":\"EventSource.emit\",\"in_app\":true,\"lineno\":3377,\"colno\":5},{\"platform\":\"javascript\",\"filename\":\"https://app-static-prod.posthog.com/static/chunk-B4MXHXII.js\",\"function\":\"a.onmessage\",\"in_app\":true,\"lineno\":290,\"colno\":97793},{\"platform\":\"javascript\",\"filename\":\"<anonymous>\",\"function\":\"JSON.parse\",\"in_app\":true}],\"type\":\"raw\"},\"mechanism\":{\"handled\":true,\"synthetic\":false}}],\"$exception_level\":\"error\"}", | ||
"timestamp": "2024-11-14 13:19:00.117", | ||
"team_id": 2, | ||
"project_id": 2, | ||
"distinct_id": "cu5skLyhm2En4xb5ERxtMkmMtC99pdbZDcqO3VDaDqt", | ||
"elements_chain": "", | ||
"created_at": "2024-11-14 13:20:30.828", | ||
"person_created_at": "2024-07-02 13:11:05", | ||
"person_mode": "full" | ||
}, | ||
{ | ||
"uuid": "01933c1f-f831-7f29-8b18-2bee05ce0125", | ||
"event": "$exception", | ||
"properties": "{\"$exception_list\":[{\"type\":\"Error\",\"value\":\"Unexpected usage\\n\\nError: Unexpected usage\\n at n.loadForeignModule (https://app-static-prod.posthog.com/static/chunk-PGUQKT6S.js:64:15003)\\n at https://app-static-prod.posthog.com/static/chunk-PGUQKT6S.js:64:25112\",\"stacktrace\":{\"frames\":[{\"filename\":\"https://app-static-prod.posthog.com/static/chunk-C6S33U6V.js\",\"function\":\"r\",\"in_app\":true,\"lineno\":19,\"colno\":2044},{\"filename\":\"https://app-static-prod.posthog.com/static/chunk-PGUQKT6S.js\",\"function\":\"?\",\"in_app\":true,\"lineno\":3,\"colno\":12},{\"filename\":\"https://app-static-prod.posthog.com/static/chunk-PGUQKT6S.js\",\"function\":\"?\",\"in_app\":true,\"lineno\":64,\"colno\":25112},{\"filename\":\"https://app-static-prod.posthog.com/static/chunk-PGUQKT6S.js\",\"function\":\"n.loadForeignModule\",\"in_app\":true,\"lineno\":64,\"colno\":15003}],\"type\":\"raw\"},\"mechanism\":{\"type\":\"generic\",\"handled\":true}}],\"$sentry_event_id\":\"c2954a0d25c643e4ac6b9aef7c3b39e4\",\"$sentry_exception\":{},\"$sentry_exception_message\":\"Unexpected usage\\n\\nError: Unexpected usage\\n at n.loadForeignModule (https://app-static-prod.posthog.com/static/chunk-PGUQKT6S.js:64:15003)\\n at https://app-static-prod.posthog.com/static/chunk-PGUQKT6S.js:64:25112\"}", | ||
"timestamp": "2024-11-17 21:55:48.475", | ||
"team_id": 2, | ||
"project_id": 2, | ||
"distinct_id": "KCVn0RwlQkwrWhSWU5j2CzvN9QTbwsZPdqz6cfSPcXH", | ||
"elements_chain": "", | ||
"created_at": "2024-11-17 21:55:51.928", | ||
"person_created_at": "2023-03-21 17:54:03", | ||
"person_mode": "full" | ||
} | ||
] |
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,86 @@ | ||
use std::sync::Arc; | ||
|
||
use cymbal::{ | ||
config::Config, | ||
langs::js::RawJSFrame, | ||
symbol_store::{ | ||
caching::{Caching, SymbolSetCache}, | ||
sourcemap::SourcemapProvider, | ||
Catalog, | ||
}, | ||
}; | ||
use serde_json::Value; | ||
use tokio::sync::Mutex; | ||
|
||
/** | ||
Input data gathered by running the following, then converting to json: | ||
SELECT | ||
symbol_set.ref as filename, | ||
contents::json->>'mangled_name' as "function", | ||
(contents::json->>'in_app')::boolean as in_app, | ||
CASE | ||
WHEN contents::json->>'line' IS NOT NULL | ||
THEN (contents::json->>'line')::int | ||
END as lineno, | ||
CASE | ||
WHEN contents::json->>'column' IS NOT NULL | ||
THEN (contents::json->>'column')::int | ||
END as colno | ||
FROM posthog_errortrackingstackframe frame | ||
LEFT JOIN posthog_errortrackingsymbolset symbol_set | ||
ON frame.symbol_set_id = symbol_set.id | ||
WHERE (contents::json->>'resolved_name') is null | ||
AND contents::json->>'lang' = 'javascript' | ||
AND symbol_set.storage_ptr IS NOT NULL; | ||
This doesn't actually work - we don't have the original line and column number, and | ||
so can't repeat the original resolution. I couldn't find a way to reverse that mapping | ||
with sourcemaps, so instead I'm going to temporarily add the raw frame to the resolve | ||
Frame. | ||
*/ | ||
const NAMELESS_FRAMES_IN_RAW_FMT: &str = include_str!("./nameless_frames_in_raw_format.json"); | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let config = Config::init_with_defaults().unwrap(); | ||
let provider = SourcemapProvider::new(&config); | ||
let cache = Arc::new(Mutex::new(SymbolSetCache::new(1_000_000_000))); | ||
let provider = Caching::new(provider, cache); | ||
|
||
let catalog = Catalog::new(provider); | ||
|
||
let frames: Vec<Value> = serde_json::from_str(NAMELESS_FRAMES_IN_RAW_FMT).unwrap(); | ||
|
||
// Deal with metabase giving me string-only values | ||
let frames: Vec<RawJSFrame> = frames | ||
.into_iter() | ||
.map(|f| { | ||
let mut f = f; | ||
let in_app = f["in_app"].as_str().unwrap() == "true"; | ||
f["in_app"] = Value::Bool(in_app); | ||
let lineno: u32 = f["lineno"] | ||
.as_str() | ||
.unwrap() | ||
.replace(",", "") | ||
.parse() | ||
.unwrap(); | ||
let colno: u32 = f["colno"] | ||
.as_str() | ||
.unwrap() | ||
.replace(",", "") | ||
.parse() | ||
.unwrap(); | ||
f["lineno"] = Value::Number(lineno.into()); | ||
f["colno"] = Value::Number(colno.into()); | ||
serde_json::from_value(f).unwrap() | ||
}) | ||
.collect(); | ||
|
||
for frame in frames { | ||
let res = frame.resolve(0, &catalog).await.unwrap(); | ||
|
||
if res.resolved_name.is_none() { | ||
panic!("Frame name not resolved: {:?}", frame); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.