mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 08:18:18 +00:00
fix(obs): disable profiling export by default and fix Helm env name (#2719)
This commit is contained in:
@@ -296,9 +296,9 @@ pub const DEFAULT_OBS_LOGS_EXPORT_ENABLED: bool = true;
|
|||||||
|
|
||||||
/// Default profiling export enabled
|
/// Default profiling export enabled
|
||||||
/// It is used to enable or disable exporting profiles
|
/// It is used to enable or disable exporting profiles
|
||||||
/// Default value: true
|
/// Default value: false
|
||||||
/// Environment variable: RUSTFS_OBS_PROFILING_EXPORT_ENABLED
|
/// Environment variable: RUSTFS_OBS_PROFILING_EXPORT_ENABLED
|
||||||
pub const DEFAULT_OBS_PROFILING_EXPORT_ENABLED: bool = true;
|
pub const DEFAULT_OBS_PROFILING_EXPORT_ENABLED: bool = false;
|
||||||
|
|
||||||
/// Default log local logging enabled for rustfs
|
/// Default log local logging enabled for rustfs
|
||||||
/// This is the default log local logging enabled for rustfs.
|
/// This is the default log local logging enabled for rustfs.
|
||||||
|
|||||||
@@ -80,7 +80,9 @@ The library selects a backend automatically based on configuration:
|
|||||||
|
|
||||||
```
|
```
|
||||||
1. Any OTLP endpoint set?
|
1. Any OTLP endpoint set?
|
||||||
└─ YES → Full OTLP/HTTP pipeline (traces + metrics + logs + profiling)
|
└─ YES → Full OTLP/HTTP pipeline (traces + metrics + logs)
|
||||||
|
+ Profiling (Pyroscope) only if:
|
||||||
|
- RUSTFS_OBS_PROFILING_EXPORT_ENABLED=true (explicit opt-in, default: false)
|
||||||
|
|
||||||
2. RUSTFS_OBS_LOG_DIRECTORY set to a non-empty path?
|
2. RUSTFS_OBS_LOG_DIRECTORY set to a non-empty path?
|
||||||
└─ YES → Rolling-file JSON logging
|
└─ YES → Rolling-file JSON logging
|
||||||
@@ -117,7 +119,7 @@ All configuration is read from environment variables at startup.
|
|||||||
| `RUSTFS_OBS_TRACES_EXPORT_ENABLED` | `true` | Toggle trace export |
|
| `RUSTFS_OBS_TRACES_EXPORT_ENABLED` | `true` | Toggle trace export |
|
||||||
| `RUSTFS_OBS_METRICS_EXPORT_ENABLED` | `true` | Toggle metrics export |
|
| `RUSTFS_OBS_METRICS_EXPORT_ENABLED` | `true` | Toggle metrics export |
|
||||||
| `RUSTFS_OBS_LOGS_EXPORT_ENABLED` | `true` | Toggle OTLP log export |
|
| `RUSTFS_OBS_LOGS_EXPORT_ENABLED` | `true` | Toggle OTLP log export |
|
||||||
| `RUSTFS_OBS_PROFILING_EXPORT_ENABLED` | `true` | Toggle profiling export |
|
| `RUSTFS_OBS_PROFILING_EXPORT_ENABLED` | `false` | Toggle profiling export |
|
||||||
| `RUSTFS_OBS_USE_STDOUT` | `false` | Mirror all signals to stdout alongside OTLP |
|
| `RUSTFS_OBS_USE_STDOUT` | `false` | Mirror all signals to stdout alongside OTLP |
|
||||||
| `RUSTFS_OBS_SAMPLE_RATIO` | `0.1` | Trace sampling ratio `0.0`–`1.0` |
|
| `RUSTFS_OBS_SAMPLE_RATIO` | `0.1` | Trace sampling ratio `0.0`–`1.0` |
|
||||||
| `RUSTFS_OBS_METER_INTERVAL` | `15` | Metrics export interval (seconds) |
|
| `RUSTFS_OBS_METER_INTERVAL` | `15` | Metrics export interval (seconds) |
|
||||||
|
|||||||
@@ -48,10 +48,15 @@ use rustfs_config::{
|
|||||||
DEFAULT_OBS_PROFILING_EXPORT_ENABLED, DEFAULT_OBS_TRACES_EXPORT_ENABLED, ENVIRONMENT, METER_INTERVAL, SAMPLE_RATIO,
|
DEFAULT_OBS_PROFILING_EXPORT_ENABLED, DEFAULT_OBS_TRACES_EXPORT_ENABLED, ENVIRONMENT, METER_INTERVAL, SAMPLE_RATIO,
|
||||||
SERVICE_VERSION, USE_STDOUT,
|
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 serde::{Deserialize, Serialize};
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
const LEGACY_ENV_OBS_PROFILING_ENABLED: &str = "RUSTFS_OBS_PROFILING_ENABLED";
|
||||||
|
|
||||||
/// Full observability configuration used by all telemetry backends.
|
/// Full observability configuration used by all telemetry backends.
|
||||||
///
|
///
|
||||||
/// Fields are grouped into three logical sections:
|
/// Fields are grouped into three logical sections:
|
||||||
@@ -134,7 +139,7 @@ pub struct OtelConfig {
|
|||||||
pub metrics_export_enabled: Option<bool>,
|
pub metrics_export_enabled: Option<bool>,
|
||||||
/// Whether to export logs via OTLP (default: `true`).
|
/// Whether to export logs via OTLP (default: `true`).
|
||||||
pub logs_export_enabled: Option<bool>,
|
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>,
|
pub profiling_export_enabled: Option<bool>,
|
||||||
/// **[OTLP-only]** Mirror all signals to stdout in addition to OTLP export.
|
/// **[OTLP-only]** Mirror all signals to stdout in addition to OTLP export.
|
||||||
/// Only applies when an OTLP endpoint is configured.
|
/// 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)),
|
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)),
|
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)),
|
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),
|
use_stdout: Some(use_stdout),
|
||||||
sample_ratio: Some(get_env_f64(ENV_OBS_SAMPLE_RATIO, SAMPLE_RATIO)),
|
sample_ratio: Some(get_env_f64(ENV_OBS_SAMPLE_RATIO, SAMPLE_RATIO)),
|
||||||
meter_interval: Some(get_env_u64(ENV_OBS_METER_INTERVAL, METER_INTERVAL)),
|
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 {
|
pub fn is_production_environment() -> bool {
|
||||||
get_env_str(ENV_OBS_ENVIRONMENT, ENVIRONMENT).eq_ignore_ascii_case(DEFAULT_OBS_ENVIRONMENT_PRODUCTION)
|
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));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,9 +65,10 @@ data:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if .profiling.enabled }}
|
{{- if .profiling.enabled }}
|
||||||
RUSTFS_OBS_PROFILING_ENDPOINT: {{ .profiling.endpoint | quote }}
|
RUSTFS_OBS_PROFILING_ENDPOINT: {{ .profiling.endpoint | quote }}
|
||||||
|
RUSTFS_OBS_PROFILING_EXPORT_ENABLED: "true"
|
||||||
{{- else }}
|
{{- else }}
|
||||||
RUSTFS_OBS_PROFILING_ENDPOINT: ""
|
RUSTFS_OBS_PROFILING_ENDPOINT: ""
|
||||||
RUSTFS_OBS_PROFILING_ENABLED: "false"
|
RUSTFS_OBS_PROFILING_EXPORT_ENABLED: "false"
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
Reference in New Issue
Block a user