Skip to content

Commit

Permalink
Add custom-tracing to reward_index
Browse files Browse the repository at this point in the history
  • Loading branch information
macpie committed May 10, 2024
1 parent 3f2530a commit 527b8b3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 31 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion price/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ triggered = { workspace = true }
solana-client = { workspace = true }
solana-sdk = { workspace = true }
task-manager = { path = "../task_manager" }
custom-tracing = { path = "../custom_tracing", features = ["grpc"] }
custom-tracing = { path = "../custom_tracing" }
49 changes: 25 additions & 24 deletions reward_index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,36 @@ license.workspace = true


[dependencies]
anyhow = {workspace = true}
bs58 = {workspace = true}
config = {workspace = true}
clap = {workspace = true}
thiserror = {workspace = true}
serde = {workspace = true}
serde_json = {workspace = true}
sqlx = {workspace = true}
base64 = {workspace = true}
sha2 = {workspace = true}
lazy_static = {workspace = true}
triggered = {workspace = true}
futures = {workspace = true}
futures-util = {workspace = true}
prost = {workspace = true}
once_cell = {workspace = true}
file-store = {path = "../file_store"}
anyhow = { workspace = true }
bs58 = { workspace = true }
config = { workspace = true }
clap = { workspace = true }
thiserror = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sqlx = { workspace = true }
base64 = { workspace = true }
sha2 = { workspace = true }
lazy_static = { workspace = true }
triggered = { workspace = true }
futures = { workspace = true }
futures-util = { workspace = true }
prost = { workspace = true }
once_cell = { workspace = true }
file-store = { path = "../file_store" }
db-store = { path = "../db_store" }
poc-metrics = {path = "../metrics"}
poc-metrics = { path = "../metrics" }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
chrono = { workspace = true, features = ["serde"] }
metrics = {workspace = true }
metrics = { workspace = true }
metrics-exporter-prometheus = { workspace = true }
helium-proto = { workspace = true }
helium-crypto = { workspace = true }
rust_decimal = {workspace = true}
rust_decimal_macros = {workspace = true}
tonic = {workspace = true}
rand = {workspace = true}
async-trait = {workspace = true}
rust_decimal = { workspace = true }
rust_decimal_macros = { workspace = true }
tonic = { workspace = true }
rand = { workspace = true }
async-trait = { workspace = true }
custom-tracing = { path = "../custom_tracing" }
7 changes: 1 addition & 6 deletions reward_index/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use futures_util::TryFutureExt;
use reward_index::{settings::Settings, telemetry, Indexer};
use std::path::PathBuf;
use tokio::signal;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

#[derive(Debug, clap::Parser)]
#[clap(version = env!("CARGO_PKG_VERSION"))]
Expand All @@ -28,6 +27,7 @@ pub struct Cli {
impl Cli {
pub async fn run(self) -> Result<()> {
let settings = Settings::new(self.config)?;
custom_tracing::init(settings.log.clone(), settings.tracing_cfg_file.clone()).await?;
self.cmd.run(settings).await
}
}
Expand All @@ -50,11 +50,6 @@ pub struct Server {}

impl Server {
pub async fn run(&self, settings: &Settings) -> Result<()> {
tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::new(&settings.log))
.with(tracing_subscriber::fmt::layer())
.init();

// Install the prometheus metrics exporter
poc_metrics::start_metrics(&settings.metrics)?;
//
Expand Down
7 changes: 7 additions & 0 deletions reward_index/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub struct Settings {
/// "poc_entropy=debug,poc_store=info"
#[serde(default = "default_log")]
pub log: String,
/// File name to be watched by custom tracing
#[serde(default = "default_tracing_cfg_file")]
pub tracing_cfg_file: String,
/// Check interval in seconds. (Default is 900; 15 minutes)
#[serde(default = "default_interval")]
pub interval: i64,
Expand All @@ -49,6 +52,10 @@ pub fn default_log() -> String {
"reward_index=debug,poc_store=info".to_string()
}

pub fn default_tracing_cfg_file() -> String {
"tracing.cfg".to_string()
}

impl Settings {
/// Load Settings from a given path. Settings are loaded from a given
/// optional path and can be overriden with environment variables.
Expand Down

0 comments on commit 527b8b3

Please sign in to comment.