refactor(obs): migrate metrics runtime/schema and tighten migration guards (#2584)

This commit is contained in:
houseme
2026-04-18 15:51:15 +08:00
committed by GitHub
parent 03f8270a60
commit 1cbf156559
98 changed files with 1536 additions and 652 deletions
+21 -1
View File
@@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{BucketNotificationConfig, Event, EventArgs, LifecycleError, NotificationError, NotificationSystem};
use crate::{
BucketNotificationConfig, Event, EventArgs, LifecycleError, NotificationError, NotificationMetricSnapshot,
NotificationSystem, NotificationTargetMetricSnapshot,
};
use rustfs_ecstore::config::Config;
use rustfs_s3_common::EventName;
use rustfs_targets::arn::TargetID;
@@ -41,6 +44,23 @@ pub fn notification_system() -> Option<Arc<NotificationSystem>> {
NOTIFICATION_SYSTEM.get().cloned()
}
/// Returns aggregate notification delivery metrics for Prometheus collection.
pub fn notification_metrics_snapshot() -> NotificationMetricSnapshot {
NOTIFICATION_SYSTEM
.get()
.map(|system| system.snapshot_metrics())
.unwrap_or_default()
}
/// Returns per-target notification delivery metrics for Prometheus collection.
pub async fn notification_target_metrics() -> Vec<NotificationTargetMetricSnapshot> {
if let Some(system) = notification_system() {
system.snapshot_target_metrics().await
} else {
Vec::new()
}
}
/// Check if the notification system has been initialized.
pub fn is_notification_system_initialized() -> bool {
NOTIFICATION_SYSTEM.get().is_some()