rustfs_obs/lib.rs
1// Copyright 2024 RustFS Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! # RustFS Observability
16//!
17//! provides tools for system and service monitoring
18//!
19//! ## Features
20//!
21//! This crate provides observability tools for RustFS:
22//! - Logging with tracing
23//! - Metrics collection
24//! - Distributed tracing
25//! - Tokio runtime telemetry (via dial9)
26//!
27//! ## Usage
28//!
29//! ```no_run
30//! use rustfs_obs::init_obs;
31//!
32//! # #[tokio::main]
33//! # async fn main() {
34//! # let _guard = match init_obs(None).await {
35//! # Ok(g) => g,
36//! # Err(e) => {
37//! # panic!("Failed to initialize observability: {:?}", e);
38//! # }
39//! # };
40//! # // Application logic here
41//! # {
42//! # // Simulate some work
43//! # tokio::time::sleep(std::time::Duration::from_secs(2)).await;
44//! # println!("Application is running...");
45//! # }
46//! # // Guard will be dropped here, flushing telemetry data
47//! # }
48//! ```
49//!
50//! ## Metrics Runtime
51//!
52//! Start metrics scheduling with `rustfs_obs::init_metrics_runtime()`.
53//!
54//! ```ignore
55//! use tokio_util::sync::CancellationToken;
56//! use rustfs_obs::init_metrics_runtime;
57//!
58//! let token = CancellationToken::new();
59//! init_metrics_runtime(token.clone());
60//! ```
61mod cleaner;
62mod config;
63mod error;
64mod global;
65mod logging;
66pub mod metrics;
67mod node_identity;
68mod telemetry;
69
70pub use cleaner::*;
71pub use config::*;
72pub use error::*;
73pub use global::*;
74pub use logging::*;
75pub use metrics::schema::*;
76pub use metrics::{
77 MetricsRuntimeCancellationSource, MetricsRuntimeController, MetricsRuntimeControllerSnapshot, MetricsRuntimeDesiredSnapshot,
78 MetricsRuntimeDesiredState, MetricsRuntimeIntervalsSnapshot, MetricsRuntimeReconcilePlan, MetricsRuntimeServiceState,
79 MetricsRuntimeShutdownHandle, MetricsRuntimeStatusSnapshot, MetricsRuntimeWorkerMutation, init_metrics_runtime,
80 metrics_runtime_controller_snapshot, metrics_runtime_status_snapshot,
81};
82pub use telemetry::{HTTP_SERVER_LOG_TARGET, OtelGuard, Recorder};
83
84// Dial9 Tokio runtime telemetry
85// Re-export dial9 types at crate root level for easier access
86pub use telemetry::dial9;