Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3362578
D13393.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13393.diff
View Options
diff --git a/services/blob/Cargo.toml b/services/blob/Cargo.toml
--- a/services/blob/Cargo.toml
+++ b/services/blob/Cargo.toml
@@ -33,5 +33,5 @@
tracing = { workspace = true }
tracing-actix-web = { workspace = true }
tracing-futures = { workspace = true, features = ["futures-03"] }
-tracing-subscriber = { workspace = true, features = ["env-filter"] }
+tracing-subscriber = { workspace = true, features = ["env-filter", "json"] }
serde_json = { workspace = true }
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
@@ -31,6 +31,7 @@
// Environment variables
+pub const COMM_SERVICES_USE_JSON_LOGS: &str = "COMM_SERVICES_USE_JSON_LOGS";
pub const LOG_LEVEL_ENV_VAR: &str =
tracing_subscriber::filter::EnvFilter::DEFAULT_ENV;
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
@@ -9,18 +9,34 @@
use anyhow::Result;
use comm_lib::auth::AuthService;
use config::Command;
+use constants::COMM_SERVICES_USE_JSON_LOGS;
+use std::env;
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
use crate::service::BlobServiceConfig;
fn configure_logging() -> Result<()> {
+ let use_json_logs: bool = env::var(COMM_SERVICES_USE_JSON_LOGS)
+ .unwrap_or("false".to_string())
+ .parse()
+ .unwrap_or_default();
+
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)?;
+ if use_json_logs {
+ let subscriber = tracing_subscriber::fmt()
+ .json()
+ .with_env_filter(filter)
+ .finish();
+ tracing::subscriber::set_global_default(subscriber)?;
+ } else {
+ let subscriber = tracing_subscriber::fmt().with_env_filter(filter).finish();
+ tracing::subscriber::set_global_default(subscriber)?;
+ }
+
Ok(())
}
diff --git a/services/terraform/remote/service_blob.tf b/services/terraform/remote/service_blob.tf
--- a/services/terraform/remote/service_blob.tf
+++ b/services/terraform/remote/service_blob.tf
@@ -49,6 +49,10 @@
{
name = "COMM_SERVICES_DISABLE_CSAT_VERIFICATION",
value = local.is_staging ? "false" : "true"
+ },
+ {
+ name = "COMM_SERVICES_USE_JSON_LOGS",
+ value = local.comm_services_use_json_logs
}
]
logConfiguration = {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 11:03 PM (19 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2581300
Default Alt Text
D13393.diff (2 KB)
Attached To
Mode
D13393: [blob] use json logs with tracing for blob service
Attached
Detach File
Event Timeline
Log In to Comment