Page MenuHomePhabricator

D13393.id44376.diff
No OneTemporary

D13393.id44376.diff

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

Mime Type
text/plain
Expires
Sat, Nov 23, 4:02 AM (16 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2568061
Default Alt Text
D13393.id44376.diff (2 KB)

Event Timeline