Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(*): Add support for OTel #23

Merged
merged 1 commit into from
May 8, 2024
Merged
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
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.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ aws-config = "0.52.0"
aws-sdk-sqs = "0.22.0"
clap = { version = "3.1.15", features = ["derive", "env"] }
futures = "0.3.25"
is-terminal = "0.4.3"
serde = "1.0"
spin-core = { git = "https://github.com/fermyon/spin", tag = "v2.4.3" }
spin-telemetry = { git = "https://github.com/fermyon/spin", tag = "v2.4.3" }
spin-trigger = { git = "https://github.com/fermyon/spin", tag = "v2.4.3" }
tokio = { version = "1.37", features = ["full"] }
tokio-scoped = "0.2.0"
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3.7", features = ["env-filter"] }
wasmtime = { version = "18.0.1" }

[target.'cfg(target_os = "linux")'.dependencies]
Expand Down
24 changes: 15 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@

use clap::Parser;
use is_terminal::IsTerminal;
use trigger_sqs::SqsTrigger;
use spin_trigger::cli::TriggerExecutorCommand;
use trigger_sqs::SqsTrigger;

type Command = TriggerExecutorCommand<SqsTrigger>;

#[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())
}
Loading