Skip to content
Merged
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
4 changes: 2 additions & 2 deletions crates/tower-cmd/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ fn build_cli_execution_spec(
run_id: String,
) -> ExecutionSpec {
let spec = ExecutionSpec {
id: run_id,
id: run_id.clone(),
package_stream: Box::new(package_stream),
runtime: ExecRuntimeConfig {
image: "local".to_string(),
Expand Down Expand Up @@ -278,7 +278,7 @@ fn build_cli_execution_spec(
timeout_seconds: 3600,
},
networking: None,
telemetry_ctx: Context::new(),
telemetry_ctx: Context::new("local-runner".to_string()).with_runid(&run_id),
};
spec
}
Expand Down
12 changes: 6 additions & 6 deletions crates/tower-runtime/tests/local_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async fn test_running_hello_world_json_logs() {

// We need to create the package, which will load the app
let opts = StartOptions {
ctx: tower_telemetry::Context::new(),
ctx: tower_telemetry::Context::new("runner-id".to_string()),
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded test value 'runner-id' is ambiguous and repeated across multiple tests. Consider using a more descriptive identifier like 'test-local-runner' or defining a test constant to maintain consistency.

Copilot uses AI. Check for mistakes.
package,
output_sender: sender,
cwd: None,
Expand Down Expand Up @@ -97,7 +97,7 @@ async fn test_running_hello_world() {

// We need to create the package, which will load the app
let opts = StartOptions {
ctx: tower_telemetry::Context::new(),
ctx: tower_telemetry::Context::new("runner-id".to_string()),
package,
output_sender: sender,
cwd: None,
Expand Down Expand Up @@ -142,7 +142,7 @@ async fn test_running_use_faker() {

// We need to create the package, which will load the app
let opts = StartOptions {
ctx: tower_telemetry::Context::new(),
ctx: tower_telemetry::Context::new("runner-id".to_string()),
package,
output_sender: sender,
cwd: None,
Expand Down Expand Up @@ -194,7 +194,7 @@ async fn test_running_legacy_app() {

// We need to create the package, which will load the app
let opts = StartOptions {
ctx: tower_telemetry::Context::new(),
ctx: tower_telemetry::Context::new("runner-id".to_string()),
package,
output_sender: sender,
cwd: None,
Expand Down Expand Up @@ -260,7 +260,7 @@ async fn test_running_app_with_secret() {

// We need to create the package, which will load the app
let opts = StartOptions {
ctx: tower_telemetry::Context::new(),
ctx: tower_telemetry::Context::new("runner-id".to_string()),
package,
output_sender: sender,
cwd: None,
Expand Down Expand Up @@ -339,7 +339,7 @@ async fn test_abort_on_dependency_installation_failure() {
let (sender, mut receiver) = unbounded_channel();

let opts = StartOptions {
ctx: tower_telemetry::Context::new(),
ctx: tower_telemetry::Context::new("runner-id".to_string()),
package,
output_sender: sender,
cwd: None,
Expand Down
2 changes: 1 addition & 1 deletion crates/tower-runtime/tests/subprocess_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn create_execution_spec(id: String, package: Package) -> ExecutionSpec {

ExecutionSpec {
id,
telemetry_ctx: tower_telemetry::Context::new(),
telemetry_ctx: tower_telemetry::Context::new("runner-id".to_string()),
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded test value 'runner-id' is ambiguous. Consider using a more descriptive identifier like 'test-subprocess-runner' to clearly indicate this is a test context.

Suggested change
telemetry_ctx: tower_telemetry::Context::new("runner-id".to_string()),
telemetry_ctx: tower_telemetry::Context::new("test-subprocess-runner".to_string()),

Copilot uses AI. Check for mistakes.
package_stream: Box::new(file),
environment: "test".to_string(),
secrets: HashMap::new(),
Expand Down
12 changes: 8 additions & 4 deletions crates/tower-telemetry/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
pub struct Context {
/// runid is the ID of the run in the current context.
pub runid: Option<String>,
/// runner_id is the ID of the runner instance in the current context.
pub runner_id: String,
}

impl Context {
pub fn from_runid(runid: &str) -> Self {
pub fn new(runner_id: String) -> Self {
Self {
runid: Some(runid.to_string()),
runid: None,
runner_id,
}
}

pub fn new() -> Self {
Self { runid: None }
pub fn with_runid(mut self, runid: &str) -> Self {
self.runid = Some(runid.to_string());
self
}
}
4 changes: 2 additions & 2 deletions crates/tower-telemetry/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ macro_rules! event_with_level {
// With context
($level:expr, ctx: $ctx:expr, $fmt:expr, $($arg:tt)+) => {
if let Some(runid) = &$ctx.runid {
$crate::tracing::event!($level, "tower.runid" = %runid, "{}", format!($fmt, $($arg)+))
$crate::tracing::event!($level, "tower.runid" = %runid, "tower.runner_id" = %$ctx.runner_id, "{}", format!($fmt, $($arg)+))
} else {
$crate::tracing::event!($level, "{}", format!($fmt, $($arg)+))
$crate::tracing::event!($level, "tower.runner_id" = %$ctx.runner_id, "{}", format!($fmt, $($arg)+))
}
};

Expand Down