Skip to content
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
1 change: 1 addition & 0 deletions crates/taurus-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ pub mod runtime;
pub mod time;
pub mod types;
pub mod value;
pub mod version;
3 changes: 2 additions & 1 deletion crates/taurus-core/src/types/errors/runtime_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tucana::shared::{
};

use crate::time::now_unix_micros;
use crate::version::runtime_version;

/// Runtime execution failure representation.
#[derive(Debug, Clone, PartialEq)]
Expand Down Expand Up @@ -48,7 +49,7 @@ impl RuntimeError {
category: category.into(),
message: message.into(),
timestamp_unix_micros: now_unix_micros() as u64,
version: env!("CARGO_PKG_VERSION").to_string(),
version: runtime_version().to_string(),
dependencies: HashMap::new(),
details: HashMap::new(),
}
Expand Down
19 changes: 19 additions & 0 deletions crates/taurus-core/src/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//! Runtime version resolution.
//!
//! `env!("CARGO_PKG_VERSION")` is a compile-time constant, so stamping a
//! per-pipeline release version into `Cargo.toml` before `cargo build` (as
//! CI used to) invalidates the build cache for every crate that reads it on
//! every single build. Reading `TAURUS_VERSION` at runtime instead lets the
//! image's final Docker layer stamp the release version without touching
//! anything upstream of it. Falls back to the compiled-in crate version when
//! the env var isn't set (local dev, tests).

use std::sync::OnceLock;

static VERSION: OnceLock<String> = OnceLock::new();

pub fn runtime_version() -> &'static str {
VERSION.get_or_init(|| {
std::env::var("TAURUS_VERSION").unwrap_or_else(|_| env!("CARGO_PKG_VERSION").to_string())
})
}
2 changes: 1 addition & 1 deletion crates/taurus/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn init_telemetry(config: &Config) -> telemetry::Telemetry {
TelemetrySettings {
environment: environment_label(&config.environment),
default_log_level: "debug",
service_version: env!("CARGO_PKG_VERSION"),
service_version: taurus_core::version::runtime_version(),
instrumentation_name: env!("CARGO_PKG_NAME"),
initialize_metrics: Some(telemetry::metrics::initialize),
},
Expand Down