Skip to content

Commit

Permalink
Read platform from env var
Browse files Browse the repository at this point in the history
  • Loading branch information
loewenheim committed Aug 27, 2024
1 parent 7c0241d commit 1031e0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
3 changes: 3 additions & 0 deletions crates/symbolicator-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
/// 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<String>,
/// A map containing custom tags and their values.
///
Expand Down
15 changes: 1 addition & 14 deletions crates/symbolicator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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")
}
}

0 comments on commit 1031e0d

Please sign in to comment.