diff --git a/Cargo.lock b/Cargo.lock index bdad807..69ddf19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -390,6 +390,16 @@ dependencies = [ "generic-array", ] +[[package]] +name = "build-data" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda20fcece9c23f3c3f4c2751a8a5ca9491c05fa7a69920af65953c3b39b7ce4" +dependencies = [ + "chrono", + "safe-regex", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -1322,6 +1332,22 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.5.2", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.10" @@ -2313,7 +2339,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2424,7 +2450,7 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.32", "hyper-rustls 0.24.2", - "hyper-tls", + "hyper-tls 0.5.0", "ipnet", "js-sys", "log", @@ -2468,11 +2494,13 @@ dependencies = [ "http-body-util", "hyper 1.5.2", "hyper-rustls 0.27.5", + "hyper-tls 0.6.0", "hyper-util", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -2486,6 +2514,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper 1.0.2", "tokio", + "tokio-native-tls", "tokio-rustls 0.26.1", "tower 0.5.2", "tower-service", @@ -2673,6 +2702,53 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "safe-proc-macro2" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd85be67db87168aa3c13fd0da99f48f2ab005dccad5af5626138dc1df20eb6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "safe-quote" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77e530f7831f3feafcd5f1aae406ac205dd998436b4007c8e80f03eca78a88f7" +dependencies = [ + "safe-proc-macro2", +] + +[[package]] +name = "safe-regex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5194fafa3cb9da89e0cab6dffa1f3fdded586bd6396d12be11b4cae0c7ee45c2" +dependencies = [ + "safe-regex-macro", +] + +[[package]] +name = "safe-regex-compiler" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e822ae1e61251bcfd698317c237cf83f7c57161a5dc24ee609a85697f1ed15b3" +dependencies = [ + "safe-proc-macro2", + "safe-quote", +] + +[[package]] +name = "safe-regex-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2768de7e6ef19f59c5fd3c3ac207ef12b68a49f95e3172d67e4a04cfd992ca06" +dependencies = [ + "safe-proc-macro2", + "safe-regex-compiler", +] + [[package]] name = "schannel" version = "0.1.27" @@ -2923,6 +2999,7 @@ dependencies = [ "async-trait", "axum 0.8.1", "axum-extra", + "build-data", "dotenv", "http 1.2.0", "oauth2", @@ -3733,7 +3810,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea6023f9fe4b69267ccd3ed7d203d931c43c5f82dbaa0f07202bc17193a5f43" dependencies = [ "loki-api", - "reqwest 0.11.27", + "reqwest 0.12.12", "serde", "serde_json", "snap", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 83d5a8c..3f2dd4f 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -3,6 +3,7 @@ name = "skjera" version = "0.1.0" edition = "2021" + [features] default = ["loki"] otel = [] @@ -41,3 +42,6 @@ tracing-opentelemetry = { version = "0.28.0", features = [] } tracing-loki = { version = "0.2.5", optional = true } tracing-subscriber = { version = "0.3.19", features = ["env-filter", "registry", "fmt"] } url = "2.5.4" + +[build-dependencies] +build-data = "0.2.1" diff --git a/backend/build.rs b/backend/build.rs new file mode 100644 index 0000000..60a04b0 --- /dev/null +++ b/backend/build.rs @@ -0,0 +1,13 @@ +fn main() { + build_data::set_GIT_BRANCH(); + build_data::set_GIT_COMMIT(); + build_data::set_GIT_DIRTY(); + // build_data::set_SOURCE_TIMESTAMP(); + build_data::no_debug_rebuilds(); + + let git_commit = build_data::get_git_commit().unwrap(); + let git_dirty = build_data::get_git_dirty().unwrap(); + + let value = format!("{}{}", git_commit, if git_dirty { " dirty" } else { "" }); + println!("cargo:rustc-env=VERSION_INFO={value}"); +} diff --git a/backend/src/logging.rs b/backend/src/logging.rs index 8cfa592..816448f 100644 --- a/backend/src/logging.rs +++ b/backend/src/logging.rs @@ -50,10 +50,10 @@ type LoggingSubsystem = LokiLoggingSubsystem; type LoggingSubsystem = OtelLoggingSubsystem; pub(crate) fn configure_logging() -> Result { - let resource = Resource::new_with_defaults(vec![KeyValue::new( - semconv::resource::SERVICE_NAME, - env!("CARGO_CRATE_NAME"), - )]); + let resource = Resource::new_with_defaults(vec![ + KeyValue::new(semconv::resource::SERVICE_NAME, env!("CARGO_CRATE_NAME")), + KeyValue::new(semconv::resource::SERVICE_VERSION, crate::VERSION_INFO), + ]); // let span_exporter = SpanExporter::builder().with_tonic().build()?; // Scaleway only supports HTTP (need to test if protobuf is supported, or we need to use json). diff --git a/backend/src/main.rs b/backend/src/main.rs index cf26cca..00eea19 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -28,8 +28,19 @@ use tower_sessions::cookie::SameSite::Lax; use tower_sessions::{MemoryStore, SessionManagerLayer, SessionStore}; use tracing::{debug, info, warn}; +// const GIT_BRANCH: &str = env!("GIT_BRANCH"); +// const GIT_COMMIT: &str = env!("GIT_COMMIT"); +// const GIT_DIRTY: &str = env!("GIT_DIRTY"); +// SOURCE_TIMESTAMP doesn't work on my machine: https://gitlab.com/leonhard-llc/ops/-/issues/18 +// const SOURCE_TIMESTAMP: &str = env!("SOURCE_TIMESTAMP"); + +// const VERSION_INFO: &str = concat!("{}{}", env!("GIT_COMMIT"), D); +const VERSION_INFO: &str = env!("VERSION_INFO"); + #[tokio::main] async fn main() { + println!("Starting skjera. version={}", VERSION_INFO); + // We don't care if there is a problem here let env = dotenv::dotenv(); let is_local = env.is_ok(); @@ -43,7 +54,7 @@ async fn main() { } let logging_subsystem = logging_subsystem.unwrap(); - warn!("skjera starting"); + warn!(version = VERSION_INFO, "Starting skjera"); let options = match std::env::var("DATABASE_URL") { Ok(url) => match url.parse::() {