obs(export): Add env vars to selectivly disable exporting traces/metrics/logs (#1853)

Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
evan slack
2026-02-17 11:38:30 -05:00
committed by GitHub
parent cf633569a2
commit 8010284aa3
4 changed files with 57 additions and 21 deletions
+6 -5
View File
@@ -33,8 +33,9 @@ use opentelemetry_semantic_conventions::{
attribute::{DEPLOYMENT_ENVIRONMENT_NAME, NETWORK_LOCAL_ADDRESS, SERVICE_VERSION as OTEL_SERVICE_VERSION},
};
use rustfs_config::{
APP_NAME, DEFAULT_LOG_KEEP_FILES, DEFAULT_LOG_LEVEL, DEFAULT_OBS_LOG_STDOUT_ENABLED, ENVIRONMENT, METER_INTERVAL,
SAMPLE_RATIO, SERVICE_VERSION,
APP_NAME, DEFAULT_LOG_KEEP_FILES, DEFAULT_LOG_LEVEL, DEFAULT_OBS_LOG_STDOUT_ENABLED, DEFAULT_OBS_LOGS_EXPORT_ENABLED,
DEFAULT_OBS_METRICS_EXPORT_ENABLED, DEFAULT_OBS_TRACES_EXPORT_ENABLED, ENVIRONMENT, METER_INTERVAL, SAMPLE_RATIO,
SERVICE_VERSION,
observability::{
DEFAULT_OBS_ENVIRONMENT_PRODUCTION, DEFAULT_OBS_LOG_FLUSH_MS, DEFAULT_OBS_LOG_MESSAGE_CAPA, DEFAULT_OBS_LOG_POOL_CAPA,
ENV_OBS_LOG_DIRECTORY, ENV_OBS_LOG_FLUSH_MS, ENV_OBS_LOG_MESSAGE_CAPA, ENV_OBS_LOG_POOL_CAPA,
@@ -417,7 +418,7 @@ fn init_observability_http(config: &OtelConfig, logger_level: &str, is_productio
// TracerHTTP
let tracer_provider = {
if trace_ep.is_empty() {
if trace_ep.is_empty() || !config.traces_export_enabled.unwrap_or(DEFAULT_OBS_TRACES_EXPORT_ENABLED) {
None
} else {
let exporter = opentelemetry_otlp::SpanExporter::builder()
@@ -447,7 +448,7 @@ fn init_observability_http(config: &OtelConfig, logger_level: &str, is_productio
// MeterHTTP
let meter_provider = {
if metric_ep.is_empty() {
if metric_ep.is_empty() || !config.metrics_export_enabled.unwrap_or(DEFAULT_OBS_METRICS_EXPORT_ENABLED) {
None
} else {
let exporter = opentelemetry_otlp::MetricExporter::builder()
@@ -482,7 +483,7 @@ fn init_observability_http(config: &OtelConfig, logger_level: &str, is_productio
// LoggerHTTP
let logger_provider = {
if log_ep.is_empty() {
if log_ep.is_empty() || !config.logs_export_enabled.unwrap_or(DEFAULT_OBS_LOGS_EXPORT_ENABLED) {
None
} else {
let exporter = opentelemetry_otlp::LogExporter::builder()