Skip to content
Open
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
15 changes: 15 additions & 0 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"crates/preloop-orchestrator",
"crates/preloop-socket-activation",
"crates/preloop-cli",
"crates/preloop-observability",
"benchmarks/preloop-perf",
]
resolver = "2"
Expand Down
1 change: 1 addition & 0 deletions crates/preloop-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ name = "preloop"
path = "src/main.rs"

[dependencies]
preloop-observability = { path = "../preloop-observability" }
preloop-orchestrator = { path = "../preloop-orchestrator" }
preloop-vm = { path = "../preloop-vm" }
preloop-runner-server = { path = "../preloop-runner-server" }
Expand Down
25 changes: 14 additions & 11 deletions crates/preloop-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,17 +736,20 @@ struct ShellArgs {

#[tokio::main]
async fn main() -> anyhow::Result<()> {
// `fmt::init()` alone filters to ERROR when `RUST_LOG` is unset, which hid
// a runner pool that failed to provision 77 times in a row: every
// provisioning fault logs at `warn` or `info`, so the operator saw a server
// that accepted webhooks and silently never ran anything. Default to `info`
// and let `RUST_LOG` override as usual.
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
)
.init();
// Unified observability init (Step 2): one handle for the process, shared
// with `AppState` and `RunnerPoolConfig` later. `PRELOOP_LOG_FORMAT` now
// controls pretty/json/auto (auto = pretty on TTY, JSON when piped), and
// `RUST_LOG` defaults to `info` (the old `fmt::init()` default of ERROR hid
// pool provisioning faults). The runtime is held for the life of `main`
// and flushed with a bounded 2s shutdown on exit.
let obs_config = preloop_observability::ObservabilityConfig::from_env();
let (observability, observability_runtime) =
preloop_observability::Observability::from_config(obs_config);
preloop_observability::ObservabilityRuntime::install_fmt_subscriber(observability.config());
// Keep the handle alive; the pool/server will clone it later. Suppress
// unused warning until the wiring lands in Step 3.
let _observability = observability;
let _observability_runtime = observability_runtime;

let cli = Cli::parse();
// One config path for the whole process. `setup`/`doctor`/`secret` return
Expand Down
24 changes: 24 additions & 0 deletions crates/preloop-observability/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "preloop-observability"
version = "0.1.0"
edition = "2021"
license = "MIT"
description = "Observability handle for Preloop — metrics, logs, traces, status snapshot"
repository = "https://github.com/preloopdev/preloop"

[dependencies]
chrono = { workspace = true }
parking_lot = { workspace = true }
rand = { workspace = true }
reqwest = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
uuid = { workspace = true }
tokio = { workspace = true }

[dev-dependencies]

[lints]
workspace = true
Loading
Loading