Skip to content

Commit

Permalink
Allow to change OcCollector Service name via LINKERD2_PROXY_TRACING_S…
Browse files Browse the repository at this point in the history
…ERVICE_NAME env variable

Signed-off-by: GrigoriyMikhalkin <[email protected]>
  • Loading branch information
GrigoriyMikhalkin committed Mar 31, 2024
1 parent 183689e commit 952951a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions linkerd/app/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,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";
Expand Down Expand Up @@ -367,6 +369,8 @@ pub fn parse_config<S: Strings>(strings: &S) -> Result<super::Config, EnvError>

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 =
Expand Down Expand Up @@ -788,6 +792,7 @@ pub fn parse_config<S: Strings>(strings: &S) -> Result<super::Config, EnvError>
oc_collector::Config::Enabled(Box::new(oc_collector::EnabledConfig {
attributes,
hostname: hostname?,
service_name: proxy_tracing_service_name?,

Check warning on line 795 in linkerd/app/src/env.rs

View check run for this annotation

Codecov / codecov/patch

linkerd/app/src/env.rs#L795

Added line #L795 was not covered by tests
control: ControlConfig {
addr,
connect,
Expand Down
3 changes: 2 additions & 1 deletion linkerd/app/src/oc_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct EnabledConfig {
pub control: control::Config,
pub attributes: HashMap<String, String>,
pub hostname: Option<String>,
pub service_name: Option<String>,
}

pub type Task = Pin<Box<dyn Future<Output = ()> + Send + 'static>>;
Expand Down Expand Up @@ -72,7 +73,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()
Expand Down

0 comments on commit 952951a

Please sign in to comment.