Skip to content

feat: add version and timestamp to error logs #2516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE reported_errors
DROP COLUMN timestamp;
ALTER TABLE reported_errors
DROP COLUMN version;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Your SQL goes here
ALTER TABLE reported_errors
ADD COLUMN timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE reported_errors
ADD COLUMN version TEXT NOT NULL DEFAULT '<2.3.1';
2 changes: 2 additions & 0 deletions coordinator/src/db/reported_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use xxi_node::commons::ReportedError;
struct NewReportedError {
trader_pubkey: String,
error: String,
version: String,
}

pub(crate) fn insert(conn: &mut PgConnection, error: ReportedError) -> QueryResult<()> {
Expand All @@ -22,6 +23,7 @@ impl From<ReportedError> for NewReportedError {
Self {
trader_pubkey: value.trader_pk.to_string(),
error: value.msg,
version: value.version.unwrap_or("<2.3.1".to_owned()),
}
}
}
2 changes: 2 additions & 0 deletions coordinator/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ diesel::table! {
id -> Int4,
trader_pubkey -> Text,
error -> Text,
timestamp -> Timestamptz,
version -> Text,
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/xxi-node/src/commons/reported_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ use serde::Serialize;
pub struct ReportedError {
pub trader_pk: PublicKey,
pub msg: String,
pub version: Option<String>,
}
3 changes: 3 additions & 0 deletions mobile/native/src/report_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use crate::state::get_or_create_tokio_runtime;
use reqwest::Url;

pub fn report_error_to_coordinator<E: ToString>(error: &E) {
let version = env!("CARGO_PKG_VERSION").to_string();

let client = reqwest_client();
let pk = get_node().inner.info.pubkey;

Expand All @@ -23,6 +25,7 @@ pub fn report_error_to_coordinator<E: ToString>(error: &E) {
.json(&xxi_node::commons::ReportedError {
trader_pk: pk,
msg: error_string,
version: Some(version),
})
.send()
.await
Expand Down
Loading