mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-12 16:16:55 +00:00
fix(obs): disable profiling export by default and fix Helm env name (#2719)
This commit is contained in:
@@ -48,10 +48,15 @@ use rustfs_config::{
|
||||
DEFAULT_OBS_PROFILING_EXPORT_ENABLED, DEFAULT_OBS_TRACES_EXPORT_ENABLED, ENVIRONMENT, METER_INTERVAL, SAMPLE_RATIO,
|
||||
SERVICE_VERSION, USE_STDOUT,
|
||||
};
|
||||
use rustfs_utils::{get_env_bool, get_env_f64, get_env_opt_str, get_env_opt_u64, get_env_str, get_env_u64, get_env_usize};
|
||||
use rustfs_utils::{
|
||||
get_env_bool, get_env_bool_with_aliases, get_env_f64, get_env_opt_str, get_env_opt_u64, get_env_str, get_env_u64,
|
||||
get_env_usize,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::env;
|
||||
|
||||
const LEGACY_ENV_OBS_PROFILING_ENABLED: &str = "RUSTFS_OBS_PROFILING_ENABLED";
|
||||
|
||||
/// Full observability configuration used by all telemetry backends.
|
||||
///
|
||||
/// Fields are grouped into three logical sections:
|
||||
@@ -134,7 +139,7 @@ pub struct OtelConfig {
|
||||
pub metrics_export_enabled: Option<bool>,
|
||||
/// Whether to export logs via OTLP (default: `true`).
|
||||
pub logs_export_enabled: Option<bool>,
|
||||
/// Whether to export profiles via pyroscope (default: `true`).
|
||||
/// Whether to export profiles via pyroscope (default: `false`).
|
||||
pub profiling_export_enabled: Option<bool>,
|
||||
/// **[OTLP-only]** Mirror all signals to stdout in addition to OTLP export.
|
||||
/// Only applies when an OTLP endpoint is configured.
|
||||
@@ -282,7 +287,11 @@ impl OtelConfig {
|
||||
traces_export_enabled: Some(get_env_bool(ENV_OBS_TRACES_EXPORT_ENABLED, DEFAULT_OBS_TRACES_EXPORT_ENABLED)),
|
||||
metrics_export_enabled: Some(get_env_bool(ENV_OBS_METRICS_EXPORT_ENABLED, DEFAULT_OBS_METRICS_EXPORT_ENABLED)),
|
||||
logs_export_enabled: Some(get_env_bool(ENV_OBS_LOGS_EXPORT_ENABLED, DEFAULT_OBS_LOGS_EXPORT_ENABLED)),
|
||||
profiling_export_enabled: Some(get_env_bool(ENV_OBS_PROFILING_EXPORT_ENABLED, DEFAULT_OBS_PROFILING_EXPORT_ENABLED)),
|
||||
profiling_export_enabled: Some(get_env_bool_with_aliases(
|
||||
ENV_OBS_PROFILING_EXPORT_ENABLED,
|
||||
&[LEGACY_ENV_OBS_PROFILING_ENABLED],
|
||||
DEFAULT_OBS_PROFILING_EXPORT_ENABLED,
|
||||
)),
|
||||
use_stdout: Some(use_stdout),
|
||||
sample_ratio: Some(get_env_f64(ENV_OBS_SAMPLE_RATIO, SAMPLE_RATIO)),
|
||||
meter_interval: Some(get_env_u64(ENV_OBS_METER_INTERVAL, METER_INTERVAL)),
|
||||
@@ -415,3 +424,38 @@ impl Default for AppConfig {
|
||||
pub fn is_production_environment() -> bool {
|
||||
get_env_str(ENV_OBS_ENVIRONMENT, ENVIRONMENT).eq_ignore_ascii_case(DEFAULT_OBS_ENVIRONMENT_PRODUCTION)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn profiling_export_defaults_to_disabled_when_unset() {
|
||||
temp_env::with_var_unset(ENV_OBS_PROFILING_EXPORT_ENABLED, || {
|
||||
temp_env::with_var_unset(LEGACY_ENV_OBS_PROFILING_ENABLED, || {
|
||||
let config = OtelConfig::extract_otel_config_from_env(None);
|
||||
assert_eq!(config.profiling_export_enabled, Some(false));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn profiling_export_accepts_legacy_env_alias() {
|
||||
temp_env::with_var_unset(ENV_OBS_PROFILING_EXPORT_ENABLED, || {
|
||||
temp_env::with_var(LEGACY_ENV_OBS_PROFILING_ENABLED, Some("true"), || {
|
||||
let config = OtelConfig::extract_otel_config_from_env(None);
|
||||
assert_eq!(config.profiling_export_enabled, Some(true));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn canonical_profiling_toggle_has_priority_over_legacy_alias() {
|
||||
temp_env::with_var(LEGACY_ENV_OBS_PROFILING_ENABLED, Some("true"), || {
|
||||
temp_env::with_var(ENV_OBS_PROFILING_EXPORT_ENABLED, Some("false"), || {
|
||||
let config = OtelConfig::extract_otel_config_from_env(None);
|
||||
assert_eq!(config.profiling_export_enabled, Some(false));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user