Write panics and crashes to snowflake (#28284)
This will let us create a better crashes dashboard, using Hex. Release Notes: - N/A
This commit is contained in:
parent
448db20eaa
commit
6220b86f94
3 changed files with 57 additions and 6 deletions
|
@ -127,7 +127,7 @@ async fn update_billing_preferences(
|
||||||
|
|
||||||
SnowflakeRow::new(
|
SnowflakeRow::new(
|
||||||
"Spend Limit Updated",
|
"Spend Limit Updated",
|
||||||
user.metrics_id,
|
Some(user.metrics_id),
|
||||||
user.admin,
|
user.admin,
|
||||||
None,
|
None,
|
||||||
json!({
|
json!({
|
||||||
|
|
|
@ -149,6 +149,31 @@ pub async fn post_crash(
|
||||||
"crash report"
|
"crash report"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if let Some(kinesis_client) = app.kinesis_client.clone() {
|
||||||
|
if let Some(stream) = app.config.kinesis_stream.clone() {
|
||||||
|
let properties = json!({
|
||||||
|
"app_version": report.header.app_version,
|
||||||
|
"os_version": report.header.os_version,
|
||||||
|
"os_name": "macOS",
|
||||||
|
"bundle_id": report.header.bundle_id,
|
||||||
|
"incident_id": report.header.incident_id,
|
||||||
|
"installation_id": installation_id,
|
||||||
|
"description": description,
|
||||||
|
"backtrace": summary,
|
||||||
|
});
|
||||||
|
SnowflakeRow::new(
|
||||||
|
"Crash Report",
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
Some(installation_id),
|
||||||
|
properties,
|
||||||
|
)
|
||||||
|
.write(&Some(kinesis_client), &Some(stream))
|
||||||
|
.await
|
||||||
|
.log_err();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(slack_panics_webhook) = app.config.slack_panics_webhook.clone() {
|
if let Some(slack_panics_webhook) = app.config.slack_panics_webhook.clone() {
|
||||||
let payload = slack::WebhookBody::new(|w| {
|
let payload = slack::WebhookBody::new(|w| {
|
||||||
w.add_section(|s| s.text(slack::Text::markdown(description)))
|
w.add_section(|s| s.text(slack::Text::markdown(description)))
|
||||||
|
@ -314,6 +339,8 @@ pub async fn post_panic(
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let backtrace = panic.backtrace.join("\n");
|
||||||
|
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
service = "client",
|
service = "client",
|
||||||
version = %panic.app_version,
|
version = %panic.app_version,
|
||||||
|
@ -322,10 +349,34 @@ pub async fn post_panic(
|
||||||
incident_id = %incident_id,
|
incident_id = %incident_id,
|
||||||
installation_id = %panic.installation_id.clone().unwrap_or_default(),
|
installation_id = %panic.installation_id.clone().unwrap_or_default(),
|
||||||
description = %panic.payload,
|
description = %panic.payload,
|
||||||
backtrace = %panic.backtrace.join("\n"),
|
backtrace = %backtrace,
|
||||||
"panic report"
|
"panic report"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if let Some(kinesis_client) = app.kinesis_client.clone() {
|
||||||
|
if let Some(stream) = app.config.kinesis_stream.clone() {
|
||||||
|
let properties = json!({
|
||||||
|
"app_version": panic.app_version,
|
||||||
|
"os_name": panic.os_name,
|
||||||
|
"os_version": panic.os_version,
|
||||||
|
"incident_id": incident_id,
|
||||||
|
"installation_id": panic.installation_id,
|
||||||
|
"description": panic.payload,
|
||||||
|
"backtrace": backtrace,
|
||||||
|
});
|
||||||
|
SnowflakeRow::new(
|
||||||
|
"Panic Report",
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
panic.installation_id.clone(),
|
||||||
|
properties,
|
||||||
|
)
|
||||||
|
.write(&Some(kinesis_client), &Some(stream))
|
||||||
|
.await
|
||||||
|
.log_err();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let backtrace = if panic.backtrace.len() > 25 {
|
let backtrace = if panic.backtrace.len() > 25 {
|
||||||
let total = panic.backtrace.len();
|
let total = panic.backtrace.len();
|
||||||
format!(
|
format!(
|
||||||
|
@ -711,7 +762,7 @@ pub struct SnowflakeRow {
|
||||||
impl SnowflakeRow {
|
impl SnowflakeRow {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
event_type: impl Into<String>,
|
event_type: impl Into<String>,
|
||||||
metrics_id: Uuid,
|
metrics_id: Option<Uuid>,
|
||||||
is_staff: bool,
|
is_staff: bool,
|
||||||
system_id: Option<String>,
|
system_id: Option<String>,
|
||||||
event_properties: serde_json::Value,
|
event_properties: serde_json::Value,
|
||||||
|
@ -720,7 +771,7 @@ impl SnowflakeRow {
|
||||||
time: chrono::Utc::now(),
|
time: chrono::Utc::now(),
|
||||||
event_type: event_type.into(),
|
event_type: event_type.into(),
|
||||||
device_id: system_id,
|
device_id: system_id,
|
||||||
user_id: Some(metrics_id.to_string()),
|
user_id: metrics_id.map(|id| id.to_string()),
|
||||||
insert_id: Some(uuid::Uuid::new_v4().to_string()),
|
insert_id: Some(uuid::Uuid::new_v4().to_string()),
|
||||||
event_properties,
|
event_properties,
|
||||||
user_properties: Some(json!({"is_staff": is_staff})),
|
user_properties: Some(json!({"is_staff": is_staff})),
|
||||||
|
|
|
@ -591,7 +591,7 @@ async fn check_usage_limit(
|
||||||
|
|
||||||
SnowflakeRow::new(
|
SnowflakeRow::new(
|
||||||
"Language Model Rate Limited",
|
"Language Model Rate Limited",
|
||||||
claims.metrics_id,
|
Some(claims.metrics_id),
|
||||||
claims.is_staff,
|
claims.is_staff,
|
||||||
claims.system_id.clone(),
|
claims.system_id.clone(),
|
||||||
json!({
|
json!({
|
||||||
|
@ -719,7 +719,7 @@ impl<S> Drop for TokenCountingStream<S> {
|
||||||
});
|
});
|
||||||
SnowflakeRow::new(
|
SnowflakeRow::new(
|
||||||
"Language Model Used",
|
"Language Model Used",
|
||||||
claims.metrics_id,
|
Some(claims.metrics_id),
|
||||||
claims.is_staff,
|
claims.is_staff,
|
||||||
claims.system_id.clone(),
|
claims.system_id.clone(),
|
||||||
properties,
|
properties,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue