Skip to content
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

feat: Write coordinator logs in GCP compatible format #984

Merged
merged 1 commit into from
Aug 7, 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
1 change: 1 addition & 0 deletions coordinator/Cargo.lock

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

1 change: 1 addition & 0 deletions coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tokio = "1.28"
tonic = "0.10.2"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-stackdriver = "0.10.0"
serde = "1.0.195"
serde_json = "1.0.108"

Expand Down
14 changes: 10 additions & 4 deletions coordinator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ async fn sleep(duration: Duration) -> anyhow::Result<()> {

#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(tracing_subscriber::EnvFilter::from_default_env())
.init();
let subscriber =
tracing_subscriber::registry().with(tracing_subscriber::EnvFilter::from_default_env());

if std::env::var("GCP_LOGGING_ENABLED").is_ok() {
subscriber.with(tracing_stackdriver::layer()).init();
} else {
subscriber
.with(tracing_subscriber::fmt::layer().compact())
.init();
}

let rpc_url = std::env::var("RPC_URL").expect("RPC_URL is not set");
let registry_contract_id = std::env::var("REGISTRY_CONTRACT_ID")
Expand Down
Loading