Files
rustfs/crates/obs
houseme 29056a767a Refactor Telemetry Initialization and Environment Utilities (#811)
* improve code for metrics

* improve code for metrics

* fix

* fix

* Refactor telemetry initialization and environment functions ordering

- Reorder functions in envs.rs by type size (8-bit to 64-bit, signed before unsigned) and add missing variants like get_env_opt_u16.
- Optimize init_telemetry to support three modes: stdout logging (default error level with span tracing), file rolling logs (size-based with retention), and HTTP-based observability with sub-endpoints (trace, metric, log) falling back to unified endpoint.
- Fix stdout logging issue by retaining WorkerGuard in OtelGuard to prevent premature release of async writer threads.
- Enhance observability mode with HTTP protocol, compression, and proper resource management.
- Update OtelGuard to include tracing_guard for stdout and flexi_logger_handles for file logging.
- Improve error handling and configuration extraction in OtelConfig.

* fix

* up

* fix

* fix

* improve code for obs

* fix

* fix
2025-11-07 20:01:54 +08:00
..

RustFS

RustFS Obs - Observability & Monitoring

Comprehensive observability and monitoring system for RustFS distributed object storage

CI 📖 Documentation · 🐛 Bug Reports · 💬 Discussions


📖 Overview

RustFS Obs provides comprehensive observability and monitoring capabilities for the RustFS distributed object storage system. For the complete RustFS experience, please visit the main RustFS repository.

Features

  • Environment-Aware Logging: Automatically configures logging behavior based on deployment environment
    • Production: File-only logging (stdout disabled by default for security and log aggregation)
    • Development/Test: Full logging with stdout support for debugging
  • OpenTelemetry integration for distributed tracing
  • Prometheus metrics collection and exposition
  • Structured logging with configurable levels and rotation
  • Performance profiling and analytics
  • Real-time health checks and status monitoring
  • Custom dashboards and alerting integration
  • Enhanced error handling and resilience

🚀 Environment-Aware Logging

The obs module automatically adapts logging behavior based on your deployment environment:

Production Environment

# Set production environment - disables stdout logging by default
export RUSTFS_OBS_ENVIRONMENT=production

# All logs go to files only (no stdout) for security and log aggregation
# Enhanced error handling with clear failure diagnostics

Development/Test Environment

# Set development environment - enables stdout logging
export RUSTFS_OBS_ENVIRONMENT=development

# Logs appear both in files and stdout for easier debugging
# Full span tracking and verbose error messages

Configuration Override

You can always override the environment defaults:

use rustfs_obs::OtelConfig;

let config = OtelConfig {
    endpoint: "".to_string(),
    use_stdout: Some(true), // Explicit override - forces stdout even in production
    environment: Some("production".to_string()),
    ..Default::default()
};

Supported Environment Values

  • production - Secure file-only logging
  • development - Full debugging with stdout
  • test - Test environment with stdout support
  • staging - Staging environment with stdout support

📚 Documentation

For comprehensive documentation, examples, and usage guides, please visit the main RustFS repository.

📄 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.