improve comment and error

This commit is contained in:
houseme
2025-05-16 17:00:56 +08:00
parent 60635aeb65
commit 6659b77f9a
29 changed files with 228 additions and 235 deletions

View File

@@ -1,7 +1,6 @@
/// bucket level s3 metric descriptor
use crate::metrics::{new_counter_md, new_gauge_md, new_histogram_md, subsystems, MetricDescriptor, MetricName};
lazy_static::lazy_static! {
pub static ref BUCKET_API_TRAFFIC_SENT_BYTES_MD: MetricDescriptor =
new_counter_md(

View File

@@ -1,10 +1,13 @@
/// Bucket copy metric descriptor
use crate::metrics::{new_counter_md, new_gauge_md, subsystems, MetricDescriptor, MetricName};
// Label constants
/// Bucket level replication metric descriptor
pub const BUCKET_L: &str = "bucket";
/// Replication operation
pub const OPERATION_L: &str = "operation";
/// Replication target ARN
pub const TARGET_ARN_L: &str = "targetArn";
/// Replication range
pub const RANGE_L: &str = "range";
lazy_static::lazy_static! {

View File

@@ -1,12 +1,12 @@
/// Metric descriptors related to cluster configuration
use crate::metrics::{new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// 集群配置相关指标描述符
lazy_static::lazy_static! {
pub static ref CONFIG_RRS_PARITY_MD: MetricDescriptor =
new_gauge_md(
MetricName::ConfigRRSParity,
"Reduced redundancy storage class parity",
&[], // 无标签
&[],
subsystems::CLUSTER_CONFIG
);
@@ -14,7 +14,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ConfigStandardParity,
"Standard storage class parity",
&[], // 无标签
&[],
subsystems::CLUSTER_CONFIG
);
}

View File

@@ -1,16 +1,17 @@
/// Erasure code set related metric descriptors
use crate::metrics::{new_gauge_md, subsystems, MetricDescriptor, MetricName};
// 定义标签常量
/// The label for the pool ID
pub const POOL_ID_L: &str = "pool_id";
/// The label for the pool ID
pub const SET_ID_L: &str = "set_id";
/// 纠删码集合相关指标描述符
lazy_static::lazy_static! {
pub static ref ERASURE_SET_OVERALL_WRITE_QUORUM_MD: MetricDescriptor =
new_gauge_md(
MetricName::ErasureSetOverallWriteQuorum,
"Overall write quorum across pools and sets",
&[], // 无标签
&[],
subsystems::CLUSTER_ERASURE_SET
);
@@ -18,7 +19,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ErasureSetOverallHealth,
"Overall health across pools and sets (1=healthy, 0=unhealthy)",
&[], // 无标签
&[],
subsystems::CLUSTER_ERASURE_SET
);

View File

@@ -1,12 +1,12 @@
/// Cluster health-related metric descriptors
use crate::metrics::{new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// 集群健康相关指标描述符
lazy_static::lazy_static! {
pub static ref HEALTH_DRIVES_OFFLINE_COUNT_MD: MetricDescriptor =
new_gauge_md(
MetricName::HealthDrivesOfflineCount,
"Count of offline drives in the cluster",
&[], // 无标签
&[],
subsystems::CLUSTER_HEALTH
);
@@ -14,7 +14,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::HealthDrivesOnlineCount,
"Count of online drives in the cluster",
&[], // 无标签
&[],
subsystems::CLUSTER_HEALTH
);
@@ -22,7 +22,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::HealthDrivesCount,
"Count of all drives in the cluster",
&[], // 无标签
&[],
subsystems::CLUSTER_HEALTH
);
}

View File

@@ -1,12 +1,12 @@
/// IAM related metric descriptors
use crate::metrics::{new_counter_md, subsystems, MetricDescriptor, MetricName};
/// IAM 相关指标描述符
lazy_static::lazy_static! {
pub static ref LAST_SYNC_DURATION_MILLIS_MD: MetricDescriptor =
new_counter_md(
MetricName::LastSyncDurationMillis,
"Last successful IAM data sync duration in milliseconds",
&[], // 无标签
&[],
subsystems::CLUSTER_IAM
);
@@ -14,7 +14,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::PluginAuthnServiceFailedRequestsMinute,
"When plugin authentication is configured, returns failed requests count in the last full minute",
&[], // 无标签
&[],
subsystems::CLUSTER_IAM
);
@@ -22,7 +22,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::PluginAuthnServiceLastFailSeconds,
"When plugin authentication is configured, returns time (in seconds) since the last failed request to the service",
&[], // 无标签
&[],
subsystems::CLUSTER_IAM
);
@@ -30,7 +30,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::PluginAuthnServiceLastSuccSeconds,
"When plugin authentication is configured, returns time (in seconds) since the last successful request to the service",
&[], // 无标签
&[],
subsystems::CLUSTER_IAM
);
@@ -38,7 +38,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::PluginAuthnServiceSuccAvgRttMsMinute,
"When plugin authentication is configured, returns average round-trip-time of successful requests in the last full minute",
&[], // 无标签
&[],
subsystems::CLUSTER_IAM
);
@@ -46,7 +46,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::PluginAuthnServiceSuccMaxRttMsMinute,
"When plugin authentication is configured, returns maximum round-trip-time of successful requests in the last full minute",
&[], // 无标签
&[],
subsystems::CLUSTER_IAM
);
@@ -54,7 +54,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::PluginAuthnServiceTotalRequestsMinute,
"When plugin authentication is configured, returns total requests count in the last full minute",
&[], // 无标签
&[],
subsystems::CLUSTER_IAM
);
@@ -62,7 +62,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::SinceLastSyncMillis,
"Time (in milliseconds) since last successful IAM data sync.",
&[], // 无标签
&[],
subsystems::CLUSTER_IAM
);
@@ -70,7 +70,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::SyncFailures,
"Number of failed IAM data syncs since server start.",
&[], // 无标签
&[],
subsystems::CLUSTER_IAM
);
@@ -78,7 +78,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::SyncSuccesses,
"Number of successful IAM data syncs since server start.",
&[], // 无标签
&[],
subsystems::CLUSTER_IAM
);
}

View File

@@ -1,12 +1,12 @@
/// Notify the relevant metric descriptor
use crate::metrics::{new_counter_md, subsystems, MetricDescriptor, MetricName};
/// 通知相关指标描述符
lazy_static::lazy_static! {
pub static ref NOTIFICATION_CURRENT_SEND_IN_PROGRESS_MD: MetricDescriptor =
new_counter_md(
MetricName::NotificationCurrentSendInProgress,
"Number of concurrent async Send calls active to all targets",
&[], // 无标签
&[],
subsystems::NOTIFICATION
);
@@ -14,7 +14,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::NotificationEventsErrorsTotal,
"Events that were failed to be sent to the targets",
&[], // 无标签
&[],
subsystems::NOTIFICATION
);
@@ -22,7 +22,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::NotificationEventsSentTotal,
"Total number of events sent to the targets",
&[], // 无标签
&[],
subsystems::NOTIFICATION
);
@@ -30,7 +30,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::NotificationEventsSkippedTotal,
"Events that were skipped to be sent to the targets due to the in-memory queue being full",
&[], // 无标签
&[],
subsystems::NOTIFICATION
);
}

View File

@@ -1,12 +1,17 @@
/// Descriptors of metrics related to cluster object and bucket usage
use crate::metrics::{new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// 集群对象使用情况相关指标描述符
/// Bucket labels
pub const BUCKET_LABEL: &str = "bucket";
/// Range labels
pub const RANGE_LABEL: &str = "range";
lazy_static::lazy_static! {
pub static ref USAGE_SINCE_LAST_UPDATE_SECONDS_MD: MetricDescriptor =
new_gauge_md(
MetricName::UsageSinceLastUpdateSeconds,
"Time since last update of usage metrics in seconds",
&[], // 无标签
&[],
subsystems::CLUSTER_USAGE_OBJECTS
);
@@ -14,7 +19,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::UsageTotalBytes,
"Total cluster usage in bytes",
&[], // 无标签
&[],
subsystems::CLUSTER_USAGE_OBJECTS
);
@@ -22,7 +27,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::UsageObjectsCount,
"Total cluster objects count",
&[], // 无标签
&[],
subsystems::CLUSTER_USAGE_OBJECTS
);
@@ -30,7 +35,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::UsageVersionsCount,
"Total cluster object versions (including delete markers) count",
&[], // 无标签
&[],
subsystems::CLUSTER_USAGE_OBJECTS
);
@@ -38,7 +43,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::UsageDeleteMarkersCount,
"Total cluster delete markers count",
&[], // 无标签
&[],
subsystems::CLUSTER_USAGE_OBJECTS
);
@@ -46,7 +51,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::UsageBucketsCount,
"Total cluster buckets count",
&[], // 无标签
&[],
subsystems::CLUSTER_USAGE_OBJECTS
);
@@ -54,7 +59,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::UsageSizeDistribution,
"Cluster object size distribution",
&["range"], // 标签
&[RANGE_LABEL],
subsystems::CLUSTER_USAGE_OBJECTS
);
@@ -62,16 +67,11 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::UsageVersionCountDistribution,
"Cluster object version count distribution",
&["range"], // 标签
&[RANGE_LABEL],
subsystems::CLUSTER_USAGE_OBJECTS
);
}
/// 定义常量
pub const BUCKET_LABEL: &str = "bucket";
pub const RANGE_LABEL: &str = "range";
/// 桶使用情况相关指标描述符
lazy_static::lazy_static! {
pub static ref USAGE_BUCKET_TOTAL_BYTES_MD: MetricDescriptor =
new_gauge_md(

View File

@@ -1,7 +1,7 @@
use crate::metrics::{MetricName, MetricNamespace, MetricSubsystem, MetricType};
use std::collections::HashSet;
/// MetricDescriptor - 指标描述符
/// MetricDescriptor - Metric descriptors
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct MetricDescriptor {
@@ -10,21 +10,21 @@ pub struct MetricDescriptor {
pub help: String,
pub variable_labels: Vec<String>,
pub namespace: MetricNamespace,
pub subsystem: MetricSubsystem, // 从 String 修改为 MetricSubsystem
pub subsystem: MetricSubsystem,
// 内部管理值
// Internal management values
label_set: Option<HashSet<String>>,
}
impl MetricDescriptor {
/// 创建新的指标描述符
/// Create a new metric descriptor
pub fn new(
name: MetricName,
metric_type: MetricType,
help: String,
variable_labels: Vec<String>,
namespace: MetricNamespace,
subsystem: impl Into<MetricSubsystem>, // 修改参数类型
subsystem: impl Into<MetricSubsystem>, // Modify the parameter type
) -> Self {
Self {
name,
@@ -37,23 +37,23 @@ impl MetricDescriptor {
}
}
/// 获取完整的指标名称,包含前缀和格式化路径
/// Get the full metric name, including the prefix and formatting path
#[allow(dead_code)]
pub fn get_full_metric_name(&self) -> String {
let prefix = self.metric_type.to_prom();
let prefix = self.metric_type.as_prom();
let namespace = self.namespace.as_str();
let formatted_subsystem = self.subsystem.as_str();
format!("{}{}_{}_{}", prefix, namespace, formatted_subsystem, self.name.as_str())
}
/// 检查标签是否在标签集中
/// check whether the label is in the label set
#[allow(dead_code)]
pub fn has_label(&mut self, label: &str) -> bool {
self.get_label_set().contains(label)
}
/// 获取标签集合,如果不存在则创建
/// Gets a collection of tags and creates them if they don't exist
pub fn get_label_set(&mut self) -> &HashSet<String> {
if self.label_set.is_none() {
let mut set = HashSet::with_capacity(self.variable_labels.len());

View File

@@ -2,7 +2,7 @@
#[allow(dead_code)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum MetricName {
// 通用指标名称
// The generic metric name
AuthTotal,
CanceledTotal,
ErrorsTotal,
@@ -27,7 +27,7 @@ pub enum MetricName {
Total,
FreeInodes,
// 失败统计指标
// Failure statistical metrics
LastMinFailedCount,
LastMinFailedBytes,
LastHourFailedCount,
@@ -35,7 +35,7 @@ pub enum MetricName {
TotalFailedCount,
TotalFailedBytes,
// 工作线程指标
// Worker metrics
CurrActiveWorkers,
AvgActiveWorkers,
MaxActiveWorkers,
@@ -49,23 +49,23 @@ pub enum MetricName {
MaxTransferRate,
CredentialErrors,
// 链接延迟指标
// Link latency metrics
CurrLinkLatency,
AvgLinkLatency,
MaxLinkLatency,
// 链接状态指标
// Link status metrics
LinkOnline,
LinkOfflineDuration,
LinkDowntimeTotalDuration,
// 队列指标
// Queue metrics
AvgInQueueCount,
AvgInQueueBytes,
MaxInQueueCount,
MaxInQueueBytes,
// 代理请求指标
// Proxy request metrics
ProxiedGetRequestsTotal,
ProxiedHeadRequestsTotal,
ProxiedPutTaggingRequestsTotal,
@@ -77,7 +77,7 @@ pub enum MetricName {
ProxiedGetTaggingRequestFailures,
ProxiedDeleteTaggingRequestFailures,
// 字节相关指标
// Byte-related metrics
FreeBytes,
ReadBytes,
RcharBytes,
@@ -89,22 +89,22 @@ pub enum MetricName {
WriteBytes,
WcharBytes,
// 延迟指标
// Latency metrics
LatencyMicroSec,
LatencyNanoSec,
// 信息指标
// Information metrics
CommitInfo,
UsageInfo,
VersionInfo,
// 分布指标
// Distribution metrics
SizeDistribution,
VersionDistribution,
TtfbDistribution,
TtlbDistribution,
// 时间指标
// Time metrics
LastActivityTime,
StartTime,
UpTime,
@@ -112,7 +112,7 @@ pub enum MetricName {
Vmemory,
Cpu,
// 过期和转换指标
// Expiration and conversion metrics
ExpiryMissedTasks,
ExpiryMissedFreeVersions,
ExpiryMissedTierJournalTasks,
@@ -122,18 +122,18 @@ pub enum MetricName {
TransitionedObjects,
TransitionedVersions,
// Tier 请求指标
//Tier request metrics
TierRequestsSuccess,
TierRequestsFailure,
// KMS 指标
// KMS metrics
KmsOnline,
KmsRequestsSuccess,
KmsRequestsError,
KmsRequestsFail,
KmsUptime,
// Webhook 指标
// Webhook metrics
WebhookOnline,
// API 拒绝指标
@@ -142,7 +142,7 @@ pub enum MetricName {
ApiRejectedTimestampTotal,
ApiRejectedInvalidTotal,
// API 请求指标
//API request metrics
ApiRequestsWaitingTotal,
ApiRequestsIncomingTotal,
ApiRequestsInFlightTotal,
@@ -152,23 +152,23 @@ pub enum MetricName {
ApiRequests4xxErrorsTotal,
ApiRequestsCanceledTotal,
// API 分布指标
// API distribution metrics
ApiRequestsTTFBSecondsDistribution,
// API 流量指标
// API traffic metrics
ApiTrafficSentBytes,
ApiTrafficRecvBytes,
// 审计指标
// Audit metrics
AuditFailedMessages,
AuditTargetQueueLength,
AuditTotalMessages,
// 集群配置相关指标
// Metrics related to cluster configurations
ConfigRRSParity,
ConfigStandardParity,
// 纠删码集合相关指标
// Erasure coding set related metrics
ErasureSetOverallWriteQuorum,
ErasureSetOverallHealth,
ErasureSetReadQuorum,
@@ -181,12 +181,12 @@ pub enum MetricName {
ErasureSetReadHealth,
ErasureSetWriteHealth,
// 集群健康相关指标
// Cluster health-related metrics
HealthDrivesOfflineCount,
HealthDrivesOnlineCount,
HealthDrivesCount,
// IAM 相关指标
// IAM-related metrics
LastSyncDurationMillis,
PluginAuthnServiceFailedRequestsMinute,
PluginAuthnServiceLastFailSeconds,
@@ -198,13 +198,13 @@ pub enum MetricName {
SyncFailures,
SyncSuccesses,
// 通知相关指标
// Notify relevant metrics
NotificationCurrentSendInProgress,
NotificationEventsErrorsTotal,
NotificationEventsSentTotal,
NotificationEventsSkippedTotal,
// 集群对象使用情况相关指标
// Metrics related to the usage of cluster objects
UsageSinceLastUpdateSeconds,
UsageTotalBytes,
UsageObjectsCount,
@@ -214,7 +214,7 @@ pub enum MetricName {
UsageSizeDistribution,
UsageVersionCountDistribution,
// 桶使用情况相关指标
// Metrics related to bucket usage
UsageBucketQuotaTotalBytes,
UsageBucketTotalBytes,
UsageBucketObjectsCount,
@@ -223,19 +223,19 @@ pub enum MetricName {
UsageBucketObjectSizeDistribution,
UsageBucketObjectVersionCountDistribution,
// ILM 相关指标
// ILM-related metrics
IlmExpiryPendingTasks,
IlmTransitionActiveTasks,
IlmTransitionPendingTasks,
IlmTransitionMissedImmediateTasks,
IlmVersionsScanned,
// Webhook 日志相关指标
// Webhook logs
WebhookQueueLength,
WebhookTotalMessages,
WebhookFailedMessages,
// 复制相关指标
// Copy the relevant metrics
ReplicationAverageActiveWorkers,
ReplicationAverageQueuedBytes,
ReplicationAverageQueuedCount,
@@ -250,7 +250,7 @@ pub enum MetricName {
ReplicationMaxDataTransferRate,
ReplicationRecentBacklogCount,
// 扫描器相关指标
// Scanner-related metrics
ScannerBucketScansFinished,
ScannerBucketScansStarted,
ScannerDirectoriesScanned,
@@ -258,7 +258,7 @@ pub enum MetricName {
ScannerVersionsScanned,
ScannerLastActivitySeconds,
// CPU 系统相关指标
// CPU system-related metrics
SysCPUAvgIdle,
SysCPUAvgIOWait,
SysCPULoad,
@@ -268,7 +268,7 @@ pub enum MetricName {
SysCPUSystem,
SysCPUUser,
// 驱动器相关指标
// Drive-related metrics
DriveUsedBytes,
DriveFreeBytes,
DriveTotalBytes,
@@ -286,7 +286,7 @@ pub enum MetricName {
DriveOnlineCount,
DriveCount,
// iostat 相关指标
// iostat related metrics
DriveReadsPerSec,
DriveReadsKBPerSec,
DriveReadsAwait,
@@ -295,7 +295,7 @@ pub enum MetricName {
DriveWritesAwait,
DrivePercUtil,
// 内存相关指标
// Memory-related metrics
MemTotal,
MemUsed,
MemUsedPerc,
@@ -305,14 +305,14 @@ pub enum MetricName {
MemShared,
MemAvailable,
// 网络相关指标
// Network-related metrics
InternodeErrorsTotal,
InternodeDialErrorsTotal,
InternodeDialAvgTimeNanos,
InternodeSentBytesTotal,
InternodeRecvBytesTotal,
// 进程相关指标
// Process-related metrics
ProcessLocksReadTotal,
ProcessLocksWriteTotal,
ProcessCPUTotalSeconds,
@@ -331,7 +331,7 @@ pub enum MetricName {
ProcessVirtualMemoryBytes,
ProcessVirtualMemoryMaxBytes,
// 自定义指标
// Custom metrics
Custom(String),
}
@@ -485,7 +485,7 @@ impl MetricName {
Self::ConfigRRSParity => "rrs_parity".to_string(),
Self::ConfigStandardParity => "standard_parity".to_string(),
// 纠删码集合相关指标
// Erasure coding set related metrics
Self::ErasureSetOverallWriteQuorum => "overall_write_quorum".to_string(),
Self::ErasureSetOverallHealth => "overall_health".to_string(),
Self::ErasureSetReadQuorum => "read_quorum".to_string(),
@@ -498,12 +498,12 @@ impl MetricName {
Self::ErasureSetReadHealth => "read_health".to_string(),
Self::ErasureSetWriteHealth => "write_health".to_string(),
// 集群健康相关指标
// Cluster health-related metrics
Self::HealthDrivesOfflineCount => "drives_offline_count".to_string(),
Self::HealthDrivesOnlineCount => "drives_online_count".to_string(),
Self::HealthDrivesCount => "drives_count".to_string(),
// IAM 相关指标
// IAM-related metrics
Self::LastSyncDurationMillis => "last_sync_duration_millis".to_string(),
Self::PluginAuthnServiceFailedRequestsMinute => "plugin_authn_service_failed_requests_minute".to_string(),
Self::PluginAuthnServiceLastFailSeconds => "plugin_authn_service_last_fail_seconds".to_string(),
@@ -515,13 +515,13 @@ impl MetricName {
Self::SyncFailures => "sync_failures".to_string(),
Self::SyncSuccesses => "sync_successes".to_string(),
// 通知相关指标
// Notify relevant metrics
Self::NotificationCurrentSendInProgress => "current_send_in_progress".to_string(),
Self::NotificationEventsErrorsTotal => "events_errors_total".to_string(),
Self::NotificationEventsSentTotal => "events_sent_total".to_string(),
Self::NotificationEventsSkippedTotal => "events_skipped_total".to_string(),
// 集群对象使用情况相关指标
// Metrics related to the usage of cluster objects
Self::UsageSinceLastUpdateSeconds => "since_last_update_seconds".to_string(),
Self::UsageTotalBytes => "total_bytes".to_string(),
Self::UsageObjectsCount => "count".to_string(),
@@ -531,7 +531,7 @@ impl MetricName {
Self::UsageSizeDistribution => "size_distribution".to_string(),
Self::UsageVersionCountDistribution => "version_count_distribution".to_string(),
// 桶使用情况相关指标
// Metrics related to bucket usage
Self::UsageBucketQuotaTotalBytes => "quota_total_bytes".to_string(),
Self::UsageBucketTotalBytes => "total_bytes".to_string(),
Self::UsageBucketObjectsCount => "objects_count".to_string(),
@@ -540,19 +540,19 @@ impl MetricName {
Self::UsageBucketObjectSizeDistribution => "object_size_distribution".to_string(),
Self::UsageBucketObjectVersionCountDistribution => "object_version_count_distribution".to_string(),
// ILM 相关指标
// ILM-related metrics
Self::IlmExpiryPendingTasks => "expiry_pending_tasks".to_string(),
Self::IlmTransitionActiveTasks => "transition_active_tasks".to_string(),
Self::IlmTransitionPendingTasks => "transition_pending_tasks".to_string(),
Self::IlmTransitionMissedImmediateTasks => "transition_missed_immediate_tasks".to_string(),
Self::IlmVersionsScanned => "versions_scanned".to_string(),
// Webhook 日志相关指标
// Webhook logs
Self::WebhookQueueLength => "queue_length".to_string(),
Self::WebhookTotalMessages => "total_messages".to_string(),
Self::WebhookFailedMessages => "failed_messages".to_string(),
// 复制相关指标
// Copy the relevant metrics
Self::ReplicationAverageActiveWorkers => "average_active_workers".to_string(),
Self::ReplicationAverageQueuedBytes => "average_queued_bytes".to_string(),
Self::ReplicationAverageQueuedCount => "average_queued_count".to_string(),
@@ -567,7 +567,7 @@ impl MetricName {
Self::ReplicationMaxDataTransferRate => "max_data_transfer_rate".to_string(),
Self::ReplicationRecentBacklogCount => "recent_backlog_count".to_string(),
// 扫描器相关指标
// Scanner-related metrics
Self::ScannerBucketScansFinished => "bucket_scans_finished".to_string(),
Self::ScannerBucketScansStarted => "bucket_scans_started".to_string(),
Self::ScannerDirectoriesScanned => "directories_scanned".to_string(),
@@ -575,7 +575,7 @@ impl MetricName {
Self::ScannerVersionsScanned => "versions_scanned".to_string(),
Self::ScannerLastActivitySeconds => "last_activity_seconds".to_string(),
// CPU 系统相关指标
// CPU system-related metrics
Self::SysCPUAvgIdle => "avg_idle".to_string(),
Self::SysCPUAvgIOWait => "avg_iowait".to_string(),
Self::SysCPULoad => "load".to_string(),
@@ -585,7 +585,7 @@ impl MetricName {
Self::SysCPUSystem => "system".to_string(),
Self::SysCPUUser => "user".to_string(),
// 驱动器相关指标
// Drive-related metrics
Self::DriveUsedBytes => "used_bytes".to_string(),
Self::DriveFreeBytes => "free_bytes".to_string(),
Self::DriveTotalBytes => "total_bytes".to_string(),
@@ -603,7 +603,7 @@ impl MetricName {
Self::DriveOnlineCount => "online_count".to_string(),
Self::DriveCount => "count".to_string(),
// iostat 相关指标
// iostat related metrics
Self::DriveReadsPerSec => "reads_per_sec".to_string(),
Self::DriveReadsKBPerSec => "reads_kb_per_sec".to_string(),
Self::DriveReadsAwait => "reads_await".to_string(),
@@ -612,7 +612,7 @@ impl MetricName {
Self::DriveWritesAwait => "writes_await".to_string(),
Self::DrivePercUtil => "perc_util".to_string(),
// 内存相关指标
// Memory-related metrics
Self::MemTotal => "total".to_string(),
Self::MemUsed => "used".to_string(),
Self::MemUsedPerc => "used_perc".to_string(),
@@ -622,14 +622,14 @@ impl MetricName {
Self::MemShared => "shared".to_string(),
Self::MemAvailable => "available".to_string(),
// 网络相关指标
// Network-related metrics
Self::InternodeErrorsTotal => "errors_total".to_string(),
Self::InternodeDialErrorsTotal => "dial_errors_total".to_string(),
Self::InternodeDialAvgTimeNanos => "dial_avg_time_nanos".to_string(),
Self::InternodeSentBytesTotal => "sent_bytes_total".to_string(),
Self::InternodeRecvBytesTotal => "recv_bytes_total".to_string(),
// 进程相关指标
// Process-related metrics
Self::ProcessLocksReadTotal => "locks_read_total".to_string(),
Self::ProcessLocksWriteTotal => "locks_write_total".to_string(),
Self::ProcessCPUTotalSeconds => "cpu_total_seconds".to_string(),

View File

@@ -21,7 +21,7 @@ impl MetricType {
/// Convert the metric type to the Prometheus value type
/// In a Rust implementation, this might return the corresponding Prometheus Rust client type
#[allow(dead_code)]
pub fn to_prom(&self) -> &'static str {
pub fn as_prom(&self) -> &'static str {
match self {
Self::Counter => "counter.",
Self::Gauge => "gauge.",

View File

@@ -92,21 +92,21 @@ impl MetricSubsystem {
/// Create a subsystem enumeration from a path string
pub fn from_path(path: &str) -> Self {
match path {
// API 相关子系统
// API-related subsystems
"/api/requests" => Self::ApiRequests,
// 桶相关子系统
// Bucket-related subsystems
"/bucket/api" => Self::BucketApi,
"/bucket/replication" => Self::BucketReplication,
// 系统相关子系统
// System-related subsystems
"/system/network/internode" => Self::SystemNetworkInternode,
"/system/drive" => Self::SystemDrive,
"/system/memory" => Self::SystemMemory,
"/system/cpu" => Self::SystemCpu,
"/system/process" => Self::SystemProcess,
// 调试相关子系统
// Debug related subsystems
"/debug/go" => Self::DebugGo,
// 集群相关子系统

View File

@@ -1,12 +1,12 @@
/// ILM-related metric descriptors
use crate::metrics::{new_counter_md, new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// ILM 相关指标描述符
lazy_static::lazy_static! {
pub static ref ILM_EXPIRY_PENDING_TASKS_MD: MetricDescriptor =
new_gauge_md(
MetricName::IlmExpiryPendingTasks,
"Number of pending ILM expiry tasks in the queue",
&[], // 无标签
&[],
subsystems::ILM
);
@@ -14,7 +14,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::IlmTransitionActiveTasks,
"Number of active ILM transition tasks",
&[], // 无标签
&[],
subsystems::ILM
);
@@ -22,7 +22,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::IlmTransitionPendingTasks,
"Number of pending ILM transition tasks in the queue",
&[], // 无标签
&[],
subsystems::ILM
);
@@ -30,7 +30,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::IlmTransitionMissedImmediateTasks,
"Number of missed immediate ILM transition tasks",
&[], // 无标签
&[],
subsystems::ILM
);
@@ -38,7 +38,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::IlmVersionsScanned,
"Total number of object versions checked for ILM actions since server start",
&[], // 无标签
&[],
subsystems::ILM
);
}

View File

@@ -1,12 +1,14 @@
/// A descriptor for metrics related to webhook logs
use crate::metrics::{new_counter_md, new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// 定义标签常量
/// Define label constants for webhook metrics
/// name label
pub const NAME_LABEL: &str = "name";
/// endpoint label
pub const ENDPOINT_LABEL: &str = "endpoint";
/// Webhook 日志相关指标描述符
lazy_static::lazy_static! {
// 所有 Webhook 指标使用的标签
// The label used by all webhook metrics
static ref ALL_WEBHOOK_LABELS: [&'static str; 2] = [NAME_LABEL, ENDPOINT_LABEL];
pub static ref WEBHOOK_FAILED_MESSAGES_MD: MetricDescriptor =

View File

@@ -1,6 +1,7 @@
mod audit;
mod bucket;
mod bucket_replication;
mod cluster_config;
mod cluster_erasure_set;
mod cluster_health;
mod cluster_iam;

View File

@@ -1,12 +1,12 @@
/// Copy the relevant metric descriptor
use crate::metrics::{new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// 复制相关指标描述符
lazy_static::lazy_static! {
pub static ref REPLICATION_AVERAGE_ACTIVE_WORKERS_MD: MetricDescriptor =
new_gauge_md(
MetricName::ReplicationAverageActiveWorkers,
"Average number of active replication workers",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -14,7 +14,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationAverageQueuedBytes,
"Average number of bytes queued for replication since server start",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -22,7 +22,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationAverageQueuedCount,
"Average number of objects queued for replication since server start",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -30,7 +30,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationAverageDataTransferRate,
"Average replication data transfer rate in bytes/sec",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -38,7 +38,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationCurrentActiveWorkers,
"Total number of active replication workers",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -46,7 +46,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationCurrentDataTransferRate,
"Current replication data transfer rate in bytes/sec",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -54,7 +54,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationLastMinuteQueuedBytes,
"Number of bytes queued for replication in the last full minute",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -62,7 +62,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationLastMinuteQueuedCount,
"Number of objects queued for replication in the last full minute",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -70,7 +70,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationMaxActiveWorkers,
"Maximum number of active replication workers seen since server start",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -78,7 +78,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationMaxQueuedBytes,
"Maximum number of bytes queued for replication since server start",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -86,7 +86,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationMaxQueuedCount,
"Maximum number of objects queued for replication since server start",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -94,7 +94,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationMaxDataTransferRate,
"Maximum replication data transfer rate in bytes/sec seen since server start",
&[], // 无标签
&[],
subsystems::REPLICATION
);
@@ -102,7 +102,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ReplicationRecentBacklogCount,
"Total number of objects seen in replication backlog in the last 5 minutes",
&[], // 无标签
&[],
subsystems::REPLICATION
);
}

View File

@@ -1,12 +1,12 @@
/// Scanner-related metric descriptors
use crate::metrics::{new_counter_md, new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// 扫描器相关指标描述符
lazy_static::lazy_static! {
pub static ref SCANNER_BUCKET_SCANS_FINISHED_MD: MetricDescriptor =
new_counter_md(
MetricName::ScannerBucketScansFinished,
"Total number of bucket scans finished since server start",
&[], // 无标签
&[],
subsystems::SCANNER
);
@@ -14,7 +14,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::ScannerBucketScansStarted,
"Total number of bucket scans started since server start",
&[], // 无标签
&[],
subsystems::SCANNER
);
@@ -22,7 +22,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::ScannerDirectoriesScanned,
"Total number of directories scanned since server start",
&[], // 无标签
&[],
subsystems::SCANNER
);
@@ -30,7 +30,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::ScannerObjectsScanned,
"Total number of unique objects scanned since server start",
&[], // 无标签
&[],
subsystems::SCANNER
);
@@ -38,7 +38,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::ScannerVersionsScanned,
"Total number of object versions scanned since server start",
&[], // 无标签
&[],
subsystems::SCANNER
);
@@ -46,7 +46,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ScannerLastActivitySeconds,
"Time elapsed (in seconds) since last scan activity.",
&[], // 无标签
&[],
subsystems::SCANNER
);
}

View File

@@ -1,12 +1,12 @@
/// CPU system-related metric descriptors
use crate::metrics::{new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// CPU 系统相关指标描述符
lazy_static::lazy_static! {
pub static ref SYS_CPU_AVG_IDLE_MD: MetricDescriptor =
new_gauge_md(
MetricName::SysCPUAvgIdle,
"Average CPU idle time",
&[], // 无标签
&[],
subsystems::SYSTEM_CPU
);
@@ -14,7 +14,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::SysCPUAvgIOWait,
"Average CPU IOWait time",
&[], // 无标签
&[],
subsystems::SYSTEM_CPU
);
@@ -22,7 +22,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::SysCPULoad,
"CPU load average 1min",
&[], // 无标签
&[],
subsystems::SYSTEM_CPU
);
@@ -30,7 +30,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::SysCPULoadPerc,
"CPU load average 1min (percentage)",
&[], // 无标签
&[],
subsystems::SYSTEM_CPU
);
@@ -38,7 +38,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::SysCPUNice,
"CPU nice time",
&[], // 无标签
&[],
subsystems::SYSTEM_CPU
);
@@ -46,7 +46,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::SysCPUSteal,
"CPU steal time",
&[], // 无标签
&[],
subsystems::SYSTEM_CPU
);
@@ -54,7 +54,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::SysCPUSystem,
"CPU system time",
&[], // 无标签
&[],
subsystems::SYSTEM_CPU
);
@@ -62,7 +62,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::SysCPUUser,
"CPU user time",
&[], // 无标签
&[],
subsystems::SYSTEM_CPU
);
}

View File

@@ -1,18 +1,22 @@
/// Drive-related metric descriptors
use crate::metrics::{new_counter_md, new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// 定义标签常量
/// drive related labels
pub const DRIVE_LABEL: &str = "drive";
/// pool index label
pub const POOL_INDEX_LABEL: &str = "pool_index";
/// set index label
pub const SET_INDEX_LABEL: &str = "set_index";
/// drive index label
pub const DRIVE_INDEX_LABEL: &str = "drive_index";
/// API label
pub const API_LABEL: &str = "api";
/// 所有驱动器相关的标签
lazy_static::lazy_static! {
/// All drive-related labels
static ref ALL_DRIVE_LABELS: [&'static str; 4] = [DRIVE_LABEL, POOL_INDEX_LABEL, SET_INDEX_LABEL, DRIVE_INDEX_LABEL];
}
/// 驱动器相关指标描述符
lazy_static::lazy_static! {
pub static ref DRIVE_USED_BYTES_MD: MetricDescriptor =
new_gauge_md(

View File

@@ -1,12 +1,12 @@
/// Memory-related metric descriptors
use crate::metrics::{new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// 内存相关指标描述符
lazy_static::lazy_static! {
pub static ref MEM_TOTAL_MD: MetricDescriptor =
new_gauge_md(
MetricName::MemTotal,
"Total memory on the node",
&[], // 无标签
&[],
subsystems::SYSTEM_MEMORY
);
@@ -14,7 +14,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::MemUsed,
"Used memory on the node",
&[], // 无标签
&[],
subsystems::SYSTEM_MEMORY
);
@@ -22,7 +22,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::MemUsedPerc,
"Used memory percentage on the node",
&[], // 无标签
&[],
subsystems::SYSTEM_MEMORY
);
@@ -30,7 +30,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::MemFree,
"Free memory on the node",
&[], // 无标签
&[],
subsystems::SYSTEM_MEMORY
);
@@ -38,7 +38,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::MemBuffers,
"Buffers memory on the node",
&[], // 无标签
&[],
subsystems::SYSTEM_MEMORY
);
@@ -46,7 +46,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::MemCache,
"Cache memory on the node",
&[], // 无标签
&[],
subsystems::SYSTEM_MEMORY
);
@@ -54,7 +54,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::MemShared,
"Shared memory on the node",
&[], // 无标签
&[],
subsystems::SYSTEM_MEMORY
);
@@ -62,7 +62,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::MemAvailable,
"Available memory on the node",
&[], // 无标签
&[],
subsystems::SYSTEM_MEMORY
);
}

View File

@@ -1,12 +1,12 @@
/// Network-related metric descriptors
use crate::metrics::{new_counter_md, new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// 网络相关指标描述符
lazy_static::lazy_static! {
pub static ref INTERNODE_ERRORS_TOTAL_MD: MetricDescriptor =
new_counter_md(
MetricName::InternodeErrorsTotal,
"Total number of failed internode calls",
&[], // 无标签
&[],
subsystems::SYSTEM_NETWORK_INTERNODE
);
@@ -14,7 +14,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::InternodeDialErrorsTotal,
"Total number of internode TCP dial timeouts and errors",
&[], // 无标签
&[],
subsystems::SYSTEM_NETWORK_INTERNODE
);
@@ -22,7 +22,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::InternodeDialAvgTimeNanos,
"Average dial time of internode TCP calls in nanoseconds",
&[], // 无标签
&[],
subsystems::SYSTEM_NETWORK_INTERNODE
);
@@ -30,7 +30,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::InternodeSentBytesTotal,
"Total number of bytes sent to other peer nodes",
&[], // 无标签
&[],
subsystems::SYSTEM_NETWORK_INTERNODE
);
@@ -38,7 +38,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::InternodeRecvBytesTotal,
"Total number of bytes received from other peer nodes",
&[], // 无标签
&[],
subsystems::SYSTEM_NETWORK_INTERNODE
);
}

View File

@@ -1,12 +1,12 @@
/// process related metric descriptors
use crate::metrics::{new_counter_md, new_gauge_md, subsystems, MetricDescriptor, MetricName};
/// process related metric descriptors
lazy_static::lazy_static! {
pub static ref PROCESS_LOCKS_READ_TOTAL_MD: MetricDescriptor =
new_gauge_md(
MetricName::ProcessLocksReadTotal,
"Number of current READ locks on this peer",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -14,7 +14,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ProcessLocksWriteTotal,
"Number of current WRITE locks on this peer",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -22,7 +22,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::ProcessCPUTotalSeconds,
"Total user and system CPU time spent in seconds",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -30,7 +30,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ProcessGoRoutineTotal,
"Total number of go routines running",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -38,7 +38,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::ProcessIORCharBytes,
"Total bytes read by the process from the underlying storage system including cache, /proc/[pid]/io rchar",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -46,7 +46,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::ProcessIOReadBytes,
"Total bytes read by the process from the underlying storage system, /proc/[pid]/io read_bytes",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -54,7 +54,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::ProcessIOWCharBytes,
"Total bytes written by the process to the underlying storage system including page cache, /proc/[pid]/io wchar",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -62,7 +62,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::ProcessIOWriteBytes,
"Total bytes written by the process to the underlying storage system, /proc/[pid]/io write_bytes",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -70,7 +70,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ProcessStartTimeSeconds,
"Start time for RustFS process in seconds since Unix epoc",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -78,7 +78,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ProcessUptimeSeconds,
"Uptime for RustFS process in seconds",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -86,7 +86,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ProcessFileDescriptorLimitTotal,
"Limit on total number of open file descriptors for the RustFS Server process",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -94,7 +94,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ProcessFileDescriptorOpenTotal,
"Total number of open file descriptors by the RustFS Server process",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -102,7 +102,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::ProcessSyscallReadTotal,
"Total read SysCalls to the kernel. /proc/[pid]/io syscr",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -110,7 +110,7 @@ lazy_static::lazy_static! {
new_counter_md(
MetricName::ProcessSyscallWriteTotal,
"Total write SysCalls to the kernel. /proc/[pid]/io syscw",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -118,7 +118,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ProcessResidentMemoryBytes,
"Resident memory size in bytes",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -126,7 +126,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ProcessVirtualMemoryBytes,
"Virtual memory size in bytes",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
@@ -134,7 +134,7 @@ lazy_static::lazy_static! {
new_gauge_md(
MetricName::ProcessVirtualMemoryMaxBytes,
"Maximum virtual memory size in bytes",
&[], // 无标签
&[],
subsystems::SYSTEM_PROCESS
);
}

View File

@@ -43,7 +43,7 @@ pub fn load_private_key(filename: &str) -> io::Result<PrivateKeyDer<'static>> {
/// error function
pub fn certs_error(err: String) -> Error {
Error::new(io::ErrorKind::Other, err)
Error::other(err)
}
/// Load all certificates and private keys in the directory

View File

@@ -1193,15 +1193,15 @@ impl DiskAPI for LocalDisk {
#[tracing::instrument(skip(self))]
async fn set_disk_id(&self, id: Option<Uuid>) -> Result<()> {
// 本地不需要设置
// No setup is required locally
// TODO: add check_id_store
let mut format_info = self.format_info.write().await;
format_info.id = id;
Ok(())
}
#[must_use]
#[tracing::instrument(skip(self))]
#[must_use]
async fn read_all(&self, volume: &str, path: &str) -> Result<Vec<u8>> {
if volume == super::RUSTFS_META_BUCKET && path == super::FORMAT_CONFIG_FILE {
let format_info = self.format_info.read().await;

View File

@@ -58,7 +58,7 @@ impl HttpFileWriter {
.body(body)
.send()
.await
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))
.map_err(io::Error::other)
{
error!("HttpFileWriter put file err: {:?}", err);
@@ -115,9 +115,9 @@ impl HttpFileReader {
))
.send()
.await
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
.map_err(io::Error::other)?;
let inner = Box::new(StreamReader::new(resp.bytes_stream().map_err(std::io::Error::other)));
let inner = Box::new(StreamReader::new(resp.bytes_stream().map_err(io::Error::other)));
Ok(Self { inner })
}

View File

@@ -2,7 +2,7 @@ use super::IOStats;
use crate::disk::Info;
use common::error::Result;
use nix::sys::{stat::stat, statfs::statfs};
use std::io::{Error, ErrorKind};
use std::io::Error;
use std::path::Path;
/// returns total and free bytes available in a directory, e.g. `/`.
@@ -17,30 +17,24 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<Info> {
let reserved = match bfree.checked_sub(bavail) {
Some(reserved) => reserved,
None => {
return Err(Error::new(
ErrorKind::Other,
format!(
"detected f_bavail space ({}) > f_bfree space ({}), fs corruption at ({}). please run 'fsck'",
bavail,
bfree,
p.as_ref().display()
),
))
return Err(Error::other(format!(
"detected f_bavail space ({}) > f_bfree space ({}), fs corruption at ({}). please run 'fsck'",
bavail,
bfree,
p.as_ref().display()
)))
}
};
let total = match blocks.checked_sub(reserved) {
Some(total) => total * bsize,
None => {
return Err(Error::new(
ErrorKind::Other,
format!(
"detected reserved space ({}) > blocks space ({}), fs corruption at ({}). please run 'fsck'",
reserved,
blocks,
p.as_ref().display()
),
))
return Err(Error::other(format!(
"detected reserved space ({}) > blocks space ({}), fs corruption at ({}). please run 'fsck'",
reserved,
blocks,
p.as_ref().display()
)))
}
};
@@ -48,15 +42,12 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<Info> {
let used = match total.checked_sub(free) {
Some(used) => used,
None => {
return Err(Error::new(
ErrorKind::Other,
format!(
"detected free space ({}) > total drive space ({}), fs corruption at ({}). please run 'fsck'",
free,
total,
p.as_ref().display()
),
))
return Err(Error::other(format!(
"detected free space ({}) > total drive space ({}), fs corruption at ({}). please run 'fsck'",
free,
total,
p.as_ref().display()
)))
}
};

View File

@@ -117,11 +117,7 @@ impl Operation for PutFile {
.map_err(|e| s3_error!(InternalError, "read file err {}", e))?
};
let mut body = StreamReader::new(
req.input
.into_stream()
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)),
);
let mut body = StreamReader::new(req.input.into_stream().map_err(std::io::Error::other));
tokio::io::copy(&mut body, &mut file)
.await

View File

@@ -281,7 +281,7 @@ async fn start_server(server_addr: SocketAddr, tls_path: Option<String>, app: Ro
.handle(handle.clone())
.serve(app.into_make_service())
.await
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
.map_err(|e| io::Error::other(e))?;
info!("HTTPS server running on https://{}", server_addr);
@@ -323,7 +323,7 @@ async fn start_http_server(addr: SocketAddr, app: Router, handle: axum_server::H
.handle(handle)
.serve(app.into_make_service())
.await
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
.map_err(io::Error::other)
}
async fn shutdown_signal() {

View File

@@ -119,7 +119,7 @@ impl FS {
let Some(body) = body else { return Err(s3_error!(IncompleteBody)) };
let body = StreamReader::new(body.map(|f| f.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))));
let body = StreamReader::new(body.map(|f| f.map_err(|e| std::io::Error::other(e.to_string()))));
// let etag_stream = EtagReader::new(body);
@@ -205,7 +205,7 @@ impl FS {
// .await
// {
// Ok(_) => println!("解压成功!"),
// Err(e) => println!("解压失败: {}", e),
// Err(e) => println!("解压失败{}", e),
// }
// TODO: etag
@@ -960,9 +960,7 @@ impl S3 for FS {
}
};
let body = Box::new(StreamReader::new(
body.map(|f| f.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))),
));
let body = Box::new(StreamReader::new(body.map(|f| f.map_err(|e| std::io::Error::other(e.to_string())))));
let mut reader = PutObjReader::new(body, content_length as usize);
@@ -1076,9 +1074,7 @@ impl S3 for FS {
}
};
let body = Box::new(StreamReader::new(
body.map(|f| f.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))),
));
let body = Box::new(StreamReader::new(body.map(|f| f.map_err(|e| std::io::Error::other(e.to_string())))));
// mc cp step 4
let mut data = PutObjReader::new(body, content_length as usize);