From 56502b4eceb257c0c445926679f953b0de8252d9 Mon Sep 17 00:00:00 2001 From: GrigoriyMikhalkin Date: Sun, 31 Mar 2024 19:44:50 +0200 Subject: [PATCH 1/2] Allow to change OcCollector Service name via LINKERD2_PROXY_TRACING_SERVICE_NAME env variable Signed-off-by: GrigoriyMikhalkin --- linkerd/app/src/env.rs | 5 +++++ linkerd/app/src/oc_collector.rs | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/linkerd/app/src/env.rs b/linkerd/app/src/env.rs index 290e1da0b7..39b4cc11c2 100644 --- a/linkerd/app/src/env.rs +++ b/linkerd/app/src/env.rs @@ -257,6 +257,8 @@ const ENV_OUTBOUND_HTTP1_CONNECTION_POOL_IDLE_TIMEOUT: &str = const ENV_SHUTDOWN_GRACE_PERIOD: &str = "LINKERD2_PROXY_SHUTDOWN_GRACE_PERIOD"; +const ENV_PROXY_TRACING_SERVICE_NAME: &str = "LINKERD2_PROXY_TRACING_SERVICE_NAME"; + // Default values for various configuration fields const DEFAULT_OUTBOUND_LISTEN_ADDR: &str = "127.0.0.1:4140"; pub const DEFAULT_INBOUND_LISTEN_ADDR: &str = "0.0.0.0:4143"; @@ -376,6 +378,8 @@ pub fn parse_config(strings: &S) -> Result let shutdown_grace_period = parse(strings, ENV_SHUTDOWN_GRACE_PERIOD, parse_duration); + let proxy_tracing_service_name = strings.get(ENV_PROXY_TRACING_SERVICE_NAME); + let inbound_discovery_idle_timeout = parse(strings, ENV_INBOUND_DISCOVERY_IDLE_TIMEOUT, parse_duration); let outbound_discovery_idle_timeout = @@ -811,6 +815,7 @@ pub fn parse_config(strings: &S) -> Result oc_collector::Config::Enabled(Box::new(oc_collector::EnabledConfig { attributes, hostname: hostname?, + service_name: proxy_tracing_service_name?, control: ControlConfig { addr, connect, diff --git a/linkerd/app/src/oc_collector.rs b/linkerd/app/src/oc_collector.rs index e8f25e23c5..c56950da40 100644 --- a/linkerd/app/src/oc_collector.rs +++ b/linkerd/app/src/oc_collector.rs @@ -18,6 +18,7 @@ pub struct EnabledConfig { pub control: control::Config, pub attributes: HashMap, pub hostname: Option, + pub service_name: Option, } pub type Task = Pin + Send + 'static>>; @@ -69,7 +70,7 @@ impl Config { start_timestamp: Some(SystemTime::now().into()), }), service_info: Some(oc::ServiceInfo { - name: Self::SERVICE_NAME.to_string(), + name: inner.service_name.unwrap_or(Self::SERVICE_NAME.to_string()), }), attributes: inner.attributes, ..oc::Node::default() From 0ffe5c5d19075ede1f7817a58279e8ad48ee6846 Mon Sep 17 00:00:00 2001 From: GrigoriyMikhalkin Date: Mon, 20 May 2024 15:23:00 +0200 Subject: [PATCH 2/2] Change trace service name variable name to LINKERD2_PROXY_TRACE_SERVICE_NAME Signed-off-by: GrigoriyMikhalkin --- linkerd/app/src/env.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linkerd/app/src/env.rs b/linkerd/app/src/env.rs index 39b4cc11c2..ca21a3ae32 100644 --- a/linkerd/app/src/env.rs +++ b/linkerd/app/src/env.rs @@ -141,6 +141,8 @@ const ENV_OUTBOUND_DISABLE_INFORMATIONAL_HEADERS: &str = pub const ENV_TRACE_ATTRIBUTES_PATH: &str = "LINKERD2_PROXY_TRACE_ATTRIBUTES_PATH"; +pub const ENV_TRACE_SERVICE_NAME: &str = "LINKERD2_PROXY_TRACE_SERVICE_NAME"; + /// Constrains which destination names may be used for profile/route discovery. /// /// The value is a comma-separated list of domain name suffixes that may be @@ -257,8 +259,6 @@ const ENV_OUTBOUND_HTTP1_CONNECTION_POOL_IDLE_TIMEOUT: &str = const ENV_SHUTDOWN_GRACE_PERIOD: &str = "LINKERD2_PROXY_SHUTDOWN_GRACE_PERIOD"; -const ENV_PROXY_TRACING_SERVICE_NAME: &str = "LINKERD2_PROXY_TRACING_SERVICE_NAME"; - // Default values for various configuration fields const DEFAULT_OUTBOUND_LISTEN_ADDR: &str = "127.0.0.1:4140"; pub const DEFAULT_INBOUND_LISTEN_ADDR: &str = "0.0.0.0:4143"; @@ -378,7 +378,7 @@ pub fn parse_config(strings: &S) -> Result let shutdown_grace_period = parse(strings, ENV_SHUTDOWN_GRACE_PERIOD, parse_duration); - let proxy_tracing_service_name = strings.get(ENV_PROXY_TRACING_SERVICE_NAME); + let proxy_tracing_service_name = strings.get(ENV_TRACE_SERVICE_NAME); let inbound_discovery_idle_timeout = parse(strings, ENV_INBOUND_DISCOVERY_IDLE_TIMEOUT, parse_duration);