Skip to content

Commit

Permalink
feat(vlog): Report observability config, flush, and shutdown (#2622)
Browse files Browse the repository at this point in the history
## What ❔

Adds more logs for observability lifecycle.

## Why ❔

Easier to debug issues.

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] 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`.
  • Loading branch information
popzxc authored Aug 8, 2024
1 parent aff7b65 commit e23e661
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
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.

3 changes: 2 additions & 1 deletion core/lib/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,4 +26,4 @@ serde = { workspace = true, features = ["derive"] }

[features]
default = []
observability_ext = ["zksync_vlog"]
observability_ext = ["zksync_vlog", "tracing"]
3 changes: 3 additions & 0 deletions core/lib/config/src/observability_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
8 changes: 8 additions & 0 deletions core/lib/vlog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -58,6 +60,7 @@ impl ObservabilityGuard {
tracing::warn!("Flushing the logs failed: {err:?}");
}
}
tracing::info!("Logs are flushed");
}
}

Expand All @@ -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");
}
}
}
Expand Down
1 change: 1 addition & 0 deletions prover/Cargo.lock

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

0 comments on commit e23e661

Please sign in to comment.