refactor(hermes): improve logging
This commit is contained in:
parent
f12df1528b
commit
245cc231fd
|
@ -1574,7 +1574,7 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermes"
|
name = "hermes"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
@ -4900,6 +4900,16 @@ dependencies = [
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-serde"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"tracing-core",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-subscriber"
|
name = "tracing-subscriber"
|
||||||
version = "0.3.17"
|
version = "0.3.17"
|
||||||
|
@ -4910,12 +4920,15 @@ dependencies = [
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"regex",
|
"regex",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"sharded-slab",
|
"sharded-slab",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thread_local",
|
"thread_local",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
|
"tracing-serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "hermes"
|
name = "hermes"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle."
|
description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ tokio = { version = "1.26.0", features = ["full"] }
|
||||||
tonic = { version = "0.10.1", features = ["tls"] }
|
tonic = { version = "0.10.1", features = ["tls"] }
|
||||||
tower-http = { version = "0.4.0", features = ["cors"] }
|
tower-http = { version = "0.4.0", features = ["cors"] }
|
||||||
tracing = { version = "0.1.37", features = ["log"] }
|
tracing = { version = "0.1.37", features = ["log"] }
|
||||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json"] }
|
||||||
utoipa = { version = "3.4.0", features = ["axum_extras"] }
|
utoipa = { version = "3.4.0", features = ["axum_extras"] }
|
||||||
utoipa-swagger-ui = { version = "3.1.4", features = ["axum"] }
|
utoipa-swagger-ui = { version = "3.1.4", features = ["axum"] }
|
||||||
wormhole-sdk = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.17.1" }
|
wormhole-sdk = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.17.1" }
|
||||||
|
|
|
@ -107,16 +107,19 @@ async fn init() -> Result<()> {
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
// Initialize a Tracing Subscriber
|
// Initialize a Tracing Subscriber
|
||||||
tracing::subscriber::set_global_default(
|
let fmt_builder = tracing_subscriber::fmt()
|
||||||
tracing_subscriber::fmt()
|
|
||||||
.compact()
|
|
||||||
.with_file(false)
|
.with_file(false)
|
||||||
.with_line_number(true)
|
.with_line_number(true)
|
||||||
.with_thread_ids(true)
|
.with_thread_ids(true)
|
||||||
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
|
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
|
||||||
.with_ansi(std::io::stderr().is_terminal())
|
.with_ansi(std::io::stderr().is_terminal());
|
||||||
.finish(),
|
|
||||||
)?;
|
// Use the compact formatter if we're in a terminal, otherwise use the JSON formatter.
|
||||||
|
if std::io::stderr().is_terminal() {
|
||||||
|
tracing::subscriber::set_global_default(fmt_builder.compact().finish())?;
|
||||||
|
} else {
|
||||||
|
tracing::subscriber::set_global_default(fmt_builder.json().finish())?;
|
||||||
|
}
|
||||||
|
|
||||||
// Launch the application. If it fails, print the full backtrace and exit. RUST_BACKTRACE
|
// Launch the application. If it fails, print the full backtrace and exit. RUST_BACKTRACE
|
||||||
// should be set to 1 for this otherwise it will only print the top-level error.
|
// should be set to 1 for this otherwise it will only print the top-level error.
|
||||||
|
|
|
@ -112,6 +112,13 @@ impl Benchmarks for crate::state::State {
|
||||||
|
|
||||||
let response = request.send().await?;
|
let response = request.send().await?;
|
||||||
|
|
||||||
|
if response.status() != reqwest::StatusCode::OK {
|
||||||
|
return Err(anyhow::anyhow!(format!(
|
||||||
|
"Price update for price ids {:?} with publish time {} not found in benchmarks. Status code: {}, message: {}",
|
||||||
|
price_ids, publish_time, response.status(), response.text().await?
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
let benchmark_updates: BenchmarkUpdates = response.json().await?;
|
let benchmark_updates: BenchmarkUpdates = response.json().await?;
|
||||||
benchmark_updates.try_into()
|
benchmark_updates.try_into()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue