Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: truncate log item strings #1227

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion common/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,15 @@ pub struct LogItem {
pub line: String,
}

const LOG_LINE_MAX_CHARS: usize = 2048;

impl LogItem {
pub fn new(id: Uuid, internal_origin: Backend, line: String) -> Self {
pub fn new(id: Uuid, internal_origin: Backend, line: impl Into<String>) -> Self {
let mut line = line.into();
if line.chars().count() > LOG_LINE_MAX_CHARS {
line = line.chars().take(LOG_LINE_MAX_CHARS).collect()
}

Self {
id,
internal_origin,
Expand Down
1 change: 1 addition & 0 deletions deployer/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ pub async fn create_service(
let pid = persistence.project_id();

span.in_scope(|| {
info!("Deployer version: {}", crate::VERSION);
info!("Deployment ID: {}", id);
info!("Service ID: {}", service.id);
info!("Service name: {}", service.name);
Expand Down
2 changes: 2 additions & 0 deletions deployer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub use crate::persistence::Persistence;
use crate::proxy::AddressGetter;
pub use crate::runtime_manager::RuntimeManager;

const VERSION: &str = env!("CARGO_PKG_VERSION");

pub async fn start(
persistence: Persistence,
runtime_manager: Arc<Mutex<RuntimeManager>>,
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/alpha/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ where
&self,
request: Request<StartRequest>,
) -> Result<Response<StartResponse>, Status> {
println!("alpha runtime starting");
println!("Runtime starting (version {})", crate::VERSION);
let service = self.service.lock().unwrap().deref_mut().take();
let service = service.unwrap();

Expand All @@ -349,7 +349,7 @@ where
.context("invalid socket address")
.map_err(|err| Status::invalid_argument(err.to_string()))?;

println!("starting on {service_address}");
println!("Starting on {service_address}");

let (kill_tx, kill_rx) = tokio::sync::oneshot::channel();
*self.kill_tx.lock().unwrap() = Some(kill_tx);
Expand Down
8 changes: 4 additions & 4 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ pub use strfmt::strfmt;
#[cfg(feature = "setup-tracing")]
pub use {colored, tracing_subscriber};

const NAME: &str = env!("CARGO_PKG_NAME");
const VERSION: &str = env!("CARGO_PKG_VERSION");

// Print the version of the runtime.
pub fn print_version() {
let name = env!("CARGO_PKG_NAME");
let version = env!("CARGO_PKG_VERSION");

println!("{name} {version}");
println!("{NAME} {VERSION}");
}