feat: include version number in response headers and on application startup (#3045)

This commit is contained in:
Sanchith Hegde
2024-01-05 17:32:36 +05:30
committed by GitHub
parent c8279b110e
commit 252443a50d
6 changed files with 30 additions and 4 deletions

View File

@ -16,7 +16,7 @@ email = ["external_services/email", "dep:aws-config", "olap"]
frm = []
basilisk = ["kms"]
stripe = ["dep:serde_qs"]
release = ["kms", "stripe", "basilisk", "s3", "email", "backwards_compatibility", "business_profile_routing", "accounts_cache", "kv_store", "connector_choice_mca_id", "profile_specific_fallback_routing"]
release = ["kms", "stripe", "basilisk", "s3", "email", "backwards_compatibility", "business_profile_routing", "accounts_cache", "kv_store", "connector_choice_mca_id", "profile_specific_fallback_routing", "vergen"]
olap = ["data_models/olap", "storage_impl/olap", "scheduler/olap", "dep:analytics"]
oltp = ["storage_impl/oltp"]
kv_store = ["scheduler/kv_store"]

View File

@ -34,6 +34,9 @@ async fn main() -> ApplicationResult<()> {
conf.validate()
.expect("Failed to validate router configuration");
#[cfg(feature = "vergen")]
println!("Starting router (Version: {})", router_env::git_tag!());
let _guard = router_env::setup(
&conf.log,
router_env::service_name!(),

View File

@ -22,8 +22,6 @@ use tokio::sync::{mpsc, oneshot};
const SCHEDULER_FLOW: &str = "SCHEDULER_FLOW";
#[tokio::main]
async fn main() -> CustomResult<(), ProcessTrackerError> {
// console_subscriber::init();
let cmd_line = <CmdLineConf as clap::Parser>::parse();
#[allow(clippy::expect_used)]
@ -58,6 +56,12 @@ async fn main() -> CustomResult<(), ProcessTrackerError> {
let scheduler_flow = scheduler::SchedulerFlow::from_str(&scheduler_flow_str)
.expect("Unable to parse SchedulerFlow from environment variable");
#[cfg(feature = "vergen")]
println!(
"Starting {scheduler_flow} (Version: {})",
router_env::git_tag!()
);
let _guard = router_env::setup(
&state.conf.log,
&scheduler_flow_str,

View File

@ -70,7 +70,13 @@ where
pub fn default_response_headers() -> actix_web::middleware::DefaultHeaders {
use actix_web::http::header;
actix_web::middleware::DefaultHeaders::new()
let default_headers_middleware = actix_web::middleware::DefaultHeaders::new();
#[cfg(feature = "vergen")]
let default_headers_middleware =
default_headers_middleware.add(("x-hyperswitch-version", router_env::git_tag!()));
default_headers_middleware
// Max age of 1 year in seconds, equal to `60 * 60 * 24 * 365` seconds.
.add((header::STRICT_TRANSPORT_SECURITY, "max-age=31536000"))
.add((header::VIA, "HyperSwitch"))