From 1031e0da6e91b51ca5767ef01358871b90bdad8e Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Tue, 27 Aug 2024 16:19:18 +0200 Subject: [PATCH] Read platform from env var --- crates/symbolicator-service/src/config.rs | 3 +++ crates/symbolicator/src/cli.rs | 15 +-------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/crates/symbolicator-service/src/config.rs b/crates/symbolicator-service/src/config.rs index c6d5da3aa..4952ca033 100644 --- a/crates/symbolicator-service/src/config.rs +++ b/crates/symbolicator-service/src/config.rs @@ -92,6 +92,9 @@ pub struct Metrics { /// A tag name to report the environment to, for each metric. Defaults to not sending such a tag. pub environment_tag: Option, /// A tag name to report the platform to, for each metric. Defaults to not sending such a tag. + /// + /// If this is set, the platform will be read from the `SYMBOLICLATOR_PLATFORM` + /// environment variable. pub platform_tag: Option, /// A map containing custom tags and their values. /// diff --git a/crates/symbolicator/src/cli.rs b/crates/symbolicator/src/cli.rs index 036abb950..bda3a4196 100644 --- a/crates/symbolicator/src/cli.rs +++ b/crates/symbolicator/src/cli.rs @@ -147,7 +147,7 @@ pub fn execute() -> Result<()> { platform_tag ); } - if let Some(platform) = get_platform() { + if let Ok(platform) = std::env::var("SYMBOLICATOR_PLATFORM") { tags.insert(platform_tag, platform.to_string()); } else { tracing::error!("platform not available"); @@ -164,16 +164,3 @@ pub fn execute() -> Result<()> { Ok(()) } - -/// Determines a Symbolicator's platform (`"js"`, `"jvm"`, or `"native"`) -/// according to the hostname. -fn get_platform() -> Option<&'static str> { - let hostname = hostname::get().ok().and_then(|s| s.into_string().ok())?; - if hostname.contains("js") { - Some("js") - } else if hostname.contains("jvm") { - Some("jvm") - } else { - Some("native") - } -}