fix: resolve all doctest failures in rustfs-obs crate

This commit is contained in:
overtrue
2025-05-28 15:29:09 +08:00
parent cad2aa436b
commit 7069f9e7a2
3 changed files with 21 additions and 15 deletions
+2 -2
View File
@@ -44,9 +44,9 @@ pub enum GlobalError {
/// ```rust /// ```rust
/// use rustfs_obs::{init_telemetry, load_config, set_global_guard}; /// use rustfs_obs::{init_telemetry, load_config, set_global_guard};
/// ///
/// async fn init() -> Result<(), Box<dyn std::error::Error>> { /// fn init() -> Result<(), Box<dyn std::error::Error>> {
/// let config = load_config(None); /// let config = load_config(None);
/// let guard = init_telemetry(&config.observability).await?; /// let guard = init_telemetry(&config.observability);
/// set_global_guard(guard)?; /// set_global_guard(guard)?;
/// Ok(()) /// Ok(())
/// } /// }
+11 -5
View File
@@ -22,11 +22,14 @@
/// ///
/// ## Usage /// ## Usage
/// ///
/// ```rust /// ```no_run
/// use rustfs_obs::{AppConfig, init_obs}; /// use rustfs_obs::{AppConfig, init_obs};
/// ///
/// # #[tokio::main]
/// # async fn main() {
/// let config = AppConfig::default(); /// let config = AppConfig::default();
/// let (logger, guard) = init_obs(config); /// let (logger, guard) = init_obs(config).await;
/// # }
/// ``` /// ```
mod config; mod config;
mod entry; mod entry;
@@ -64,11 +67,14 @@ use tracing::{error, info};
/// A tuple containing the logger and the telemetry guard /// A tuple containing the logger and the telemetry guard
/// ///
/// # Example /// # Example
/// ``` /// ```no_run
/// use rustfs_obs::{AppConfig, init_obs}; /// use rustfs_obs::{AppConfig, init_obs};
/// ///
/// # #[tokio::main]
/// # async fn main() {
/// let config = AppConfig::default(); /// let config = AppConfig::default();
/// let (logger, guard) = init_obs(config); /// let (logger, guard) = init_obs(config).await;
/// # }
/// ``` /// ```
pub async fn init_obs(config: AppConfig) -> (Arc<Mutex<Logger>>, telemetry::OtelGuard) { pub async fn init_obs(config: AppConfig) -> (Arc<Mutex<Logger>>, telemetry::OtelGuard) {
let guard = init_telemetry(&config.observability); let guard = init_telemetry(&config.observability);
@@ -97,7 +103,7 @@ pub async fn init_obs(config: AppConfig) -> (Arc<Mutex<Logger>>, telemetry::Otel
/// A reference to the global logger instance /// A reference to the global logger instance
/// ///
/// # Example /// # Example
/// ``` /// ```no_run
/// use rustfs_obs::get_logger; /// use rustfs_obs::get_logger;
/// ///
/// let logger = get_logger(); /// let logger = get_logger();
+8 -8
View File
@@ -224,7 +224,7 @@ impl Logger {
/// # Returns /// # Returns
/// The global logger instance /// The global logger instance
/// # Example /// # Example
/// ``` /// ```no_run
/// use rustfs_obs::{AppConfig, start_logger}; /// use rustfs_obs::{AppConfig, start_logger};
/// ///
/// let config = AppConfig::default(); /// let config = AppConfig::default();
@@ -270,7 +270,7 @@ pub async fn init_global_logger(config: &AppConfig, sinks: Vec<Arc<dyn Sink>>) -
/// A reference to the global logger instance /// A reference to the global logger instance
/// ///
/// # Example /// # Example
/// ``` /// ```no_run
/// use rustfs_obs::get_global_logger; /// use rustfs_obs::get_global_logger;
/// ///
/// let logger = get_global_logger(); /// let logger = get_global_logger();
@@ -290,7 +290,7 @@ pub fn get_global_logger() -> &'static Arc<Mutex<Logger>> {
/// Result indicating whether the operation was successful /// Result indicating whether the operation was successful
/// ///
/// # Example /// # Example
/// ``` /// ```no_run
/// use rustfs_obs::log_info; /// use rustfs_obs::log_info;
/// ///
/// async fn example() { /// async fn example() {
@@ -309,7 +309,7 @@ pub async fn log_info(message: &str, source: &str) -> Result<(), GlobalError> {
/// # Returns /// # Returns
/// Result indicating whether the operation was successful /// Result indicating whether the operation was successful
/// # Example /// # Example
/// ``` /// ```no_run
/// use rustfs_obs::log_error; /// use rustfs_obs::log_error;
/// ///
/// async fn example() { /// async fn example() {
@@ -328,7 +328,7 @@ pub async fn log_error(message: &str, source: &str) -> Result<(), GlobalError> {
/// Result indicating whether the operation was successful /// Result indicating whether the operation was successful
/// ///
/// # Example /// # Example
/// ``` /// ```no_run
/// use rustfs_obs::log_warn; /// use rustfs_obs::log_warn;
/// ///
/// async fn example() { /// async fn example() {
@@ -348,7 +348,7 @@ pub async fn log_warn(message: &str, source: &str) -> Result<(), GlobalError> {
/// Result indicating whether the operation was successful /// Result indicating whether the operation was successful
/// ///
/// # Example /// # Example
/// ``` /// ```no_run
/// use rustfs_obs::log_debug; /// use rustfs_obs::log_debug;
/// ///
/// async fn example() { /// async fn example() {
@@ -369,7 +369,7 @@ pub async fn log_debug(message: &str, source: &str) -> Result<(), GlobalError> {
/// Result indicating whether the operation was successful /// Result indicating whether the operation was successful
/// ///
/// # Example /// # Example
/// ``` /// ```no_run
/// use rustfs_obs::log_trace; /// use rustfs_obs::log_trace;
/// ///
/// async fn example() { /// async fn example() {
@@ -392,7 +392,7 @@ pub async fn log_trace(message: &str, source: &str) -> Result<(), GlobalError> {
/// # Returns /// # Returns
/// Result indicating whether the operation was successful /// Result indicating whether the operation was successful
/// # Example /// # Example
/// ``` /// ```no_run
/// use tracing_core::Level; /// use tracing_core::Level;
/// use rustfs_obs::log_with_context; /// use rustfs_obs::log_with_context;
/// ///