-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use spin_telemetry instead of our own subscriber
Signed-off-by: Caleb Schoepp <[email protected]>
- Loading branch information
1 parent
9ad3b3c
commit 258eaa4
Showing
3 changed files
with
15 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} |