Skip to content

Commit

Permalink
feat(metrics): Add platform tag (#1511)
Browse files Browse the repository at this point in the history
This adds a configurable platform tag to metrics. If this is set, the platform (read from the SYMBOLICATOR_PLATFORM env variable) will be reported with every metric.
  • Loading branch information
loewenheim authored Aug 28, 2024
1 parent 47b3d6e commit f07e925
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/symbolicator-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ pub struct Metrics {
pub hostname_tag: Option<String>,
/// 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.
///
/// These tags will be appended to every metric.
Expand All @@ -107,6 +112,7 @@ impl Default for Metrics {
prefix: "symbolicator".into(),
hostname_tag: None,
environment_tag: None,
platform_tag: None,
custom_tags: BTreeMap::new(),
}
}
Expand Down
14 changes: 14 additions & 0 deletions crates/symbolicator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ pub fn execute() -> Result<()> {
}
};

if let Some(platform_tag) = config.metrics.platform_tag.clone() {
if tags.contains_key(&platform_tag) {
tracing::warn!(
"tag {} defined both as platform tag and as a custom tag",
platform_tag
);
}
if let Ok(platform) = std::env::var("SYMBOLICATOR_PLATFORM") {
tags.insert(platform_tag, platform.to_string());
} else {
tracing::error!("platform not available");
}
};

metrics::configure_statsd(&config.metrics.prefix, statsd, tags);
}

Expand Down

0 comments on commit f07e925

Please sign in to comment.