From e23e6611731835ef3abd34f3f9867f9dc533eb21 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Thu, 8 Aug 2024 17:11:35 +0400 Subject: [PATCH] feat(vlog): Report observability config, flush, and shutdown (#2622) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Adds more logs for observability lifecycle. ## Why ❔ Easier to debug issues. ## Checklist - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`. --- Cargo.lock | 1 + core/lib/config/Cargo.toml | 3 ++- core/lib/config/src/observability_ext.rs | 3 +++ core/lib/vlog/src/lib.rs | 8 ++++++++ prover/Cargo.lock | 1 + 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 8446831eca71..85ea14290a13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8157,6 +8157,7 @@ dependencies = [ "rand 0.8.5", "secrecy", "serde", + "tracing", "url", "zksync_basic_types", "zksync_concurrency", diff --git a/core/lib/config/Cargo.toml b/core/lib/config/Cargo.toml index 784bdebfef07..b13948448cdd 100644 --- a/core/lib/config/Cargo.toml +++ b/core/lib/config/Cargo.toml @@ -16,6 +16,7 @@ zksync_crypto_primitives.workspace = true zksync_consensus_utils.workspace = true zksync_concurrency.workspace = true zksync_vlog = { workspace = true, optional = true } +tracing = { workspace = true, optional = true } url.workspace = true anyhow.workspace = true @@ -25,4 +26,4 @@ serde = { workspace = true, features = ["derive"] } [features] default = [] -observability_ext = ["zksync_vlog"] +observability_ext = ["zksync_vlog", "tracing"] diff --git a/core/lib/config/src/observability_ext.rs b/core/lib/config/src/observability_ext.rs index 641b095eb3b9..1370978b5807 100644 --- a/core/lib/config/src/observability_ext.rs +++ b/core/lib/config/src/observability_ext.rs @@ -16,6 +16,9 @@ impl ObservabilityConfig { .with_sentry(sentry) .with_opentelemetry(opentelemetry) .build(); + + tracing::info!("Installed observability stack with the following configuration: {self:?}"); + Ok(guard) } } diff --git a/core/lib/vlog/src/lib.rs b/core/lib/vlog/src/lib.rs index 390b7782c584..268fbd0b39eb 100644 --- a/core/lib/vlog/src/lib.rs +++ b/core/lib/vlog/src/lib.rs @@ -42,6 +42,7 @@ impl ObservabilityGuard { if let Some(sentry_guard) = &self.sentry_guard { sentry_guard.flush(Some(FLUSH_TIMEOUT)); + tracing::info!("Sentry events are flushed"); } if let Some(provider) = &self.otlp_tracing_provider { @@ -50,6 +51,7 @@ impl ObservabilityGuard { tracing::warn!("Flushing the spans failed: {err:?}"); } } + tracing::info!("Spans are flushed"); } if let Some(provider) = &self.otlp_logging_provider { @@ -58,6 +60,7 @@ impl ObservabilityGuard { tracing::warn!("Flushing the logs failed: {err:?}"); } } + tracing::info!("Logs are flushed"); } } @@ -70,15 +73,20 @@ impl ObservabilityGuard { // `take` here and below ensures that we don't have any access to the deinitialized resources. if let Some(sentry_guard) = self.sentry_guard.take() { sentry_guard.close(Some(SHUTDOWN_TIMEOUT)); + tracing::info!("Sentry client is shut down"); } if let Some(provider) = self.otlp_tracing_provider.take() { if let Err(err) = provider.shutdown() { tracing::warn!("Shutting down the OTLP tracing provider failed: {err:?}"); + } else { + tracing::info!("OTLP tracing provider is shut down"); } } if let Some(provider) = self.otlp_logging_provider.take() { if let Err(err) = provider.shutdown() { tracing::warn!("Shutting down the OTLP logs provider failed: {err:?}"); + } else { + tracing::info!("OTLP logs provider is shut down"); } } } diff --git a/prover/Cargo.lock b/prover/Cargo.lock index a7400fc2490e..4284ee998940 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -7736,6 +7736,7 @@ dependencies = [ "rand 0.8.5", "secrecy", "serde", + "tracing", "url", "zksync_basic_types", "zksync_concurrency",