Add additional panic information to panic events (#2555)

Adds the following to the panic event

release_channel
os_name
os_version
architecture

Merge first: https://github.com/zed-industries/zed.dev/pull/322

Release Notes:

- N/A
This commit is contained in:
Joseph T. Lyons 2023-06-02 14:30:16 -04:00 committed by GitHub
commit 00265c19a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 7 deletions

View file

@ -6,6 +6,8 @@ use std::{env, fmt::Display};
use sysinfo::{System, SystemExt};
use util::channel::ReleaseChannel;
// TODO: Move this file out of feedback and into a more general place
#[derive(Clone, Debug, Serialize)]
pub struct SystemSpecs {
#[serde(serialize_with = "serialize_app_version")]

View file

@ -70,10 +70,7 @@ fn main() {
log::info!("========== starting zed ==========");
let mut app = gpui::App::new(Assets).unwrap();
let app_version = ZED_APP_VERSION
.or_else(|| app.platform().app_version().ok())
.map_or("dev".to_string(), |v| v.to_string());
init_panic_hook(app_version);
init_panic_hook(&app);
app.background();
@ -376,19 +373,29 @@ struct Panic {
backtrace: Vec<String>,
// TODO
// stripped_backtrace: String,
time: u128,
release_channel: String,
os_name: String,
os_version: Option<String>,
architecture: String,
panicked_on: u128,
}
#[derive(Serialize)]
struct PanicRequest {
panic: Panic,
// TODO: Move to Panic struct, as app_version - requires changing zed.dev
version: String,
token: String,
}
fn init_panic_hook(app_version: String) {
fn init_panic_hook(app: &App) {
let is_pty = stdout_is_a_pty();
let platform = app.platform();
panic::set_hook(Box::new(move |info| {
let app_version = ZED_APP_VERSION
.or_else(|| platform.app_version().ok())
.map_or("dev".to_string(), |v| v.to_string());
let backtrace = Backtrace::new();
let thread = thread::current();
@ -414,7 +421,14 @@ fn init_panic_hook(app_version: String) {
.map(|line| line.to_string())
.collect(),
// modified_backtrace: None,
time: SystemTime::now()
release_channel: RELEASE_CHANNEL.dev_name().into(),
os_name: platform.os_name().into(),
os_version: platform
.os_version()
.ok()
.map(|os_version| os_version.to_string()),
architecture: env::consts::ARCH.into(),
panicked_on: SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_millis(),