mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-24 05:06:28 +00:00
replace log to tracing
This commit is contained in:
Generated
+1
-2
@@ -5617,7 +5617,6 @@ dependencies = [
|
|||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
"futures",
|
"futures",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"h2",
|
|
||||||
"http",
|
"http",
|
||||||
"http-body",
|
"http-body",
|
||||||
"hyper",
|
"hyper",
|
||||||
@@ -5627,7 +5626,6 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
"local-ip-address",
|
"local-ip-address",
|
||||||
"lock",
|
"lock",
|
||||||
"log",
|
|
||||||
"madmin",
|
"madmin",
|
||||||
"matchit 0.8.6",
|
"matchit 0.8.6",
|
||||||
"mime",
|
"mime",
|
||||||
@@ -5658,6 +5656,7 @@ dependencies = [
|
|||||||
"tower 0.5.2",
|
"tower 0.5.2",
|
||||||
"tower-http",
|
"tower-http",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
"tracing-core",
|
||||||
"tracing-error",
|
"tracing-error",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"transform-stream",
|
"transform-stream",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use tracing::warn;
|
use tracing::{instrument, warn};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
disk::endpoint::{Endpoint, EndpointType},
|
disk::endpoint::{Endpoint, EndpointType},
|
||||||
@@ -407,7 +407,7 @@ pub struct PoolEndpoints {
|
|||||||
pub platform: String,
|
pub platform: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// list of list of endpoints
|
/// list of endpoints
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct EndpointServerPools(pub Vec<PoolEndpoints>);
|
pub struct EndpointServerPools(pub Vec<PoolEndpoints>);
|
||||||
|
|
||||||
@@ -532,6 +532,8 @@ impl EndpointServerPools {
|
|||||||
|
|
||||||
nodes
|
nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument]
|
||||||
pub fn hosts_sorted(&self) -> Vec<Option<XHost>> {
|
pub fn hosts_sorted(&self) -> Vec<Option<XHost>> {
|
||||||
let (mut peers, local) = self.peers();
|
let (mut peers, local) = self.peers();
|
||||||
|
|
||||||
@@ -604,7 +606,6 @@ impl EndpointServerPools {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ pub fn get_global_deployment_id() -> Option<String> {
|
|||||||
pub fn set_global_endpoints(eps: Vec<PoolEndpoints>) {
|
pub fn set_global_endpoints(eps: Vec<PoolEndpoints>) {
|
||||||
GLOBAL_Endpoints
|
GLOBAL_Endpoints
|
||||||
.set(EndpointServerPools::from(eps))
|
.set(EndpointServerPools::from(eps))
|
||||||
.expect("GLOBAL_Endpoints set faild")
|
.expect("GLOBAL_Endpoints set failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_global_endpoints() -> EndpointServerPools {
|
pub fn get_global_endpoints() -> EndpointServerPools {
|
||||||
|
|||||||
+2
-1
@@ -2,11 +2,11 @@ use auth::Credentials;
|
|||||||
use ecstore::error::{Error, Result};
|
use ecstore::error::{Error, Result};
|
||||||
use ecstore::store::ECStore;
|
use ecstore::store::ECStore;
|
||||||
use error::Error as IamError;
|
use error::Error as IamError;
|
||||||
use log::debug;
|
|
||||||
use manager::IamCache;
|
use manager::IamCache;
|
||||||
use std::sync::{Arc, OnceLock};
|
use std::sync::{Arc, OnceLock};
|
||||||
use store::object::ObjectStore;
|
use store::object::ObjectStore;
|
||||||
use sys::IamSys;
|
use sys::IamSys;
|
||||||
|
use tracing::{debug, instrument};
|
||||||
|
|
||||||
pub mod cache;
|
pub mod cache;
|
||||||
mod format;
|
mod format;
|
||||||
@@ -58,6 +58,7 @@ pub fn get_global_action_cred() -> Option<Credentials> {
|
|||||||
GLOBAL_ACTIVE_CRED.get().cloned()
|
GLOBAL_ACTIVE_CRED.get().cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument]
|
||||||
pub async fn init_iam_sys(ecstore: Arc<ECStore>) -> Result<()> {
|
pub async fn init_iam_sys(ecstore: Arc<ECStore>) -> Result<()> {
|
||||||
debug!("init iam system");
|
debug!("init iam system");
|
||||||
let s = IamCache::new(ObjectStore::new(ecstore)).await;
|
let s = IamCache::new(ObjectStore::new(ecstore)).await;
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ opentelemetry = { workspace = true }
|
|||||||
opentelemetry-appender-tracing = { workspace = true, features = ["experimental_use_tracing_span_context", "experimental_metadata_attributes"] }
|
opentelemetry-appender-tracing = { workspace = true, features = ["experimental_use_tracing_span_context", "experimental_metadata_attributes"] }
|
||||||
opentelemetry_sdk = { workspace = true, features = ["rt-tokio"] }
|
opentelemetry_sdk = { workspace = true, features = ["rt-tokio"] }
|
||||||
opentelemetry-stdout = { workspace = true }
|
opentelemetry-stdout = { workspace = true }
|
||||||
opentelemetry-otlp = { workspace = true, features = ["grpc-tonic", "metrics"] }
|
opentelemetry-otlp = { workspace = true, features = ["grpc-tonic", "gzip-tonic"] }
|
||||||
opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] }
|
opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true, features = ["std", "attributes"] }
|
||||||
tracing-core = { workspace = true }
|
tracing-core = { workspace = true }
|
||||||
tracing-error = { workspace = true }
|
tracing-error = { workspace = true }
|
||||||
tracing-opentelemetry = { workspace = true }
|
tracing-opentelemetry = { workspace = true }
|
||||||
tracing-subscriber = { workspace = true, features = ["fmt", "env-filter", "tracing-log", "time", "local-time", "json"] }
|
tracing-subscriber = { workspace = true, features = ["registry", "std", "fmt", "env-filter", "tracing-log", "time", "local-time", "json"] }
|
||||||
tokio = { workspace = true, features = ["sync", "fs", "rt-multi-thread"] }
|
tokio = { workspace = true, features = ["sync", "fs", "rt-multi-thread"] }
|
||||||
rdkafka = { workspace = true, features = ["tokio"], optional = true }
|
rdkafka = { workspace = true, features = ["tokio"], optional = true }
|
||||||
reqwest = { workspace = true, optional = true, default-features = false }
|
reqwest = { workspace = true, optional = true, default-features = false }
|
||||||
@@ -41,10 +41,10 @@ local-ip-address = { workspace = true }
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
chrono = { workspace = true }
|
chrono = { workspace = true }
|
||||||
opentelemetry = { workspace = true, features = ["trace", "metrics"] }
|
opentelemetry = { workspace = true }
|
||||||
opentelemetry_sdk = { workspace = true, features = ["trace", "rt-tokio"] }
|
opentelemetry_sdk = { workspace = true, features = ["rt-tokio"] }
|
||||||
opentelemetry-stdout = { workspace = true, features = ["trace", "metrics"] }
|
opentelemetry-stdout = { workspace = true }
|
||||||
opentelemetry-otlp = { workspace = true, features = ["metrics", "grpc-tonic"] }
|
opentelemetry-otlp = { workspace = true, features = ["grpc-tonic"] }
|
||||||
opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] }
|
opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] }
|
||||||
tokio = { workspace = true, features = ["full"] }
|
tokio = { workspace = true, features = ["full"] }
|
||||||
tracing = { workspace = true, features = ["std", "attributes"] }
|
tracing = { workspace = true, features = ["std", "attributes"] }
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
[observability]
|
[observability]
|
||||||
endpoint = "http://localhost:4317"
|
endpoint = "http://localhost:4317"
|
||||||
use_stdout = true
|
use_stdout = true
|
||||||
sample_ratio = 0.5
|
sample_ratio = 1
|
||||||
meter_interval = 30
|
meter_interval = 30
|
||||||
service_name = "rustfs_obs_service"
|
service_name = "rustfs_obs"
|
||||||
service_version = "0.1.0"
|
service_version = "0.1.0"
|
||||||
deployment_environment = "develop"
|
deployment_environment = "develop"
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ fn init_tracer_provider(config: &OtelConfig) -> SdkTracerProvider {
|
|||||||
|
|
||||||
let tracer_provider = if config.endpoint.is_empty() {
|
let tracer_provider = if config.endpoint.is_empty() {
|
||||||
builder
|
builder
|
||||||
.with_simple_exporter(opentelemetry_stdout::SpanExporter::default())
|
.with_batch_exporter(opentelemetry_stdout::SpanExporter::default())
|
||||||
.build()
|
.build()
|
||||||
} else {
|
} else {
|
||||||
let exporter = opentelemetry_otlp::SpanExporter::builder()
|
let exporter = opentelemetry_otlp::SpanExporter::builder()
|
||||||
|
|||||||
+3
-2
@@ -16,7 +16,7 @@ workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
madmin.workspace = true
|
madmin.workspace = true
|
||||||
log.workspace = true
|
#log.workspace = true
|
||||||
async-trait.workspace = true
|
async-trait.workspace = true
|
||||||
bytes.workspace = true
|
bytes.workspace = true
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
@@ -25,7 +25,7 @@ ecstore.workspace = true
|
|||||||
flatbuffers.workspace = true
|
flatbuffers.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
futures-util.workspace = true
|
futures-util.workspace = true
|
||||||
h2 = "0.4.7"
|
#h2 = "0.4.7"
|
||||||
hyper.workspace = true
|
hyper.workspace = true
|
||||||
hyper-util.workspace = true
|
hyper-util.workspace = true
|
||||||
http.workspace = true
|
http.workspace = true
|
||||||
@@ -57,6 +57,7 @@ tokio-stream.workspace = true
|
|||||||
tonic = { version = "0.12.3", features = ["gzip"] }
|
tonic = { version = "0.12.3", features = ["gzip"] }
|
||||||
tonic-reflection.workspace = true
|
tonic-reflection.workspace = true
|
||||||
tower.workspace = true
|
tower.workspace = true
|
||||||
|
tracing-core = { workspace = true }
|
||||||
tracing-error.workspace = true
|
tracing-error.workspace = true
|
||||||
tracing-subscriber.workspace = true
|
tracing-subscriber.workspace = true
|
||||||
transform-stream.workspace = true
|
transform-stream.workspace = true
|
||||||
|
|||||||
+29
-12
@@ -36,14 +36,16 @@ use hyper_util::{
|
|||||||
use iam::init_iam_sys;
|
use iam::init_iam_sys;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use protos::proto_gen::node_service::node_service_server::NodeServiceServer;
|
use protos::proto_gen::node_service::node_service_server::NodeServiceServer;
|
||||||
use rustfs_obs::{init_obs, load_config};
|
use rustfs_obs::{init_obs, load_config, BaseLogEntry, ServerLogEntry};
|
||||||
use s3s::{host::MultiDomain, service::S3ServiceBuilder};
|
use s3s::{host::MultiDomain, service::S3ServiceBuilder};
|
||||||
use service::hybrid;
|
use service::hybrid;
|
||||||
|
use std::time::SystemTime;
|
||||||
use std::{io::IsTerminal, net::SocketAddr};
|
use std::{io::IsTerminal, net::SocketAddr};
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tonic::{metadata::MetadataValue, Request, Status};
|
use tonic::{metadata::MetadataValue, Request, Status};
|
||||||
use tower_http::cors::CorsLayer;
|
use tower_http::cors::CorsLayer;
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, error, info, info_span, warn};
|
||||||
|
use tracing_core::Level;
|
||||||
use tracing_error::ErrorLayer;
|
use tracing_error::ErrorLayer;
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|
||||||
@@ -101,28 +103,43 @@ fn print_server_info() {
|
|||||||
info!("Docs: {}", cfg.doc());
|
info!("Docs: {}", cfg.doc());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
#[tokio::main]
|
||||||
|
async fn main() -> Result<()> {
|
||||||
// Parse the obtained parameters
|
// Parse the obtained parameters
|
||||||
let opt = config::Opt::parse();
|
let opt = config::Opt::parse();
|
||||||
|
println!("config: {:?}", &opt);
|
||||||
// 设置 trace
|
// 设置 trace
|
||||||
// setup_tracing();
|
// setup_tracing();
|
||||||
|
|
||||||
let config = load_config(Some(opt.clone().obs_config));
|
let config = load_config(Some(opt.clone().obs_config));
|
||||||
// Initialize Observability
|
// Initialize Observability
|
||||||
let (_logger, guard) = tokio::runtime::Runtime::new()?.block_on(async { init_obs(config).await });
|
let (logger, guard) = init_obs(config).await;
|
||||||
|
// let (logger, guard) = tokio::runtime::Runtime::new()?.block_on(async { init_obs(config).await });
|
||||||
|
// let _rr = tokio::runtime::Runtime::new()?.block_on(async {
|
||||||
|
let start_time = SystemTime::now();
|
||||||
|
let base_entry = BaseLogEntry::new()
|
||||||
|
.timestamp(chrono::DateTime::from(start_time))
|
||||||
|
.message(Some("main init obs end".to_string()))
|
||||||
|
.request_id(Some("main".to_string()));
|
||||||
|
let server_entry = ServerLogEntry::new(Level::INFO, "main_server_entry".to_string())
|
||||||
|
.with_base(base_entry)
|
||||||
|
.user_id(Some("user_id".to_string()));
|
||||||
|
let _r = logger.lock().await.log_server_entry(server_entry).await;
|
||||||
|
// });
|
||||||
// Pack and store the guard
|
// Pack and store the guard
|
||||||
GLOBAL_GUARD.set(TracingGuard(Box::new(guard))).unwrap_or_else(|_| {
|
GLOBAL_GUARD.set(TracingGuard(Box::new(guard))).unwrap_or_else(|_| {
|
||||||
error!("Unable to set global tracing guard");
|
error!("Unable to set global tracing guard");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Run parameters
|
// Run parameters
|
||||||
run(opt)
|
run(opt).await
|
||||||
}
|
}
|
||||||
|
//
|
||||||
#[tokio::main]
|
// #[tokio::main]
|
||||||
async fn run(opt: config::Opt) -> Result<()> {
|
async fn run(opt: config::Opt) -> Result<()> {
|
||||||
|
let span = info_span!("trace-main-run");
|
||||||
|
let _enter = span.enter();
|
||||||
|
|
||||||
debug!("opt: {:?}", &opt);
|
debug!("opt: {:?}", &opt);
|
||||||
|
|
||||||
let mut server_addr = net::check_local_server_addr(opt.address.as_str()).unwrap();
|
let mut server_addr = net::check_local_server_addr(opt.address.as_str()).unwrap();
|
||||||
@@ -259,7 +276,7 @@ async fn run(opt: config::Opt) -> Result<()> {
|
|||||||
match res {
|
match res {
|
||||||
Ok(conn) => conn,
|
Ok(conn) => conn,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
tracing::error!("error accepting connection: {err}");
|
error!("error accepting connection: {err}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,10 +295,10 @@ async fn run(opt: config::Opt) -> Result<()> {
|
|||||||
|
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
() = graceful.shutdown() => {
|
() = graceful.shutdown() => {
|
||||||
tracing::debug!("Gracefully shutdown!");
|
debug!("Gracefully shutdown!");
|
||||||
},
|
},
|
||||||
() = tokio::time::sleep(std::time::Duration::from_secs(10)) => {
|
() = tokio::time::sleep(std::time::Duration::from_secs(10)) => {
|
||||||
tracing::debug!("Waited 10 seconds for graceful shutdown, aborting...");
|
debug!("Waited 10 seconds for graceful shutdown, aborting...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ use http::HeaderMap;
|
|||||||
use iam::policy::action::Action;
|
use iam::policy::action::Action;
|
||||||
use iam::policy::action::S3Action;
|
use iam::policy::action::S3Action;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use log::warn;
|
|
||||||
use s3s::dto::*;
|
use s3s::dto::*;
|
||||||
use s3s::s3_error;
|
use s3s::s3_error;
|
||||||
use s3s::S3Error;
|
use s3s::S3Error;
|
||||||
@@ -57,6 +56,7 @@ use tokio_util::io::StreamReader;
|
|||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
use tracing::warn;
|
||||||
use transform_stream::AsyncTryStream;
|
use transform_stream::AsyncTryStream;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ impl S3 for FS {
|
|||||||
#[tracing::instrument(level = "debug", skip(self, req))]
|
#[tracing::instrument(level = "debug", skip(self, req))]
|
||||||
async fn delete_bucket(&self, req: S3Request<DeleteBucketInput>) -> S3Result<S3Response<DeleteBucketOutput>> {
|
async fn delete_bucket(&self, req: S3Request<DeleteBucketInput>) -> S3Result<S3Response<DeleteBucketOutput>> {
|
||||||
let input = req.input;
|
let input = req.input;
|
||||||
// TODO: DeleteBucketInput 没有force参数?
|
// TODO: DeleteBucketInput 没有 force 参数?
|
||||||
let Some(store) = new_object_layer_fn() else {
|
let Some(store) = new_object_layer_fn() else {
|
||||||
return Err(S3Error::with_message(S3ErrorCode::InternalError, "Not init".to_string()));
|
return Err(S3Error::with_message(S3ErrorCode::InternalError, "Not init".to_string()));
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user