Skip to content

Commit

Permalink
Use spin_telemetry instead of our own subscriber
Browse files Browse the repository at this point in the history
Signed-off-by: Caleb Schoepp <[email protected]>
  • Loading branch information
calebschoepp committed May 14, 2024
1 parent 9ad3b3c commit 258eaa4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
14 changes: 1 addition & 13 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ serde = "1.0"
spin-app = { git = "https://github.com/fermyon/spin", tag = "v2.5.1" }
spin-core = { git = "https://github.com/fermyon/spin", tag = "v2.5.1" }
spin-trigger = { git = "https://github.com/fermyon/spin", tag = "v2.5.1" }
spin-telemetry = { git = "https://github.com/fermyon/spin", tag = "v2.5.1" }
tokio = { version = "1.23", features = ["full"] }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3.7", features = ["env-filter"] }
wasmtime-wasi = { version = "18.0.4", features = ["tokio"] }

[target.'cfg(target_os = "linux")'.dependencies]
Expand Down
19 changes: 13 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
use clap::Parser;
use spin_trigger::cli::TriggerExecutorCommand;
use std::io::IsTerminal;
use trigger_command::CommandTrigger;

type Command = TriggerExecutorCommand<CommandTrigger>;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_writer(std::io::stderr)
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.with_ansi(std::io::stderr().is_terminal())
.init();
let _telemetry_guard = spin_telemetry::init(build_info())?;

let t = Command::parse();
t.run().await
}

/// Returns build information of the parent Spin process, similar to: 0.1.0 (2be4034 2022-03-31).
fn build_info() -> String {
let spin_version = env_var("SPIN_VERSION");
let spin_commit_sha = env_var("SPIN_COMMIT_SHA");
let spin_commit_date = env_var("SPIN_COMMIT_DATE");
format!("{spin_version} ({spin_commit_sha} {spin_commit_date})")
}

fn env_var(name: &str) -> String {
std::env::var(name).unwrap_or_else(|_| "unknown".to_string())
}

0 comments on commit 258eaa4

Please sign in to comment.