Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion .github/nightly-alpha-branches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@

branches:
- main
- release/0.6
21 changes: 19 additions & 2 deletions crates/cli/src/configuration/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use std::path::PathBuf;

use nemo_relay::error::FlowError;
use nemo_relay::logging::{
DEFAULT_FILE_FLUSH_INTERVAL_MILLIS, DEFAULT_FILE_SINK_QUEUE_ENTRIES, FileLogSinkConfig,
LogFormat, LogLevel, LogSinkConfig, LoggingConfig, MAX_FILE_SINK_QUEUE_ENTRIES,
DEFAULT_FILE_FLUSH_INTERVAL_MILLIS, DEFAULT_FILE_SINK_QUEUE_ENTRIES, FileLogRotationConfig,
FileLogSinkConfig, LogFormat, LogLevel, LogSinkConfig, LoggingConfig,
MAX_FILE_SINK_QUEUE_ENTRIES,
};
use serde::Deserialize;

Expand Down Expand Up @@ -36,6 +37,8 @@ struct RawFileLogSinkConfig {
/// Optional advanced: pending async queue entries per file sink (default
/// [`DEFAULT_FILE_SINK_QUEUE_ENTRIES`]).
queue_capacity: Option<usize>,
max_file_size_bytes: Option<u64>,
retained_files: Option<usize>,
}

pub(super) fn apply_file_logging_config(
Expand Down Expand Up @@ -100,11 +103,25 @@ fn parse_file_log_sink(
Some(capacity) => capacity,
None => DEFAULT_FILE_SINK_QUEUE_ENTRIES,
};
let rotation = match (config.max_file_size_bytes, config.retained_files) {
(None, None) => None,
(Some(max_file_size_bytes), Some(retained_files)) => Some(
FileLogRotationConfig::new(max_file_size_bytes, retained_files)
.map_err(logging_parse_error)?,
),
_ => {
return Err(CliError::Config(
"logging sink max_file_size_bytes and retained_files must be configured together"
.into(),
));
}
};
Ok(LogSinkConfig::File(FileLogSinkConfig {
path,
level,
format,
queue_capacity,
rotation,
}))
}

Expand Down
6 changes: 5 additions & 1 deletion crates/cli/src/gateway/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use nemo_relay::api::llm::{
llm_stream_call_execute,
};
use nemo_relay::api::runtime::{
LlmExecutionNextFn, LlmJsonStream, LlmStreamExecutionNextFn, TASK_SCOPE_STACK,
LlmCodecIdentity, LlmExecutionNextFn, LlmJsonStream, LlmStreamExecutionNextFn, TASK_SCOPE_STACK,
};
use nemo_relay::codec::request::AnnotatedLlmRequest;
use nemo_relay::codec::resolve::{
Expand Down Expand Up @@ -160,6 +160,10 @@ struct GatewayRequestCodec {
}

impl LlmCodec for GatewayRequestCodec {
fn codec_identity(&self) -> LlmCodecIdentity {
self.inner.codec_identity()
}

fn decode(&self, request: &LlmRequest) -> nemo_relay::error::Result<AnnotatedLlmRequest> {
self.inner.decode(request)
}
Expand Down
50 changes: 50 additions & 0 deletions crates/cli/tests/coverage/shared/config_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3271,6 +3271,56 @@ format = "human"
}
}

#[test]
fn logging_rotation_cli_config_preserves_pair_and_rejects_incomplete_pair() {
let temp = tempfile::tempdir().unwrap();
let config_path = isolated_config_path(&temp);
let log_path = temp.path().join("relay.log.jsonl");
std::fs::write(
&config_path,
format!(
r#"
[[logging.sinks]]
path = {}
max_file_size_bytes = 1024
retained_files = 2
"#,
toml_basic_string(log_path.to_string_lossy().as_ref())
),
)
.unwrap();

let resolved = resolve_server_config(&GatewayOverrides {
config: Some(config_path),
..GatewayOverrides::default()
})
.unwrap();
let LogSinkConfig::File(sink) = &resolved.logging.sinks[0];
let rotation = sink.rotation.expect("complete rotation configuration");
assert_eq!(rotation.max_file_size_bytes(), 1024);
assert_eq!(rotation.retained_files(), 2);

let incomplete_path = isolated_config_path(&temp);
std::fs::write(
&incomplete_path,
r#"
[[logging.sinks]]
path = "relay.log.jsonl"
max_file_size_bytes = 1024
"#,
)
.unwrap();
let error = resolve_server_config(&GatewayOverrides {
config: Some(incomplete_path),
..GatewayOverrides::default()
})
.unwrap_err()
.to_string();
assert!(error.contains(
"logging sink max_file_size_bytes and retained_files must be configured together"
));
}

#[test]
fn logging_rejects_invalid_level_format_missing_path_and_zero_queue() {
let temp = tempfile::tempdir().unwrap();
Expand Down
Loading