Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3504888
D5729.id18925.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D5729.id18925.diff
View Options
diff --git a/services/blob/Cargo.lock b/services/blob/Cargo.lock
--- a/services/blob/Cargo.lock
+++ b/services/blob/Cargo.lock
@@ -486,6 +486,8 @@
"tokio-stream",
"tonic",
"tonic-build",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
@@ -1006,6 +1008,15 @@
"cfg-if",
]
+[[package]]
+name = "matchers"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
+dependencies = [
+ "regex-automata",
+]
+
[[package]]
name = "matchit"
version = "0.5.0"
@@ -1051,6 +1062,16 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
+[[package]]
+name = "nu-ansi-term"
+version = "0.46.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
+dependencies = [
+ "overload",
+ "winapi",
+]
+
[[package]]
name = "num-integer"
version = "0.1.45"
@@ -1092,6 +1113,12 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
+[[package]]
+name = "overload"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
+
[[package]]
name = "percent-encoding"
version = "2.2.0"
@@ -1279,6 +1306,15 @@
"regex-syntax",
]
+[[package]]
+name = "regex-automata"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
+dependencies = [
+ "regex-syntax",
+]
+
[[package]]
name = "regex-syntax"
version = "0.6.28"
@@ -1440,6 +1476,15 @@
"digest",
]
+[[package]]
+name = "sharded-slab"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
+dependencies = [
+ "lazy_static",
+]
+
[[package]]
name = "slab"
version = "0.4.7"
@@ -1449,6 +1494,12 @@
"autocfg",
]
+[[package]]
+name = "smallvec"
+version = "1.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
+
[[package]]
name = "socket2"
version = "0.4.7"
@@ -1505,6 +1556,15 @@
"winapi-util",
]
+[[package]]
+name = "thread_local"
+version = "1.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
+dependencies = [
+ "once_cell",
+]
+
[[package]]
name = "time"
version = "0.1.44"
@@ -1744,6 +1804,7 @@
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
dependencies = [
"once_cell",
+ "valuable",
]
[[package]]
@@ -1756,6 +1817,35 @@
"tracing",
]
+[[package]]
+name = "tracing-log"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
+dependencies = [
+ "lazy_static",
+ "log",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-subscriber"
+version = "0.3.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
+dependencies = [
+ "matchers",
+ "nu-ansi-term",
+ "once_cell",
+ "regex",
+ "sharded-slab",
+ "smallvec",
+ "thread_local",
+ "tracing",
+ "tracing-core",
+ "tracing-log",
+]
+
[[package]]
name = "try-lock"
version = "0.2.3"
@@ -1792,6 +1882,12 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9"
+[[package]]
+name = "valuable"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
+
[[package]]
name = "version_check"
version = "0.9.4"
diff --git a/services/blob/Cargo.toml b/services/blob/Cargo.toml
--- a/services/blob/Cargo.toml
+++ b/services/blob/Cargo.toml
@@ -18,6 +18,8 @@
tokio = { version = "1.21", features = ["rt-multi-thread"]}
tokio-stream = "0.1"
tonic = "0.8"
+tracing = "0.1"
+tracing-subscriber = { version = "0.3", features = ["env-filter"]}
[build-dependencies]
tonic-build = "0.8"
diff --git a/services/blob/src/constants.rs b/services/blob/src/constants.rs
--- a/services/blob/src/constants.rs
+++ b/services/blob/src/constants.rs
@@ -39,6 +39,8 @@
// Environment variables
pub const SANDBOX_ENV_VAR: &str = "COMM_SERVICES_SANDBOX";
+pub const LOG_LEVEL_ENV_VAR: &str =
+ tracing_subscriber::filter::EnvFilter::DEFAULT_ENV;
// S3 constants
diff --git a/services/blob/src/main.rs b/services/blob/src/main.rs
--- a/services/blob/src/main.rs
+++ b/services/blob/src/main.rs
@@ -10,12 +10,26 @@
use service::{blob::blob_service_server::BlobServiceServer, MyBlobService};
use std::net::SocketAddr;
use tonic::transport::{Server, Uri};
+use tracing::info;
+use tracing_subscriber::filter::{EnvFilter, LevelFilter};
+
+fn configure_logging() -> Result<()> {
+ let filter = EnvFilter::builder()
+ .with_default_directive(LevelFilter::INFO.into())
+ .with_env_var(constants::LOG_LEVEL_ENV_VAR)
+ .from_env_lossy();
+
+ let subscriber = tracing_subscriber::fmt().with_env_filter(filter).finish();
+ tracing::subscriber::set_global_default(subscriber)?;
+ Ok(())
+}
async fn get_aws_config() -> aws_types::SdkConfig {
let mut config_builder =
aws_config::from_env().region(Region::new(constants::AWS_REGION));
if tools::is_sandbox_env() {
+ info!("Running in sandbox environment");
config_builder = config_builder.endpoint_resolver(Endpoint::immutable(
Uri::from_static(constants::LOCALSTACK_URL),
));
@@ -32,7 +46,7 @@
format!("[::]:{}", constants::GRPC_SERVER_DEFAULT_PORT).parse()?;
let blob_service = MyBlobService::new(db_client, s3_client);
- println!("Starting gRPC server at port {}", addr.port());
+ info!("Starting gRPC server listening at {}", addr.to_string());
Server::builder()
.add_service(BlobServiceServer::new(blob_service))
.serve(addr)
@@ -43,6 +57,8 @@
#[tokio::main]
async fn main() -> Result<()> {
+ configure_logging()?;
+
let aws_config = get_aws_config().await;
let db = database::DatabaseClient::new(&aws_config);
let s3 = aws_sdk_s3::Client::new(&aws_config);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 11:04 AM (20 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2687485
Default Alt Text
D5729.id18925.diff (6 KB)
Attached To
Mode
D5729: [services][blob] Use tracing for logs
Attached
Detach File
Event Timeline
Log In to Comment